JADE_SL.lang.sl
Class SLCodec

java.lang.Object
  extended byJADE_SL.lang.Codec
      extended byJADE_SL.lang.StringCodec
          extended byJADE_SL.lang.sl.SLCodec

public class SLCodec
extends StringCodec

The codec class for the FIPA-SLn languages. This class implements the 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.

Version:
$Date: 2003/10/09 13:00:36 $ $Revision: 1.1.1.1 $
Author:
Fabio Bellifemine - TILAB

Nested Class Summary
 
Nested classes inherited from class JADE_SL.lang.Codec
Codec.CodecException
 
Field Summary
private static java.util.Vector FullSLFunctionals
           
static java.lang.String IOTA
          Constant needed to create an AbsIRE(SLCodec.IOTA)
private  SLParser parser
           
(package private) static java.lang.String SEQUENCE
           
(package private) static java.lang.String SET
           
private static java.util.Vector SL0Functionals
           
private  java.util.Vector vectorOfPredefinedFunctionals
          Vector of all the functionals which have been pre-defined by FIPA and whose slots should not be encoded
 
Fields inherited from class JADE_SL.lang.Codec
UNNAMEDPREFIX
 
Constructor Summary
SLCodec()
          Construct a Codec object for the full SL-language (FIPA-SL).
SLCodec(int slType)
          Construct a Codec object for the given profile of SL-language.
 
Method Summary
 AbsContentElement decode(Ontology ontology, java.lang.String content)
          Decodes the content to an abstract description.
 AbsContentElement decode(java.lang.String content)
          Decodes the content to an abstract description.
 java.lang.String encode(AbsContentElement content)
          Encodes a content into a String.
private  java.lang.String encode(AbsObject val, boolean encodeSlotNames)
          this method is used by all the toString methods and it exploits the common AbsObject implementation
 java.lang.String encode(Ontology ontology, AbsContentElement content)
          Encodes a content into a String.
private  java.lang.String encode(java.lang.String val)
          Encode a string, taking care of quoting separated words and escaping strings, if necessary
 Ontology getInnerOntology()
           
private  boolean isAWord(java.lang.String s)
          Test if the given string is a legal SL0 word using the FIPA XC00008D spec.
static void main(java.lang.String[] args)
           
private  java.lang.String quotedString(java.lang.String s)
          Take a java String and quote it to form a legal FIPA SL0 string.
private  boolean requiresSlotNames(java.lang.String conceptName)
           
private  java.lang.String toString(AbsAggregate val)
           
private  java.lang.String toString(AbsConcept val)
           
private  java.lang.String toString(AbsIRE val)
           
private  java.lang.String toString(AbsObject val)
           
private  java.lang.String toString(AbsPredicate val)
           
private  java.lang.String toString(AbsPrimitive val)
           
private  java.lang.String toString(AbsVariable val)
           
 
Methods inherited from class JADE_SL.lang.Codec
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

private SLParser parser

IOTA

public static final java.lang.String IOTA
Constant needed to create an AbsIRE(SLCodec.IOTA)

See Also:
Constant Field Values

SET

static final java.lang.String SET
See Also:
Constant Field Values

SEQUENCE

static final java.lang.String SEQUENCE
See Also:
Constant Field Values

vectorOfPredefinedFunctionals

private java.util.Vector vectorOfPredefinedFunctionals
Vector of all the functionals which have been pre-defined by FIPA and whose slots should not be encoded


SL0Functionals

private static java.util.Vector SL0Functionals

FullSLFunctionals

private static java.util.Vector FullSLFunctionals
Constructor Detail

SLCodec

public SLCodec()
Construct a Codec object for the full SL-language (FIPA-SL).


SLCodec

public SLCodec(int slType)
Construct a Codec object for the given profile of SL-language.

Method Detail

encode

public java.lang.String encode(AbsContentElement content)
                        throws Codec.CodecException
Encodes a content into a String.

Specified by:
encode in class StringCodec
Parameters:
content - the content as an abstract descriptor.
Returns:
the content as a String.
Throws:
CodecException
Codec.CodecException

encode

public java.lang.String encode(Ontology ontology,
                               AbsContentElement content)
                        throws Codec.CodecException
Encodes a content into a String.

Specified by:
encode in class StringCodec
Parameters:
ontology - the ontology
content - the content as an abstract descriptor.
Returns:
the content as a String.
Throws:
CodecException
Codec.CodecException

quotedString

private java.lang.String quotedString(java.lang.String s)
Take a java String and quote it to form a legal FIPA SL0 string. Add quotation marks to the beginning/end and escape any quotation marks inside the string. This must be the exact inverse of the procedure in the parser (SLParser.jj) when it encounters a quoted string.


isAWord

private boolean isAWord(java.lang.String s)
Test if the given string is a legal SL0 word using the FIPA XC00008D spec. In addition to FIPA's restrictions, place the additional restriction that a Word can not contain a '\"', that would confuse the parser at the other end.


encode

private java.lang.String encode(java.lang.String val)
Encode a string, taking care of quoting separated words and escaping strings, if necessary


encode

private java.lang.String encode(AbsObject val,
                                boolean encodeSlotNames)
                         throws Codec.CodecException
this method is used by all the toString methods and it exploits the common AbsObject implementation

Parameters:
encodeSlotNames - if true and the name of the slot does not start with Codec.UNNAMEDPREFIX, then the slotName is also encoded, otherwise it is skipped.
Throws:
Codec.CodecException

toString

private java.lang.String toString(AbsPredicate val)
                           throws Codec.CodecException
Throws:
Codec.CodecException

toString

private java.lang.String toString(AbsIRE val)
                           throws Codec.CodecException
Throws:
Codec.CodecException

toString

private java.lang.String toString(AbsVariable val)
                           throws Codec.CodecException
Throws:
Codec.CodecException

requiresSlotNames

private boolean requiresSlotNames(java.lang.String conceptName)

toString

private java.lang.String toString(AbsConcept val)
                           throws Codec.CodecException
Throws:
Codec.CodecException

toString

private java.lang.String toString(AbsAggregate val)
                           throws Codec.CodecException
Throws:
Codec.CodecException

toString

private java.lang.String toString(AbsPrimitive val)
                           throws Codec.CodecException
Throws:
Codec.CodecException

toString

private java.lang.String toString(AbsObject val)
                           throws Codec.CodecException
Throws:
Codec.CodecException

decode

public AbsContentElement decode(java.lang.String content)
                         throws Codec.CodecException
Decodes the content to an abstract description.

Specified by:
decode in class StringCodec
Parameters:
content - the content as a String.
Returns:
the content as an abstract description.
Throws:
CodecException
Codec.CodecException

decode

public AbsContentElement decode(Ontology ontology,
                                java.lang.String content)
                         throws Codec.CodecException
Decodes the content to an abstract description.

Specified by:
decode in class StringCodec
Parameters:
ontology - the ontology.
content - the content as a String.
Returns:
the content as an abstract description.
Throws:
CodecException
Codec.CodecException

main

public static void main(java.lang.String[] args)

getInnerOntology

public Ontology getInnerOntology()
Overrides:
getInnerOntology in class Codec
Returns:
the ontology containing the schemas of the operator defined in this language


Copyright © 2000-2003 BT Exact Technologies. All Rights Reserved.