org.apache.java.util
Class ExtendedProperties

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--org.apache.java.util.ConfigurationsRepository
                    |
                    +--org.apache.java.util.ExtendedProperties
All Implemented Interfaces:
Cloneable, Map, Serializable

public class ExtendedProperties
extends ConfigurationsRepository

This class extends normal Java properties by adding the possibility to use the same key many times concatenating the value strings instead of overwriting them.

The Extended Properties syntax is explained here:

Here is an example of a valid extended properties file:

      # lines starting with # are comments

      # This is the simplest property
      key = value

      # A long property may be separated on multiple lines
      longvalue = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
                  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

      # This is a property with many tokens
      tokens_on_a_line = first token, second token

      # This sequence generates exactly the same result
      tokens_on_multiple_lines = first token
      tokens_on_multiple_lines = second token

      # commas may be escaped in tokens
      commas.excaped = Hi\, what'up?
 

NOTE: this class has not been written for performance nor low memory usage. In fact, it's way slower than it could be and generates too much memory garbage. But since performance it's not an issue during intialization (and there no much time to improve it), I wrote it this way. If you don't like it, go ahead and tune it up!

See Also:
Configurations, Serialized Form

Inner Class Summary
(package private)  class ExtendedProperties.PropertiesReader
          This class is used to read properties lines.
(package private)  class ExtendedProperties.PropertiesTokenizer
          This class divides into tokens a property value.
 
Inner classes inherited from class java.util.Map
Map.Entry
 
Fields inherited from class org.apache.java.util.ConfigurationsRepository
file, model
 
Constructor Summary
ExtendedProperties()
          Creates an empty extended properties object.
ExtendedProperties(String file)
          Creates and loads the extended properties from the specified file.
 
Method Summary
 String getInclude()
          Gets the property value for including other properties files By default it is "include"
 void load(InputStream input)
          Load the properties from the given input stream.
 void save(OutputStream output, String Header)
          Save the properties to the given outputstream.
 void setInclude(String inc)
          Sets the property value for including other properties files.
 
Methods inherited from class org.apache.java.util.ConfigurationsRepository
combine
 
Methods inherited from class java.util.Hashtable
, clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtendedProperties

public ExtendedProperties()
Creates an empty extended properties object.

ExtendedProperties

public ExtendedProperties(String file)
                   throws IOException
Creates and loads the extended properties from the specified file.
Method Detail

getInclude

public String getInclude()
Gets the property value for including other properties files By default it is "include"

setInclude

public void setInclude(String inc)
Sets the property value for including other properties files. By default it is "include"

load

public void load(InputStream input)
          throws IOException
Load the properties from the given input stream.
Overrides:
load in class ConfigurationsRepository

save

public void save(OutputStream output,
                 String Header)
          throws IOException
Save the properties to the given outputstream.
Overrides:
save in class ConfigurationsRepository