Class CommentedProperties

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,​java.lang.Object>

    public class CommentedProperties
    extends java.util.Properties
    The CommentedProperties class is an extension of java.util.Properties to allow retention of comment lines and blank (whitespace only) lines in the properties file.

    Written for Java version 1.4

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.util.Vector<java.lang.String> keyData
      Use a Vector to keep a copy of lines containing a key, i.e.
      java.util.Vector<java.lang.String> lineData
      Use a Vector to keep a copy of lines that are a comment or 'blank'
      • Fields inherited from class java.util.Properties

        defaults
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String keyString, java.lang.String value)
      Add a Property to the end of the CommentedProperties.
      void addLine​(java.lang.String line)
      Add a comment or blank line or comment to the end of the CommentedProperties.
      CommentedProperties clone()  
      void load​(java.io.InputStream inStream)
      Load properties from the specified InputStream.
      void store​(java.io.OutputStream out, java.lang.String header)  
      void store​(java.io.OutputStream out, java.lang.String header, java.lang.String encoding)
      Write the properties to the specified OutputStream.
      • Methods inherited from class java.util.Properties

        clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • lineData

        public java.util.Vector<java.lang.String> lineData
        Use a Vector to keep a copy of lines that are a comment or 'blank'
      • keyData

        public java.util.Vector<java.lang.String> keyData
        Use a Vector to keep a copy of lines containing a key, i.e. they are a property.
    • Constructor Detail

      • CommentedProperties

        public CommentedProperties()
    • Method Detail

      • load

        public void load​(java.io.InputStream inStream)
                  throws java.io.IOException
        Load properties from the specified InputStream. Overload the load method in Properties so we can keep comment and blank lines.
        Overrides:
        load in class java.util.Properties
        Parameters:
        inStream - The InputStream to read.
        Throws:
        java.io.IOException
      • store

        public void store​(java.io.OutputStream out,
                          java.lang.String header)
                   throws java.io.IOException
        Overrides:
        store in class java.util.Properties
        Throws:
        java.io.IOException
      • store

        public void store​(java.io.OutputStream out,
                          java.lang.String header,
                          java.lang.String encoding)
                   throws java.io.IOException
        Write the properties to the specified OutputStream.

        Overloads the store method in Properties so we can put back comment and blank lines.

        Parameters:
        out - The OutputStream to write to.
        header - Ignored, here for compatability w/ Properties.
        encoding - The encoding of the file
        Throws:
        java.io.IOException
      • add

        public void add​(java.lang.String keyString,
                        java.lang.String value)
        Add a Property to the end of the CommentedProperties.
        Parameters:
        keyString - The Property key.
        value - The value of this Property.
      • addLine

        public void addLine​(java.lang.String line)
        Add a comment or blank line or comment to the end of the CommentedProperties.
        Parameters:
        line - The string to add to the end, make sure this is a comment or a 'whitespace' line.