Class SuperProperties

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

public class SuperProperties extends Properties
Properties is a Hashtable where the keys and values must be Strings. Each Properties can have a default Properties which specifies the default values which are used if the key is not in this Properties.
See Also:
  • Field Details

    • properties

      protected LinkedHashMap<Object,Object> properties
      Actual property values.
    • comments

      protected LinkedHashMap<String,String> comments
      Comments for individual the properties.
    • attributes

      Attributes for the properties.
    • defaults

      protected Properties defaults
      The default property values.
    • caseInsensitive

      protected boolean caseInsensitive
      Are lookups case insensitive?
    • keyValueSeparator

      protected String keyValueSeparator
      The text between a key and the value.
    • lineSeparator

      protected String lineSeparator
      The line separator to use when storing. Defaults to system line separator.
    • indent

      protected String indent
      Number of spaces to indent each line of the properties file.
    • commentIndent

      protected String commentIndent
      Number of spaces to indent comment after '#' character.
    • spaceBetweenProperties

      protected boolean spaceBetweenProperties
      Should there be a blank line between properties.
    • spaceAfterComment

      protected boolean spaceAfterComment
      Should there be a blank line between a comment and the property.
  • Constructor Details

    • SuperProperties

      public SuperProperties()
      Constructs a new Properties object.
    • SuperProperties

      public SuperProperties(Properties properties)
      Constructs a new Properties object using the specified default properties.
      Parameters:
      properties - the default properties
  • Method Details

    • isCaseInsensitive

      public boolean isCaseInsensitive()
      Are lookups case insensitive?
      Returns:
      true if lookups are insensitive
    • setCaseInsensitive

      public void setCaseInsensitive(boolean caseInsensitive)
      Sets the sensitive of lookups.
      Parameters:
      caseInsensitive - if looks are insensitive
    • caseInsensitive

      public SuperProperties caseInsensitive(boolean caseInsensitive)
    • getKeyValueSeparator

      public String getKeyValueSeparator()
      Gets the text that separates keys and values. The default is "=".
      Returns:
      the text that separates keys and values
    • setKeyValueSeparator

      public void setKeyValueSeparator(String keyValueSeparator)
      Sets the text that separates keys and values.
      Parameters:
      keyValueSeparator - the text that separates keys and values
    • getLineSeparator

      public String getLineSeparator()
      Gets the text that separates lines while storing. The default is the system line.separator.
      Returns:
      the text that separates keys and values
    • setLineSeparator

      public void setLineSeparator(String lineSeparator)
      Sets the text that separates lines while storing
      Parameters:
      lineSeparator - the text that separates lines
    • getIndent

      public int getIndent()
      Gets the number of spaces to indent each line of the properties file.
      Returns:
      the number of spaces to indent each line of the properties file
    • setIndent

      public void setIndent(int indent)
      Sets the number of spaces to indent each line of the properties file.
      Parameters:
      indent - the number of spaces to indent each line of the properties file
    • getCommentIndent

      public int getCommentIndent()
      Gets the number of spaces to indent comment after '#' character.
      Returns:
      the number of spaces to indent comment after '#' character
    • setCommentIndent

      public void setCommentIndent(int commentIndent)
      Sets the number of spaces to indent comment after '#' character.
      Parameters:
      commentIndent - the number of spaces to indent comment after '#' character
    • isSpaceBetweenProperties

      public boolean isSpaceBetweenProperties()
      Should a blank line be added between properties?
      Returns:
      true if a blank line should be added between properties; false otherwise
    • setSpaceBetweenProperties

      public void setSpaceBetweenProperties(boolean spaceBetweenProperties)
      If true a blank line will be added between properties.
      Parameters:
      spaceBetweenProperties - if true a blank line will be added between properties
    • isSpaceAfterComment

      public boolean isSpaceAfterComment()
      Should there be a blank line between a comment and the property?
      Returns:
      true if a blank line should be added between a comment and the property
    • setSpaceAfterComment

      public void setSpaceAfterComment(boolean spaceAfterComment)
      If true a blank line will be added between a comment and the property.
      Parameters:
      spaceAfterComment - if true a blank line will be added between a comment and the property
    • getProperty

      public String getProperty(String name)
      Overrides:
      getProperty in class Properties
    • getProperty

      public String getProperty(String name, String defaultValue)
      Overrides:
      getProperty in class Properties
    • setProperty

      public Object setProperty(String name, String value)
      Overrides:
      setProperty in class Properties
    • getComment

      public String getComment(String name)
      Searches for the comment associated with the specified property. If the property is not found, look in the default properties. If the property is not found in the default properties, answer null.
      Parameters:
      name - the name of the property to find
      Returns:
      the named property value
    • setComment

      public void setComment(String name, String comment)
      Sets the comment associated with a property.
      Parameters:
      name - the property name; not null
      comment - the comment; not null
    • getAttributes

      public Map<String,String> getAttributes(String name)
      Searches for the attributes associated with the specified property. If the property is not found, look in the default properties. If the property is not found in the default properties, answer null.
      Parameters:
      name - the name of the property to find
      Returns:
      the attributes for an existing property (not null); null for non-existant properties
    • list

      public void list(PrintStream out)
      Overrides:
      list in class Properties
    • list

      public void list(PrintWriter writer)
      Overrides:
      list in class Properties
    • load

      public void load(InputStream in) throws IOException
      Overrides:
      load in class Properties
      Throws:
      IOException
    • propertyNames

      public Enumeration<?> propertyNames()
      Overrides:
      propertyNames in class Properties
    • save

      public void save(OutputStream out, String comment)
      Overrides:
      save in class Properties
    • store

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

      public void loadFromXML(InputStream in) throws IOException
      Overrides:
      loadFromXML in class Properties
      Throws:
      IOException
    • storeToXML

      public void storeToXML(OutputStream os, String comment) throws IOException
      Overrides:
      storeToXML in class Properties
      Throws:
      IOException
    • storeToXML

      public void storeToXML(OutputStream os, String headComment, String encoding) throws IOException
      Overrides:
      storeToXML in class Properties
      Throws:
      IOException
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<Object,Object>
      Overrides:
      isEmpty in class Hashtable<Object,Object>
    • size

      public int size()
      Specified by:
      size in interface Map<Object,Object>
      Overrides:
      size in class Hashtable<Object,Object>
    • get

      public Object get(Object key)
      Specified by:
      get in interface Map<Object,Object>
      Overrides:
      get in class Hashtable<Object,Object>
    • put

      public Object put(Object key, Object value)
      Specified by:
      put in interface Map<Object,Object>
      Overrides:
      put in class Hashtable<Object,Object>
    • remove

      public Object remove(Object key)
      Specified by:
      remove in interface Map<Object,Object>
      Overrides:
      remove in class Hashtable<Object,Object>
    • putAll

      public void putAll(Map<?,?> t)
      Specified by:
      putAll in interface Map<Object,Object>
      Overrides:
      putAll in class Hashtable<Object,Object>
    • keySet

      public Set<Object> keySet()
      Returns an unmodifiable view of the keys.
      Specified by:
      keySet in interface Map<Object,Object>
      Overrides:
      keySet in class Hashtable<Object,Object>
      Returns:
      an unmodifiable view of the keys
    • keys

      public Enumeration<Object> keys()
      Overrides:
      keys in class Hashtable<Object,Object>
    • values

      public Collection<Object> values()
      Returns an unmodifiable view of the values.
      Specified by:
      values in interface Map<Object,Object>
      Overrides:
      values in class Hashtable<Object,Object>
      Returns:
      an unmodifiable view of the values
    • entrySet

      public Set<Map.Entry<Object,Object>> entrySet()
      Returns an unmodifiable view of the entries.
      Specified by:
      entrySet in interface Map<Object,Object>
      Overrides:
      entrySet in class Hashtable<Object,Object>
      Returns:
      an unmodifiable view of the entries
    • elements

      public Enumeration<Object> elements()
      Overrides:
      elements in class Hashtable<Object,Object>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<Object,Object>
      Overrides:
      containsKey in class Hashtable<Object,Object>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<Object,Object>
      Overrides:
      containsValue in class Hashtable<Object,Object>
    • contains

      public boolean contains(Object value)
      Overrides:
      contains in class Hashtable<Object,Object>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<Object,Object>
      Overrides:
      clear in class Hashtable<Object,Object>
    • clone

      public Object clone()
      Overrides:
      clone in class Hashtable<Object,Object>
    • equals

      public boolean equals(Object o)
      Specified by:
      equals in interface Map<Object,Object>
      Overrides:
      equals in class Hashtable<Object,Object>
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<Object,Object>
      Overrides:
      hashCode in class Hashtable<Object,Object>
    • toString

      public String toString()
      Overrides:
      toString in class Hashtable<Object,Object>
    • rehash

      protected void rehash()
      Overrides:
      rehash in class Hashtable<Object,Object>