public class ConfigurationKey extends Object implements Serializable
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.
Modifier and Type | Class and Description |
---|---|
class |
ConfigurationKey.KeyIterator
A specialized iterator class for tokenizing a configuration key.
|
Modifier and Type | Field and Description |
---|---|
static String |
ESCAPED_DELIMITER
Constant for an escaped delimiter.
|
static char |
PROPERTY_DELIMITER
Constant for a property delimiter.
|
Constructor and Description |
---|
ConfigurationKey()
Creates a new, empty instance of
ConfigurationKey . |
ConfigurationKey(String key)
Creates a new instance of
ConfigurationKey and
initializes it with the given key. |
Modifier and Type | Method and Description |
---|---|
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.
|
public static final char PROPERTY_DELIMITER
public static final String ESCAPED_DELIMITER
public ConfigurationKey()
ConfigurationKey
.public ConfigurationKey(String key)
ConfigurationKey
and
initializes it with the given key.key
- the key as a stringpublic ConfigurationKey append(String property)
property
- the name of the property to be addedpublic ConfigurationKey appendIndex(int index)
index
- the index to be appendedpublic ConfigurationKey appendAttribute(String attr)
attr
- the name of the attribute to be appendedpublic boolean isAttributeKey()
public static boolean isAttributeKey(String key)
key
- the key (part) to be checkedpublic static String constructAttributeKey(String key)
key
- the key to be decoratedpublic static String attributeName(String key)
key
- the attribute keypublic 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.public int hashCode()
public ConfigurationKey commonKey(ConfigurationKey other)
other
- the other keypublic 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 calculatedCopyright © 2012 JBoss by Red Hat. All Rights Reserved.