Class DefaultConfigurationKey.KeyIterator
- java.lang.Object
-
- org.apache.commons.configuration.tree.DefaultConfigurationKey.KeyIterator
-
- All Implemented Interfaces:
java.lang.Cloneable
,java.util.Iterator<java.lang.Object>
- Enclosing class:
- DefaultConfigurationKey
public class DefaultConfigurationKey.KeyIterator extends java.lang.Object implements java.util.Iterator<java.lang.Object>, java.lang.Cloneable
A specialized iterator class for tokenizing a configuration key. This class implements the normal iterator interface. In addition it provides some specific methods for configuration keys.
-
-
Constructor Summary
Constructors Constructor Description KeyIterator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
clone()
Creates a clone of this object.java.lang.String
currentKey()
Returns the current key of the iteration (without skipping to the next element).java.lang.String
currentKey(boolean decorated)
Returns the current key of the iteration (without skipping to the next element).int
getIndex()
Returns the index value of the current key.boolean
hasIndex()
Returns a flag if the current key has an associated index.boolean
hasNext()
Checks if there is a next element.boolean
isAttribute()
Returns a flag if the current key is an attribute.boolean
isPropertyKey()
Returns a flag whether the current key refers to a property (i.e.java.lang.Object
next()
Returns the next object in the iteration.java.lang.String
nextKey()
Returns the next key part of this configuration key.java.lang.String
nextKey(boolean decorated)
Returns the next key part of this configuration key.void
remove()
Removes the current object in the iteration.
-
-
-
Method Detail
-
nextKey
public java.lang.String nextKey()
Returns the next key part of this configuration key. This is a short form ofnextKey(false)
.- Returns:
- the next key part
-
nextKey
public java.lang.String nextKey(boolean decorated)
Returns the next key part of this configuration key. The boolean parameter indicates wheter a decorated key should be returned. This affects only attribute keys: if the parameter is false, the attribute markers are stripped from the key; if it is true, they remain.- Parameters:
decorated
- a flag if the decorated key is to be returned- Returns:
- the next key part
-
hasNext
public boolean hasNext()
Checks if there is a next element.- Specified by:
hasNext
in interfacejava.util.Iterator<java.lang.Object>
- Returns:
- a flag if there is a next element
-
next
public java.lang.Object next()
Returns the next object in the iteration.- Specified by:
next
in interfacejava.util.Iterator<java.lang.Object>
- Returns:
- the next object
-
remove
public void remove()
Removes the current object in the iteration. This method is not supported by this iterator type, so an exception is thrown.- Specified by:
remove
in interfacejava.util.Iterator<java.lang.Object>
-
currentKey
public java.lang.String currentKey()
Returns the current key of the iteration (without skipping to the next element). This is the same key the previousnext()
call had returned. (Short form ofcurrentKey(false)
.- Returns:
- the current key
-
currentKey
public java.lang.String currentKey(boolean decorated)
Returns the current key of the iteration (without skipping to the next element). The boolean parameter indicates wheter a decorated key should be returned. This affects only attribute keys: if the parameter is false, the attribute markers are stripped from the key; if it is true, they remain.- Parameters:
decorated
- a flag if the decorated key is to be returned- Returns:
- the current key
-
isAttribute
public boolean isAttribute()
Returns a flag if the current key is an attribute. This method can be called afternext()
.- Returns:
- a flag if the current key is an attribute
-
isPropertyKey
public boolean isPropertyKey()
Returns a flag whether the current key refers to a property (i.e. is no special attribute key). Usually this method will return the opposite ofisAttribute()
, but if the delimiters for normal properties and attributes are set to the same string, it is possible that both methods return true.- Returns:
- a flag if the current key is a property key
- See Also:
isAttribute()
-
getIndex
public int getIndex()
Returns the index value of the current key. If the current key does not have an index, return value is -1. This method can be called afternext()
.- Returns:
- the index value of the current key
-
hasIndex
public boolean hasIndex()
Returns a flag if the current key has an associated index. This method can be called afternext()
.- Returns:
- a flag if the current key has an index
-
clone
public java.lang.Object clone()
Creates a clone of this object.- Overrides:
clone
in classjava.lang.Object
- Returns:
- a clone of this object
-
-