Class CommentedProperties

All Implemented Interfaces:
Serializable, Cloneable, Map<Object,Object>

public class CommentedProperties extends 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:
  • Field Details

    • lineData

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

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

    • CommentedProperties

      public CommentedProperties()
  • Method Details

    • load

      public void load(InputStreamReader isr) throws IOException
      Load properties from the specified InputStreamReader. Overload the load method in Properties so we can keep comment and blank lines.
      Parameters:
      isr - The InputStreamReader to read.
      Throws:
      IOException
    • load

      public void load(InputStream inStream) throws 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 Properties
      Parameters:
      inStream - The InputStream to read.
      Throws:
      IOException
    • store

      public void store(OutputStream out, String header) throws IOException
      Overrides:
      store in class Properties
      Throws:
      IOException
    • store

      public void store(OutputStream out, String header, String encoding, Map<String,String> missing) throws IOException
      Throws:
      IOException
    • store

      public void store(OutputStream out, String header, String encoding) throws 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 compatibility w/ Properties.
      encoding - The encoding of the file
      Throws:
      IOException - If the creation of the writer fails.
    • add

      public void add(String keyString, 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(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.
    • clone

      public CommentedProperties clone()
      Overrides:
      clone in class Properties