Package org.apache.commons.configuration
Class ConfigurationKey
java.lang.Object
org.apache.commons.configuration.ConfigurationKey
- All Implemented Interfaces:
Serializable
Deprecated.
A simple class that supports creation of and iteration on complex configuration keys.
For key creation the class works similar to a StringBuilder: 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.
- Version:
- $Id: ConfigurationKey.java 1231749 2012-01-15 20:48:56Z oheger $
- Author:
- Commons Configuration team
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
Deprecated.A specialized iterator class for tokenizing a configuration key. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Deprecated.Constant for an escaped delimiter.static final char
Deprecated.Constant for a property delimiter. -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Creates a new, empty instance ofConfigurationKey
.ConfigurationKey
(String key) Deprecated.Creates a new instance ofConfigurationKey
and initializes it with the given key. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Appends the name of a property to this key.appendAttribute
(String attr) Deprecated.Appends an attribute to this configuration key.appendIndex
(int index) Deprecated.Appends an index to this configuration key.static String
attributeName
(String key) Deprecated.Extracts the name of the attribute from the given attribute key.commonKey
(ConfigurationKey other) Deprecated.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
Deprecated.Decorates the given key so that it represents an attribute.differenceKey
(ConfigurationKey other) Deprecated.Returns the "difference key" to a given key.boolean
Deprecated.Checks if twoConfigurationKey
objects are equal.int
hashCode()
Deprecated.Returns the hash code for this object.boolean
Deprecated.Checks if this key is an attribute key.static boolean
isAttributeKey
(String key) Deprecated.Checks if the passed in key is an attribute key.iterator()
Deprecated.Returns an iterator for iterating over the single components of this configuration key.int
length()
Deprecated.Returns the actual length of this configuration key.void
setLength
(int len) Deprecated.Sets the new length of this configuration key.toString()
Deprecated.Returns a string representation of this object.
-
Field Details
-
PROPERTY_DELIMITER
Deprecated.Constant for a property delimiter.- See Also:
-
ESCAPED_DELIMITER
Deprecated.Constant for an escaped delimiter.
-
-
Constructor Details
-
ConfigurationKey
public ConfigurationKey()Deprecated.Creates a new, empty instance ofConfigurationKey
. -
ConfigurationKey
Deprecated.Creates a new instance ofConfigurationKey
and initializes it with the given key.- Parameters:
key
- the key as a string
-
-
Method Details
-
append
Deprecated.Appends the name of a property to this key. If necessary, a property delimiter will be added.- Parameters:
property
- the name of the property to be added- Returns:
- a reference to this object
-
appendIndex
Deprecated.Appends an index to this configuration key.- Parameters:
index
- the index to be appended- Returns:
- a reference to this object
-
appendAttribute
Deprecated.Appends an attribute to this configuration key.- Parameters:
attr
- the name of the attribute to be appended- Returns:
- a reference to this object
-
isAttributeKey
Deprecated.Checks if this key is an attribute key.- Returns:
- a flag if this key is an attribute key
-
isAttributeKey
Deprecated.Checks if the passed in key is an attribute key. Such attribute keys start and end with certain marker strings. In some cases they must be treated slightly different.- Parameters:
key
- the key (part) to be checked- Returns:
- a flag if this key is an attribute key
-
constructAttributeKey
Deprecated.Decorates the given key so that it represents an attribute. Adds special start and end markers.- Parameters:
key
- the key to be decorated- Returns:
- the decorated attribute key
-
attributeName
Deprecated.Extracts the name of the attribute from the given attribute key. This method removes the attribute markers - if any - from the specified key.- Parameters:
key
- the attribute key- Returns:
- the name of the corresponding attribute
-
toString
Deprecated.Returns a string representation of this object. This is the configuration key as a plain string. -
iterator
Deprecated.Returns an iterator for iterating over the single components of this configuration key.- Returns:
- an iterator for this key
-
length
Deprecated.Returns the actual length of this configuration key.- Returns:
- the length of this key
-
setLength
Deprecated.Sets the new length of this configuration key. With this method it is possible to truncate the key, e.g. to return to a state prior calling someappend()
methods. The semantic is the same as thesetLength()
method ofStringBuilder
.- Parameters:
len
- the new length of the key
-
equals
Deprecated.Checks if twoConfigurationKey
objects are equal. The method can be called with strings or other objects, too. -
hashCode
Deprecated.Returns the hash code for this object. -
commonKey
Deprecated.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.- Parameters:
other
- the other key- Returns:
- a key object with the common key part
-
differenceKey
Deprecated.Returns the "difference key" to a given key. This value is the part of the passed in key that differs from this key. There is the following relation:other = key.commonKey(other) + key.differenceKey(other)
for an arbitrary configuration keykey
.- Parameters:
other
- the key for which the difference is to be calculated- Returns:
- the difference key
-
DefaultConfigurationKey
instead. It is associated with aDefaultExpressionEngine
and thus can produce correct keys even if key separators have been changed.