org.apache.commons.configuration.tree
public class DefaultConfigurationKey extends Object
A simple class that supports creation of and iteration on configuration keys
supported by a DefaultExpressionEngine
object.
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.
Instances of this class are always associated with an instance of
DefaultExpressionEngine
, from which the current
delimiters are obtained. So key creation and parsing is specific to this
associated expression engine.
Since: 1.3
Version: $Id: DefaultConfigurationKey.java 439648 2006-09-02 20:42:10Z oheger $
Nested Class Summary | |
---|---|
class | DefaultConfigurationKey.KeyIterator
A specialized iterator class for tokenizing a configuration key. |
Field Summary | |
---|---|
DefaultExpressionEngine | expressionEngine Stores a reference to the associated expression engine. |
static int | INITIAL_SIZE Constant for the initial StringBuffer size. |
StringBuffer | keyBuffer Holds a buffer with the so far created key. |
Constructor Summary | |
---|---|
DefaultConfigurationKey(DefaultExpressionEngine engine)
Creates a new instance of DefaultConfigurationKey and sets
the associated expression engine.
| |
DefaultConfigurationKey(DefaultExpressionEngine engine, String key)
Creates a new instance of DefaultConfigurationKey and sets
the associated expression engine and an initial key.
|
Method Summary | |
---|---|
DefaultConfigurationKey | append(String property, boolean escape)
Appends the name of a property to this key. |
DefaultConfigurationKey | append(String property)
Appends the name of a property to this key. |
DefaultConfigurationKey | appendAttribute(String attr)
Appends an attribute to this configuration key.
|
DefaultConfigurationKey | appendIndex(int index)
Appends an index to this configuration key.
|
String | attributeName(String key)
Extracts the name of the attribute from the given attribute key. |
String | constructAttributeKey(String key)
Decorates the given key so that it represents an attribute. |
boolean | equals(Object c)
Checks if two ConfigurationKey objects are equal. |
String | escapeDelimiters(String key)
Escapes the delimiters in the specified string.
|
DefaultExpressionEngine | getExpressionEngine()
Returns the associated default expression engine.
|
int | hashCode()
Returns the hash code for this object.
|
boolean | hasLeadingDelimiter(String key)
Helper method that checks if the specified key starts with a property
delimiter.
|
boolean | hasTrailingDelimiter(String key)
Helper method that checks if the specified key ends with a property
delimiter.
|
boolean | isAttributeKey(String key)
Tests if the specified key represents an attribute according to the
current expression engine.
|
DefaultConfigurationKey.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.
|
String | removeAttributeMarkers(String key)
Helper method for removing attribute markers from a key.
|
void | setExpressionEngine(DefaultExpressionEngine expressionEngine)
Sets the associated expression engine.
|
void | setLength(int len)
Sets the new length of this configuration key. |
String | toString()
Returns a string representation of this object. |
String | trim(String key)
Removes delimiters at the beginning and the end of the specified key.
|
String | trimLeft(String key)
Removes leading property delimiters from the specified key.
|
String | trimRight(String key)
Removes trailing property delimiters from the specified key.
|
String | unescapeDelimiters(String key)
Unescapes the delimiters in the specified string.
|
DefaultConfigurationKey
and sets
the associated expression engine.
Parameters: engine the expression engine
DefaultConfigurationKey
and sets
the associated expression engine and an initial key.
Parameters: engine the expression engine key the key to be wrapped
Parameters: property the name of the property to be added escape a flag if property delimiters in the passed in property name should be escaped
Returns: a reference to this object
Parameters: property the name of the property to be added
Returns: a reference to this object
Parameters: attr the name of the attribute to be appended
Returns: a reference to this object
Parameters: index the index to be appended
Returns: a reference to this object
Parameters: key the attribute key
Returns: the name of the corresponding attribute
Parameters: key the key to be decorated
Returns: the decorated attribute key
ConfigurationKey
objects are equal. The
method can be called with strings or other objects, too.
Parameters: c the object to compare
Returns: a flag if both objects are equal
Parameters: key the key to be escaped
Returns: the escaped key
Returns: the associated expression engine
Returns: the hash code
Parameters: key the key to check
Returns: a flag if there is a leading delimiter
Parameters: key the key to check
Returns: a flag if there is a trailing delimiter
Parameters: key the key to be checked
Returns: true if this is an attribute key, false otherwise
Returns: an iterator for this key
Returns: the length of this key
Parameters: key the key
Returns: the key with removed attribute markers
Parameters: expressionEngine the expression engine (must not be null)
append()
methods. The semantic is the same as the
setLength()
method of StringBuffer
.
Parameters: len the new length of the key
Returns: a string for this object
Parameters: key the key
Returns: the key with removed property delimiters
Parameters: key the key
Returns: the key with removed leading property delimiters
Parameters: key the key
Returns: the key with removed trailing property delimiters
Parameters: key the key to be unescaped
Returns: the unescaped key