org.pf.file
Class PropertiesFileContent

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<java.lang.Object,java.lang.Object>
          extended by java.util.Properties
              extended by org.pf.util.OrderedProperties
                  extended by org.pf.file.PropertiesFileContent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class PropertiesFileContent
extends OrderedProperties

Represents a properties collection with empty lines and comments. The order will be preserved.

Version:
1.0
Author:
Manfred Duchrow
See Also:
Serialized Form

Constructor Summary
PropertiesFileContent()
          Initialize the new instance with default values.
PropertiesFileContent(int initialCapacity)
          Initialize the new instance with an initial capacity.
 
Method Summary
 void addLine(java.lang.String line)
          Adds the given line at the end of all contained elements
 boolean addProperty(java.lang.String name, java.lang.String value)
          Adds the property with the specified name and value.
 boolean commentProperty(java.lang.String name)
          Turns the property specified by the given name to a comment.
 boolean modifyProperty(java.lang.String name, java.lang.String newValue)
          Modifies the value of the property specified by the given name.
 java.lang.Object setProperty(java.lang.String name, java.lang.String value)
          Modifies the value or adds the property specified by the given name.
 boolean uncommentProperty(java.lang.String name)
          Changes a comment containing the property specified by the given name to a real property setting, by removing the leading comment indicator '#'.
 
Methods inherited from class org.pf.util.OrderedProperties
clear, deleteProperty, entrySet, getProperty, getProperty, getPropertyNames, keys, keySet, list, list, load, propertyNames, remove, save, size, store
 
Methods inherited from class java.util.Properties
loadFromXML, storeToXML, storeToXML
 
Methods inherited from class java.util.Hashtable
clone, contains, containsKey, containsValue, elements, equals, get, hashCode, isEmpty, put, putAll, toString, values
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PropertiesFileContent

public PropertiesFileContent()
Initialize the new instance with default values.


PropertiesFileContent

public PropertiesFileContent(int initialCapacity)
Initialize the new instance with an initial capacity.

Method Detail

addLine

public void addLine(java.lang.String line)
Adds the given line at the end of all contained elements


setProperty

public java.lang.Object setProperty(java.lang.String name,
                                    java.lang.String value)
Modifies the value or adds the property specified by the given name. Returns true if the property was found and modified or added, otherwise false.

Overrides:
setProperty in class OrderedProperties
Parameters:
name - The name of the property to set
value - The new value to be set

modifyProperty

public boolean modifyProperty(java.lang.String name,
                              java.lang.String newValue)
Modifies the value of the property specified by the given name. Returns true if the property was found and modified, otherwise false.

Parameters:
name - The name of the property to modify
newValue - The new value to be set

addProperty

public boolean addProperty(java.lang.String name,
                           java.lang.String value)
Adds the property with the specified name and value. Returns true if the property was added, otherwise false. In particular it will not be added if a property with the same name already exists (returns false then).

Parameters:
name - The name of the property to add
value - The value to be set

commentProperty

public boolean commentProperty(java.lang.String name)
Turns the property specified by the given name to a comment. Returns true if the property was found and changed to a comment, otherwise false.

Parameters:
name - The name of the property to change to be a comment

uncommentProperty

public boolean uncommentProperty(java.lang.String name)
Changes a comment containing the property specified by the given name to a real property setting, by removing the leading comment indicator '#'. Returns true if the property was found in a comment and changed to a non-comment, otherwise false.

Parameters:
name - The name of the property to change from a comment to a property