Class CommentedProperties

java.lang.Object
java.util.Dictionary<K,​V>
java.util.Hashtable<java.lang.Object,​java.lang.Object>
java.util.Properties
gaiasky.desktop.util.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
  • Constructor Summary

    Constructors
    Constructor Description
    CommentedProperties()  
  • Method Summary

    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 Details

    • 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 Details

    • CommentedProperties

      public CommentedProperties()
  • Method Details

    • 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.
    • clone

      public CommentedProperties clone()
      Overrides:
      clone in class java.util.Properties