|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.configuration.ConfigurationKey
A simple class that supports creation of and iteration on complex configuration keys.
For key creation the class works similar to a StringBuffer: There are
several appendXXXX()
methods with which single parts
of a key can be constructed. All these methods return a reference to the
actual object so they can be written in a chain. When using this methods
the exact syntax for keys need not be known.
This class also defines a specialized iterator for configuration keys. With such an iterator a key can be tokenized into its single parts. For each part it can be checked whether it has an associated index.
Nested Class Summary | |
class |
ConfigurationKey.KeyIterator
A specialized iterator class for tokenizing a configuration key. |
Field Summary | |
static String |
ESCAPED_DELIMITER
Constant for an escaped delimiter. |
static char |
PROPERTY_DELIMITER
Constant for a property delimiter. |
Constructor Summary | |
ConfigurationKey()
Creates a new, empty instance of ConfigurationKey . |
|
ConfigurationKey(String key)
Creates a new instance of ConfigurationKey and
initializes it with the given key. |
Method Summary | |
ConfigurationKey |
append(String property)
Appends the name of a property to this key. |
ConfigurationKey |
appendAttribute(String attr)
Appends an attribute to this configuration key. |
ConfigurationKey |
appendIndex(int index)
Appends an index to this configuration key. |
static String |
attributeName(String key)
Extracts the name of the attribute from the given attribute key. |
ConfigurationKey |
commonKey(ConfigurationKey other)
Returns a configuration key object that is initialized with the part of the key that is common to this key and the passed in key. |
static String |
constructAttributeKey(String key)
Decorates the given key so that it represents an attribute. |
ConfigurationKey |
differenceKey(ConfigurationKey other)
Returns the "difference key" to a given key. |
boolean |
equals(Object c)
Checks if two ConfigurationKey objects are equal. |
int |
hashCode()
Returns the hash code for this object. |
boolean |
isAttributeKey()
Checks if this key is an attribute key. |
static boolean |
isAttributeKey(String key)
Checks if the passed in key is an attribute key. |
ConfigurationKey.KeyIterator |
iterator()
Returns an iterator for iterating over the single components of this configuration key. |
int |
length()
Returns the actual length of this configuration key. |
void |
setLength(int len)
Sets the new length of this configuration key. |
String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final char PROPERTY_DELIMITER
public static final String ESCAPED_DELIMITER
Constructor Detail |
public ConfigurationKey()
ConfigurationKey
.
public ConfigurationKey(String key)
ConfigurationKey
and
initializes it with the given key.
key
- the key as a stringMethod Detail |
public ConfigurationKey append(String property)
property
- the name of the property to be added
public ConfigurationKey appendIndex(int index)
index
- the index to be appended
public ConfigurationKey appendAttribute(String attr)
attr
- the name of the attribute to be appended
public boolean isAttributeKey()
public static boolean isAttributeKey(String key)
key
- the key (part) to be checked
public static String constructAttributeKey(String key)
key
- the key to be decorated
public static String attributeName(String key)
key
- the attribute key
public String toString()
public ConfigurationKey.KeyIterator iterator()
public int length()
public void setLength(int len)
append()
methods. The semantic is the same as
the setLength()
method of StringBuffer
.
len
- the new length of the keypublic boolean equals(Object c)
ConfigurationKey
objects are equal. The
method can be called with strings or other objects, too.
c
- the object to compare
public int hashCode()
public ConfigurationKey commonKey(ConfigurationKey other)
other
- the other key
public ConfigurationKey differenceKey(ConfigurationKey other)
other = key.commonKey(other) + key.differenceKey(other)
for an arbitrary configuration key key
.
other
- the key for which the difference is to be calculated
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |