Class ProfileParser


  • public class ProfileParser
    extends java.lang.Object
    Converts between the string version of a profile specification and the parsed triples and back again.
    Author:
    Gaurang Mehta, Jens-S. Vöckler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static byte[][] c_action
      There are six identified actions.
      private static byte[][] c_state
      Table to contain the state transition diagram for the parser.
    • Constructor Summary

      Constructors 
      Constructor Description
      ProfileParser()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String combine​(Profiles p)
      Creates a profile string from the internal representation.
      static java.lang.String combine​(java.util.List l)
      Creates a profile string from the internal representation.
      static void main​(java.lang.String[] args)
      Test program.
      static java.util.List parse​(java.lang.String s)
      Parses a given user profile specification into a map of maps.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • c_state

        private static final byte[][] c_state
        Table to contain the state transition diagram for the parser. The rows are defined as current states 0 through 7. The columns is the current input character. The cell contains first the action to be taken, followed by the new state to transition to:
              | EOS | adu |  ,  |  ;  |  :  |  \  |  "  |  =  |other|
              |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |
         -----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
           0  | -,F |Cn,0 | -,E1| -,E1| -,1 | -,E1| -,E1| -,E1| -,E1|
           1  | -,E2| -,E1| -,E1| -,E1| -,2 | -,E1| -,E1| -,E1| -,E1|
           2  | -,F |Ck,2 | -,E1| -,E1| -,E1| -,E1| -,E1| -,3 |Ck,E1|
           3  | -,E2|Cv,6 | -E1 | -,E1| -,E1| -,E1| -,4 | -,E1|Cv,6 |
           4  | -,E2|Cv,4 |Cv,4 |Cv,4 |Cv,4 | -,5 | -,7 |Cv,4 |Cv,4 |
           5  | -,E2|Cv,4 |Cv,4 |Cv,4 |Cv,4 |Cv,4 |Cv,4 |Cv,4 |Cv,4 |
           6  |A1,F |Cv,6 |A2,2 |A1,0 | -,E1| -,E1| -,E1| -,E1|Cv,6 |
           7  |A1,F | -,E1|A2,2 |A1,0 | -,E1| -,E1| -,E1| -,E1| -,E1|
         -----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
           F  |  8  | final state
           E1 |  9  | error1: illegal character in input
           E2 | 10  | error2: premature end of input
         
        The state variable collects the new state for a given state (rows) and input character set (column) identifier.
      • c_action

        private static final byte[][] c_action
        There are six identified actions.
          -   | 0 | noop
          Cn  | 1 | append input character to namespace field
          Ck  | 2 | append input character to key field
          Cv  | 3 | append input character to value field
          A1  | 4 | create triple and flush all fields
          A2  | 5 | create triple and flush key and value only
         
        The action variable collects the action to take for a given state (rows) and input character set (column).
    • Constructor Detail

      • ProfileParser

        public ProfileParser()
    • Method Detail

      • parse

        public static java.util.List parse​(java.lang.String s)
                                    throws ProfileParserException
        Parses a given user profile specification into a map of maps.
        Parameters:
        s - is the input string to parse
        Returns:
        a map of namespaces mapping to maps of key value pairs.
        Throws:
        ProfileParserException - if the input cannot be recognized
        See Also:
        combine( List m )
      • combine

        public static java.lang.String combine​(Profiles p)
        Creates a profile string from the internal representation.
        Parameters:
        l - is a list of profiles
        Returns:
        a string containing the representation. The string can be empty (FIXME: should it be "null" or null?) for an empty list.
        See Also:
        parse( String s )
      • combine

        public static java.lang.String combine​(java.util.List l)
        Creates a profile string from the internal representation.
        Parameters:
        l - is a list of profiles
        Returns:
        a string containing the representation. The string can be empty (FIXME: should it be "null" or null?) for an empty list.
        See Also:
        parse( String s )
      • main

        public static void main​(java.lang.String[] args)
        Test program.
        Parameters:
        args - are command-line arguments