org.apache.openejb.util
Class SuperProperties

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable<Object,Object>
          extended by java.util.Properties
              extended by org.apache.openejb.util.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:
Hashtable, System.getProperties(), Serialized Form

Field Summary
protected  LinkedHashMap<String,LinkedHashMap<String,String>> attributes
          Attributes for the properties.
protected  boolean caseInsensitive
          Are lookups case insensitive?
protected  String commentIndent
          Number of spaces to indent comment after '#' character.
protected  LinkedHashMap<String,String> comments
          Comments for the properties.
protected  Properties defaults
          The default property values.
protected  String indent
          Number of spaces to indent each line of the properties file.
protected  String keyValueSeparator
          The text between a key and the value.
protected  String lineSeparator
          The line separator to use when storing.
protected  LinkedHashMap<Object,Object> properties
          Actual property values.
protected  boolean spaceAfterComment
          Should there be a blank line between a comment and the property.
protected  boolean spaceBetweenProperties
          Should there be a blank line between properties.
 
Constructor Summary
SuperProperties()
          Constructs a new Properties object.
SuperProperties(Properties properties)
          Constructs a new Properties object using the specified default properties.
 
Method Summary
 void clear()
           
 Object clone()
           
 boolean contains(Object value)
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Enumeration<Object> elements()
           
 Set<Map.Entry<Object,Object>> entrySet()
          Returns an unmodifiable view of the entries.
 boolean equals(Object o)
           
 Object get(Object key)
           
 Map<String,String> getAttributes(String name)
          Searches for the attributes associated with the specified property.
 String getComment(String name)
          Searches for the comment associated with the specified property.
 int getCommentIndent()
          Gets the number of spaces to indent comment after '#' character.
 int getIndent()
          Gets the number of spaces to indent each line of the properties file.
 String getKeyValueSeparator()
          Gets the text that separates keys and values.
 String getLineSeparator()
          Gets the text that separates lines while storing.
 String getProperty(String name)
           
 String getProperty(String name, String defaultValue)
           
 int hashCode()
           
 boolean isCaseInsensitive()
          Are lookups case insensitive?
 boolean isEmpty()
           
 boolean isSpaceAfterComment()
          Should there be a blank line between a comment and the property?
 boolean isSpaceBetweenProperties()
          Should a blank line be added between properties?
 Enumeration<Object> keys()
           
 Set<Object> keySet()
          Returns an unmodifiable view of the keys.
 void list(PrintStream out)
           
 void list(PrintWriter writer)
           
 void load(InputStream in)
           
 void loadFromXML(InputStream in)
           
 Enumeration<?> propertyNames()
           
 Object put(Object key, Object value)
           
 void putAll(Map<?,?> t)
           
protected  void rehash()
           
 Object remove(Object key)
           
 void save(OutputStream out, String comment)
           
 void setCaseInsensitive(boolean caseInsensitive)
          Sets the sensitive of lookups.
 void setComment(String name, String comment)
          Sets the comment associated with a property.
 void setCommentIndent(int commentIndent)
          Sets the number of spaces to indent comment after '#' character.
 void setIndent(int indent)
          Sets the number of spaces to indent each line of the properties file.
 void setKeyValueSeparator(String keyValueSeparator)
          Sets the text that separates keys and values.
 void setLineSeparator(String lineSeparator)
          Sets the text that separates lines while storing
 Object setProperty(String name, String value)
           
 void setSpaceAfterComment(boolean spaceAfterComment)
          If true a blank line will be added between a comment and the property.
 void setSpaceBetweenProperties(boolean spaceBetweenProperties)
          If true a blank line will be added between properties.
 int size()
           
 void store(OutputStream out, String headComment)
           
 void storeToXML(OutputStream os, String comment)
           
 void storeToXML(OutputStream os, String headComment, String encoding)
           
 String toString()
           
 Collection<Object> values()
          Returns an unmodifiable view of the values.
 
Methods inherited from class java.util.Properties
load, store, stringPropertyNames
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

properties

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


comments

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


attributes

protected LinkedHashMap<String,LinkedHashMap<String,String>> 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 Detail

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 Detail

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

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>


Copyright © 1999-2011 The Apache OpenEJB development community. All Rights Reserved.