Package jade.content.lang.sl
Class SLCodec
- java.lang.Object
-
- jade.content.lang.Codec
-
- jade.content.lang.StringCodec
-
- jade.content.lang.sl.SLCodec
-
- All Implemented Interfaces:
Serializable,Serializable
public class SLCodec extends StringCodec
The codec class for the FIPA-SLn languages. This class implements theCodecinterface and allows converting back and forth between strings and frames, according to the SL grammar. By default the class implements full SL grammar, otherwise the proper value must be used in the constructor.- Version:
- $Date$ $Revision$
- Author:
- Fabio Bellifemine - TILAB, Nicolas Lhuillier - Motorola (added support for byte[] primitive)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jade.content.lang.Codec
Codec.CodecException
-
-
Field Summary
Fields Modifier and Type Field Description static StringPRESERVE_JAVA_TYPES-
Fields inherited from class jade.content.lang.Codec
UNNAMEDPREFIX
-
-
Constructor Summary
Constructors Constructor Description SLCodec()Construct a Codec object for the full SL-language (FIPA-SL).SLCodec(boolean preserveJavaTypes)Create an SLCodec for the full SL-language (FIPA-SL) specifying whether or not java primitive types (long, int, float, double) must be preserved.SLCodec(int slType)Construct a Codec object for the given profile of SL-language.SLCodec(int slType, boolean preserveJavaTypes)Create an SLCodec for the given profile of SL-language specifying whether or not java primitive types (long, int, float, double) must be preserved.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AbsContentElementdecode(Ontology ontology, String content)Decodes the content to an abstract description.AbsContentElementdecode(String content)Decodes the content to an abstract description.AbsPredicatedecodeFormula(Ontology ontology, String formula)Decodes the content to an abstract description, where the content is known to be a Well-formed FormulaAbsTermdecodeTerm(Ontology ontology, String term)Decodes the content to an abstract description, where the content is known to be a Term.Stringencode(AbsContentElement content)Encodes a content into a String.Stringencode(Ontology ontology, AbsContentElement content)Encodes a content into a String.StringencodeFormula(Ontology ontology, AbsPredicate formula)Encodes the content into a String, where the content is known to be a Well-formed FormulaStringencodeTerm(Ontology ontology, AbsTerm term)Encodes the content into a String, where the content is known to be a Term.OntologygetInnerOntology()booleangetPreserveJavaTypes()static voidmain(String[] args)protected ObjectreadResolve()Restore parser after deserialization.
-
-
-
Field Detail
-
PRESERVE_JAVA_TYPES
public static final String PRESERVE_JAVA_TYPES
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SLCodec
public SLCodec()
Construct a Codec object for the full SL-language (FIPA-SL).
-
SLCodec
public SLCodec(boolean preserveJavaTypes)
Create an SLCodec for the full SL-language (FIPA-SL) specifying whether or not java primitive types (long, int, float, double) must be preserved. This is achieved by encoding long values asL and float values as - Parameters:
preserveJavaTypes- Indicates whether or not java primitive types must be preserved
-
SLCodec
public SLCodec(int slType)
Construct a Codec object for the given profile of SL-language.- Parameters:
slType- specify 0 for FIPA-SL0, 1 for FIPA-SL1, 2 for FIPA-SL2, any other value can be used for full FIPA-SL
-
SLCodec
public SLCodec(int slType, boolean preserveJavaTypes)Create an SLCodec for the given profile of SL-language specifying whether or not java primitive types (long, int, float, double) must be preserved.- Parameters:
slType- specify 0 for FIPA-SL0, 1 for FIPA-SL1, 2 for FIPA-SL2, any other value can be used for full FIPA-SLpreserveJavaTypes- Indicates whether or not java primitive types must be preserved
-
Method Detail
-
getPreserveJavaTypes
public boolean getPreserveJavaTypes()
-
encode
public String encode(AbsContentElement content) throws Codec.CodecException
Encodes a content into a String.- Specified by:
encodein classStringCodec- Parameters:
content- the content as an abstract descriptor.- Returns:
- the content as a String.
- Throws:
Codec.CodecException
-
encode
public String encode(Ontology ontology, AbsContentElement content) throws Codec.CodecException
Encodes a content into a String.- Specified by:
encodein classStringCodec- Parameters:
ontology- the ontologycontent- the content as an abstract descriptor.- Returns:
- the content as a String.
- Throws:
Codec.CodecException
-
decode
public AbsContentElement decode(String content) throws Codec.CodecException
Decodes the content to an abstract description.- Specified by:
decodein classStringCodec- Parameters:
content- the content as a String.- Returns:
- the content as an abstract description.
- Throws:
Codec.CodecException
-
decode
public AbsContentElement decode(Ontology ontology, String content) throws Codec.CodecException
Decodes the content to an abstract description.- Specified by:
decodein classStringCodec- Parameters:
ontology- the ontology.content- the content as a String.- Returns:
- the content as an abstract description.
- Throws:
Codec.CodecException
-
decodeTerm
public AbsTerm decodeTerm(Ontology ontology, String term) throws Codec.CodecException
Decodes the content to an abstract description, where the content is known to be a Term.- Parameters:
ontology- the ontology.cterm- the term as a String.- Returns:
- the content as an abstract description.
- Throws:
Codec.CodecException- Since:
- JADE 3.4
-
encodeTerm
public String encodeTerm(Ontology ontology, AbsTerm term) throws Codec.CodecException
Encodes the content into a String, where the content is known to be a Term.- Parameters:
ontology- the ontology.term- the termt as an abstract descriptor- Returns:
- the content as a String
- Throws:
Codec.CodecException- Since:
- JADE 3.4
-
decodeFormula
public AbsPredicate decodeFormula(Ontology ontology, String formula) throws Codec.CodecException
Decodes the content to an abstract description, where the content is known to be a Well-formed Formula- Parameters:
ontology- the ontology.formula- the content as a String.- Returns:
- the content as an abstract description.
- Throws:
Codec.CodecException- Since:
- JADE 3.4
-
encodeFormula
public String encodeFormula(Ontology ontology, AbsPredicate formula) throws Codec.CodecException
Encodes the content into a String, where the content is known to be a Well-formed Formula- Parameters:
ontology- the ontology.formula- the formula as an abstract descriptor- Returns:
- the content as a String
- Throws:
Codec.CodecException- Since:
- JADE 3.4
-
main
public static void main(String[] args)
-
getInnerOntology
public Ontology getInnerOntology()
- Overrides:
getInnerOntologyin classCodec- Returns:
- the ontology containing the schemas of the operator defined in this language
-
readResolve
protected Object readResolve() throws ObjectStreamException
Restore parser after deserialization.
The readResolve method is called when ObjectInputStream has read an object from the stream and is preparing to return it to the caller.
The readResolve method is not invoked on the object until the object is fully constructed.- Throws:
ObjectStreamException
-
-
-