public class SLCodec extends StringCodec
Codec
interface 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.Codec.CodecException
Modifier and Type | Field and Description |
---|---|
private StringBuffer |
buffer
This is the StringBuffer used by the encode method
|
private Ontology |
domainOnto |
private ExtendedSLParser |
extendedParser |
private boolean |
metaAllowed
This variable is true, when meta symbols are allowed (metas are a semantics-specific extension to the SL Grammar)
|
private SLParser |
parser |
private boolean |
preserveJavaTypes |
private SL0Ontology |
slOnto |
UNNAMEDPREFIX
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
AbsContentElement |
decode(Ontology ontology,
String content)
Decodes the content to an abstract description.
|
AbsContentElement |
decode(String content)
Decodes the content to an abstract description.
|
AbsPredicate |
decodeFormula(Ontology ontology,
String formula)
Decodes the content to an abstract description, where the content is known to be a Well-formed Formula
|
AbsTerm |
decodeTerm(Ontology ontology,
String term)
Decodes the content to an abstract description, where the content is known to be a Term.
|
String |
encode(AbsContentElement content)
Encodes a content into a String.
|
String |
encode(Ontology ontology,
AbsContentElement content)
Encodes a content into a String.
|
private void |
encodeAndAppend(AbsAggregate val) |
private void |
encodeAndAppend(AbsConcept val) |
private void |
encodeAndAppend(AbsIRE val) |
private void |
encodeAndAppend(AbsObject val) |
private void |
encodeAndAppend(AbsPredicate val)
Encode the passed Abstract Predicate and append its encoding to buffer
|
private void |
encodeAndAppend(AbsPrimitive val) |
private void |
encodeAndAppend(AbsVariable val) |
private void |
encodeAndAppend(String val)
Encode a string, taking care of quoting separated words and
escaping strings, if necessary.
|
String |
encodeFormula(Ontology ontology,
AbsPredicate formula)
Encodes the content into a String, where the content is known to be a Well-formed Formula
|
private void |
encodeSlotsByName(AbsObject val,
String[] slotNames)
Encode the slots of an abstract descriptor by name, i.e.
|
private void |
encodeSlotsByOrder(AbsObject val,
String[] slotNames)
Encode the slots of an abstract descriptor by order, i.e.
|
String |
encodeTerm(Ontology ontology,
AbsTerm term)
Encodes the content into a String, where the content is known to be a Term.
|
private boolean |
getEncodingByOrder(AbsObject abs) |
Ontology |
getInnerOntology() |
boolean |
getPreserveJavaTypes() |
private String[] |
getSlotNames(AbsObject abs) |
private void |
initParser() |
static void |
main(String[] args) |
protected Object |
readResolve()
Restore parser after deserialization.
|
private transient SLParser parser
private transient ExtendedSLParser extendedParser
private SL0Ontology slOnto
private Ontology domainOnto
private transient StringBuffer buffer
private boolean metaAllowed
private boolean preserveJavaTypes
public SLCodec()
public SLCodec(boolean preserveJavaTypes)
preserveJavaTypes
- Indicates whether or not java primitive types must be preservedpublic SLCodec(int slType)
slType
- specify 0 for FIPA-SL0, 1 for FIPA-SL1, 2 for FIPA-SL2, any other value can be used for full FIPA-SLpublic SLCodec(int slType, boolean preserveJavaTypes)
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 preservedprivate void initParser()
public boolean getPreserveJavaTypes()
public String encode(AbsContentElement content) throws Codec.CodecException
encode
in class StringCodec
content
- the content as an abstract descriptor.CodecException
Codec.CodecException
public String encode(Ontology ontology, AbsContentElement content) throws Codec.CodecException
encode
in class StringCodec
ontology
- the ontologycontent
- the content as an abstract descriptor.CodecException
Codec.CodecException
private void encodeAndAppend(String val)
private void encodeAndAppend(AbsPredicate val) throws Codec.CodecException
Codec.CodecException
private void encodeAndAppend(AbsIRE val) throws Codec.CodecException
Codec.CodecException
private void encodeAndAppend(AbsVariable val) throws Codec.CodecException
Codec.CodecException
private void encodeAndAppend(AbsConcept val) throws Codec.CodecException
Codec.CodecException
private void encodeAndAppend(AbsAggregate val) throws Codec.CodecException
Codec.CodecException
private void encodeAndAppend(AbsPrimitive val) throws Codec.CodecException
Codec.CodecException
private void encodeAndAppend(AbsObject val) throws Codec.CodecException
Codec.CodecException
public AbsContentElement decode(String content) throws Codec.CodecException
decode
in class StringCodec
content
- the content as a String.CodecException
Codec.CodecException
public AbsContentElement decode(Ontology ontology, String content) throws Codec.CodecException
decode
in class StringCodec
ontology
- the ontology.content
- the content as a String.CodecException
Codec.CodecException
public AbsTerm decodeTerm(Ontology ontology, String term) throws Codec.CodecException
ontology
- the ontology.cterm
- the term as a String.CodecException
Codec.CodecException
public String encodeTerm(Ontology ontology, AbsTerm term) throws Codec.CodecException
ontology
- the ontology.term
- the termt as an abstract descriptorCodecException
Codec.CodecException
public AbsPredicate decodeFormula(Ontology ontology, String formula) throws Codec.CodecException
ontology
- the ontology.formula
- the content as a String.CodecException
Codec.CodecException
public String encodeFormula(Ontology ontology, AbsPredicate formula) throws Codec.CodecException
ontology
- the ontology.formula
- the formula as an abstract descriptorCodecException
Codec.CodecException
public static void main(String[] args)
public Ontology getInnerOntology()
getInnerOntology
in class Codec
private String[] getSlotNames(AbsObject abs) throws Codec.CodecException
Codec.CodecException
private boolean getEncodingByOrder(AbsObject abs) throws Codec.CodecException
Codec.CodecException
private void encodeSlotsByOrder(AbsObject val, String[] slotNames) throws Codec.CodecException
Codec.CodecException
private void encodeSlotsByName(AbsObject val, String[] slotNames) throws Codec.CodecException
Codec.CodecException
protected Object readResolve() throws ObjectStreamException
ObjectStreamException