org.apache.openejb.util
Class SuperProperties

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.apache.openejb.util.SuperProperties
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.Map<java.lang.Object,java.lang.Object>

public class SuperProperties
extends java.util.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  java.util.LinkedHashMap<java.lang.String,java.util.LinkedHashMap<java.lang.String,java.lang.String>> attributes
          Attributes for the properties.
protected  boolean caseInsensitive
          Are lookups case insensitive?
protected  java.lang.String commentIndent
          Number of spaces to indent comment after '#' character.
protected  java.util.LinkedHashMap<java.lang.String,java.lang.String> comments
          Comments for individual the properties.
protected  java.util.Properties defaults
          The default property values.
protected  java.lang.String indent
          Number of spaces to indent each line of the properties file.
protected  java.lang.String keyValueSeparator
          The text between a key and the value.
protected  java.lang.String lineSeparator
          The line separator to use when storing.
protected  java.util.LinkedHashMap<java.lang.Object,java.lang.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(java.util.Properties properties)
          Constructs a new Properties object using the specified default properties.
 
Method Summary
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(java.lang.Object value)
           
 boolean containsKey(java.lang.Object key)
           
 boolean containsValue(java.lang.Object value)
           
 java.util.Enumeration<java.lang.Object> elements()
           
 java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
          Returns an unmodifiable view of the entries.
 boolean equals(java.lang.Object o)
           
 java.lang.Object get(java.lang.Object key)
           
 java.util.Map<java.lang.String,java.lang.String> getAttributes(java.lang.String name)
          Searches for the attributes associated with the specified property.
 java.lang.String getComment(java.lang.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.
 java.lang.String getKeyValueSeparator()
          Gets the text that separates keys and values.
 java.lang.String getLineSeparator()
          Gets the text that separates lines while storing.
 java.lang.String getProperty(java.lang.String name)
           
 java.lang.String getProperty(java.lang.String name, java.lang.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?
 java.util.Enumeration<java.lang.Object> keys()
           
 java.util.Set<java.lang.Object> keySet()
          Returns an unmodifiable view of the keys.
 void list(java.io.PrintStream out)
           
 void list(java.io.PrintWriter writer)
           
 void load(java.io.InputStream in)
           
 void loadFromXML(java.io.InputStream in)
           
 java.util.Enumeration<?> propertyNames()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
           
 void putAll(java.util.Map<?,?> t)
           
protected  void rehash()
           
 java.lang.Object remove(java.lang.Object key)
           
 void save(java.io.OutputStream out, java.lang.String comment)
           
 void setCaseInsensitive(boolean caseInsensitive)
          Sets the sensitive of lookups.
 void setComment(java.lang.String name, java.lang.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(java.lang.String keyValueSeparator)
          Sets the text that separates keys and values.
 void setLineSeparator(java.lang.String lineSeparator)
          Sets the text that separates lines while storing
 java.lang.Object setProperty(java.lang.String name, java.lang.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(java.io.OutputStream out, java.lang.String headComment)
           
 void storeToXML(java.io.OutputStream os, java.lang.String comment)
           
 void storeToXML(java.io.OutputStream os, java.lang.String headComment, java.lang.String encoding)
           
 java.lang.String toString()
           
 java.util.Collection<java.lang.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 java.util.LinkedHashMap<java.lang.Object,java.lang.Object> properties
Actual property values.


comments

protected java.util.LinkedHashMap<java.lang.String,java.lang.String> comments
Comments for individual the properties.


attributes

protected java.util.LinkedHashMap<java.lang.String,java.util.LinkedHashMap<java.lang.String,java.lang.String>> attributes
Attributes for the properties.


defaults

protected java.util.Properties defaults
The default property values.


caseInsensitive

protected boolean caseInsensitive
Are lookups case insensitive?


keyValueSeparator

protected java.lang.String keyValueSeparator
The text between a key and the value.


lineSeparator

protected java.lang.String lineSeparator
The line separator to use when storing. Defaults to system line separator.


indent

protected java.lang.String indent
Number of spaces to indent each line of the properties file.


commentIndent

protected java.lang.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(java.util.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 java.lang.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(java.lang.String keyValueSeparator)
Sets the text that separates keys and values.

Parameters:
keyValueSeparator - the text that separates keys and values

getLineSeparator

public java.lang.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(java.lang.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 java.lang.String getProperty(java.lang.String name)
Overrides:
getProperty in class java.util.Properties

getProperty

public java.lang.String getProperty(java.lang.String name,
                                    java.lang.String defaultValue)
Overrides:
getProperty in class java.util.Properties

setProperty

public java.lang.Object setProperty(java.lang.String name,
                                    java.lang.String value)
Overrides:
setProperty in class java.util.Properties

getComment

public java.lang.String getComment(java.lang.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(java.lang.String name,
                       java.lang.String comment)
Sets the comment associated with a property.

Parameters:
name - the property name; not null
comment - the comment; not null

getAttributes

public java.util.Map<java.lang.String,java.lang.String> getAttributes(java.lang.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(java.io.PrintStream out)
Overrides:
list in class java.util.Properties

list

public void list(java.io.PrintWriter writer)
Overrides:
list in class java.util.Properties

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Overrides:
load in class java.util.Properties
Throws:
java.io.IOException

propertyNames

public java.util.Enumeration<?> propertyNames()
Overrides:
propertyNames in class java.util.Properties

save

public void save(java.io.OutputStream out,
                 java.lang.String comment)
Overrides:
save in class java.util.Properties

store

public void store(java.io.OutputStream out,
                  java.lang.String headComment)
           throws java.io.IOException
Overrides:
store in class java.util.Properties
Throws:
java.io.IOException

loadFromXML

public void loadFromXML(java.io.InputStream in)
                 throws java.io.IOException
Overrides:
loadFromXML in class java.util.Properties
Throws:
java.io.IOException

storeToXML

public void storeToXML(java.io.OutputStream os,
                       java.lang.String comment)
                throws java.io.IOException
Overrides:
storeToXML in class java.util.Properties
Throws:
java.io.IOException

storeToXML

public void storeToXML(java.io.OutputStream os,
                       java.lang.String headComment,
                       java.lang.String encoding)
                throws java.io.IOException
Overrides:
storeToXML in class java.util.Properties
Throws:
java.io.IOException

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
isEmpty in class java.util.Hashtable<java.lang.Object,java.lang.Object>

size

public int size()
Specified by:
size in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
size in class java.util.Hashtable<java.lang.Object,java.lang.Object>

get

public java.lang.Object get(java.lang.Object key)
Specified by:
get in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
get in class java.util.Hashtable<java.lang.Object,java.lang.Object>

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Specified by:
put in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
put in class java.util.Hashtable<java.lang.Object,java.lang.Object>

remove

public java.lang.Object remove(java.lang.Object key)
Specified by:
remove in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
remove in class java.util.Hashtable<java.lang.Object,java.lang.Object>

putAll

public void putAll(java.util.Map<?,?> t)
Specified by:
putAll in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
putAll in class java.util.Hashtable<java.lang.Object,java.lang.Object>

keySet

public java.util.Set<java.lang.Object> keySet()
Returns an unmodifiable view of the keys.

Specified by:
keySet in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
keySet in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Returns:
an unmodifiable view of the keys

keys

public java.util.Enumeration<java.lang.Object> keys()
Overrides:
keys in class java.util.Hashtable<java.lang.Object,java.lang.Object>

values

public java.util.Collection<java.lang.Object> values()
Returns an unmodifiable view of the values.

Specified by:
values in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
values in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Returns:
an unmodifiable view of the values

entrySet

public java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
Returns an unmodifiable view of the entries.

Specified by:
entrySet in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
entrySet in class java.util.Hashtable<java.lang.Object,java.lang.Object>
Returns:
an unmodifiable view of the entries

elements

public java.util.Enumeration<java.lang.Object> elements()
Overrides:
elements in class java.util.Hashtable<java.lang.Object,java.lang.Object>

containsKey

public boolean containsKey(java.lang.Object key)
Specified by:
containsKey in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
containsKey in class java.util.Hashtable<java.lang.Object,java.lang.Object>

containsValue

public boolean containsValue(java.lang.Object value)
Specified by:
containsValue in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
containsValue in class java.util.Hashtable<java.lang.Object,java.lang.Object>

contains

public boolean contains(java.lang.Object value)
Overrides:
contains in class java.util.Hashtable<java.lang.Object,java.lang.Object>

clear

public void clear()
Specified by:
clear in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
clear in class java.util.Hashtable<java.lang.Object,java.lang.Object>

clone

public java.lang.Object clone()
Overrides:
clone in class java.util.Hashtable<java.lang.Object,java.lang.Object>

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
equals in class java.util.Hashtable<java.lang.Object,java.lang.Object>

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Map<java.lang.Object,java.lang.Object>
Overrides:
hashCode in class java.util.Hashtable<java.lang.Object,java.lang.Object>

toString

public java.lang.String toString()
Overrides:
toString in class java.util.Hashtable<java.lang.Object,java.lang.Object>

rehash

protected void rehash()
Overrides:
rehash in class java.util.Hashtable<java.lang.Object,java.lang.Object>


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