Class ConfigurationHandler


  • public class ConfigurationHandler
    extends java.lang.Object
    The ConfigurationHandler class implements configuration reading form a java.io.InputStream and writing to a java.io.OutputStream on behalf of the FilePersistenceManager class.
     cfg = prop "=" value .
      prop = symbolic-name . // 1.4.2 of OSGi Core Specification
      symbolic-name = token { "." token } .
      token = { [ 0..9 ] | [ a..z ] | [ A..Z ] | '_' | '-' } .
      value = [ type ] ( "[" values "]" | "(" values ")" | simple ) .
      values = simple { "," simple } .
      simple = """ stringsimple """ .
      type = // 1-char type code .
      stringsimple = // quoted string representation of the value .
     
    • Constructor Detail

      • ConfigurationHandler

        private ConfigurationHandler()
    • Method Detail

      • write

        public static void write​(java.io.OutputStream out,
                                 java.util.Dictionary properties)
                          throws java.io.IOException
        Writes the configuration data from the Dictionary to the given OutputStream.

        This method writes at the current location in the stream and does not close the outputstream.

        Parameters:
        out - The OutputStream to write the configurtion data to.
        properties - The Dictionary to write.
        Throws:
        java.io.IOException - If an error occurrs writing to the output stream.
      • write

        public static java.lang.String write​(java.lang.Object value)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • orderedKeys

        private static java.util.Enumeration orderedKeys​(java.util.Dictionary properties)
        Generates an Enumeration for the given Dictionary where the keys of the Dictionary are provided in sorted order.
        Parameters:
        properties - The Dictionary that keys are sorted.
        Returns:
        An Enumeration that provides the keys of properties in an ordered manner.
      • read

        public static java.util.Dictionary read​(java.io.InputStream ins)
                                         throws java.io.IOException
        Reads configuration data from the given InputStream and returns a new Dictionary object containing the data.

        This method reads from the current location in the stream upto the end of the stream but does not close the stream at the end.

        Parameters:
        ins - The InputStream from which to read the configuration data.
        Returns:
        A Dictionary object containing the configuration data. This object may be empty if the stream contains no configuration data.
        Throws:
        java.io.IOException - If an error occurrs reading from the stream. This exception is also thrown if a syntax error is encountered.
      • read

        public static java.lang.Object read​(java.lang.String value)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readInternal

        private java.util.Dictionary readInternal​(java.io.InputStream ins)
                                           throws java.io.IOException
        Throws:
        java.io.IOException
      • readValue

        private java.lang.Object readValue​(java.io.PushbackReader pr)
                                    throws java.io.IOException
        value = type ( "[" values "]" | "(" values ")" | simple ) . values = value { "," value } . simple = "{" stringsimple "}" . type = // 1-char type code . stringsimple = // quoted string representation of the value .
        Parameters:
        pr -
        Returns:
        Throws:
        java.io.IOException
      • readArray

        private java.lang.Object readArray​(int typeCode,
                                           java.io.PushbackReader pr)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • readCollection

        private java.util.Collection readCollection​(int typeCode,
                                                    java.io.PushbackReader pr)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readSimple

        private java.lang.Object readSimple​(int code,
                                            java.io.PushbackReader pr)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • ensureNext

        private void ensureNext​(java.io.PushbackReader pr,
                                int expected)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • readQuoted

        private java.lang.String readQuoted​(java.io.PushbackReader pr)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • readUnquoted

        private java.lang.String readUnquoted​(java.io.PushbackReader pr)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • nextToken

        private int nextToken​(java.io.PushbackReader pr,
                              boolean newLine)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • ignorableWhiteSpace

        private int ignorableWhiteSpace​(java.io.PushbackReader pr)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • ignorablePageBreakAndWhiteSpace

        private int ignorablePageBreakAndWhiteSpace​(java.io.PushbackReader pr)
                                             throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        private int read​(java.io.PushbackReader pr)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • read

        private int read​(java.io.PushbackReader pr,
                         char[] buf)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • readFailure

        private java.io.IOException readFailure​(int current,
                                                int expected)
      • writeValue

        private static void writeValue​(java.io.Writer out,
                                       java.lang.Object value)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • writeArray

        private static void writeArray​(java.io.Writer out,
                                       java.lang.Object arrayValue)
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCollection

        private static void writeCollection​(java.io.Writer out,
                                            java.util.Collection collection)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCollectionElement

        private static void writeCollectionElement​(java.io.Writer out,
                                                   java.lang.Object element)
                                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeType

        private static void writeType​(java.io.Writer out,
                                      java.lang.Class valueType)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeSimple

        private static void writeSimple​(java.io.Writer out,
                                        java.lang.Object value)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeQuoted

        private static void writeQuoted​(java.io.Writer out,
                                        java.lang.String simple)
                                 throws java.io.IOException
        Throws:
        java.io.IOException