1 /***
2 * ***************************************************************
3 * JADE - Java Agent DEvelopment Framework is a framework to develop
4 * multi-agent systems in compliance with the FIPA specifications.
5 * Copyright (C) 2000 CSELT S.p.A.
6 *
7 * GNU Lesser General Public License
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation,
12 * version 2.1 of the License.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
23 * **************************************************************
24 */
25 package JADE_SL.lang;
26
27 import JADE_SL.onto.*;
28 import JADE_SL.abs.*;
29
30 /***
31 * Base class for content language codecs that transform
32 * AbsContentElements to/from sequences of strings
33 * @author Giovanni Caire - TILAB
34 */
35 public abstract class StringCodec extends Codec{
36
37 /***
38 * Construct a StringCodec object with the given name
39 */
40 public StringCodec(String name) {
41 super(name);
42 }
43
44 /***
45 * Encodes a content into a string.
46 * @param content the content as an abstract descriptor.
47 * @return the content as a string.
48 * @throws CodecException
49 */
50 public abstract String encode(AbsContentElement content)
51 throws CodecException;
52
53 /***
54 * Encodes a content into a string using a given ontology.
55 * @param ontology the ontology
56 * @param content the content as an abstract descriptor.
57 * @return the content as a string.
58 * @throws CodecException
59 */
60 public abstract String encode(Ontology ontology, AbsContentElement content)
61 throws CodecException;
62
63 /***
64 * Decodes the content to an abstract description.
65 * @param content the content as a string.
66 * @return the content as an abstract description.
67 * @throws CodecException
68 */
69 public abstract AbsContentElement decode(String content)
70 throws CodecException;
71
72 /***
73 * Decodes the content to an abstract description using a
74 * given ontology.
75 * @param ontology the ontology.
76 * @param content the content as a string.
77 * @return the content as an abstract description.
78 * @throws CodecException
79 */
80 public abstract AbsContentElement decode(Ontology ontology, String content)
81 throws CodecException;
82
83 }
84