Class SimpleSLTokenizer


  • public class SimpleSLTokenizer
    extends Object
    Simple utility class for hand-made SL parsing
    Author:
    Giovanni Caire - TILAB
    • Constructor Detail

      • SimpleSLTokenizer

        public SimpleSLTokenizer​(String s)
        Construct a SimpleSLTokenizer that will act on the given String
    • Method Detail

      • 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 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​(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 String quoteString​(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.