jade.content.lang.sl
Class SimpleSLTokenizer

java.lang.Object
  extended by jade.content.lang.sl.SimpleSLTokenizer

public class SimpleSLTokenizer
extends java.lang.Object

Simple utility class for hand-made SL parsing

Author:
Giovanni Caire - TILAB

Constructor Summary
SimpleSLTokenizer(java.lang.String s)
          Construct a SimpleSLTokenizer that will act on the given String
 
Method Summary
 void consumeChar(char c)
          Check that the next character (after eventual spaces) is 'c' and advance the pointer to the character just after
 java.lang.String getElement()
          Return the next SL element (i.e. a word or a generic sequence of char enclosed into "") and advance the pointer to the character just after.
static boolean isAWord(java.lang.String s)
          Test if the given string is a legal SL word using the FIPA XC00008D spec.
 boolean isClosedBracket()
           
 boolean isOpenBracket()
           
 java.lang.String nextToken()
          Return the next SL token (i.e. '(', ')' or a generic element) without advancing the pointer
static java.lang.String quoteString(java.lang.String s)
          Take a java String and quote it to form a legal FIPA SL0 string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSLTokenizer

public SimpleSLTokenizer(java.lang.String s)
Construct a SimpleSLTokenizer that will act on the given String

Method Detail

nextToken

public java.lang.String nextToken()
                           throws Codec.CodecException
Return the next SL token (i.e. '(', ')' or a generic element) without advancing the pointer

Throws:
Codec.CodecException

isOpenBracket

public boolean isOpenBracket()
                      throws Codec.CodecException
Throws:
Codec.CodecException

isClosedBracket

public boolean isClosedBracket()
                        throws Codec.CodecException
Throws:
Codec.CodecException

consumeChar

public void consumeChar(char c)
                 throws Codec.CodecException
Check that the next character (after eventual spaces) is 'c' and advance the pointer to the character just after

Throws:
Codec.CodecException

getElement

public java.lang.String getElement()
                            throws Codec.CodecException
Return the next SL element (i.e. a word or a generic sequence of char enclosed into "") and advance the pointer to the character just after. If the element starts with ':' this is automatically removed. If the element is a sequence of char enclosed into "" the enclosing " are removed and all \" are automatically transformed into "

Throws:
Codec.CodecException

isAWord

public static final boolean isAWord(java.lang.String s)
Test if the given string is a legal SL 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.


quoteString

public static java.lang.String quoteString(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.