org.apache.commons.configuration
Class ConfigurationKey.KeyIterator

java.lang.Object
  extended by org.apache.commons.configuration.ConfigurationKey.KeyIterator
All Implemented Interfaces:
java.lang.Cloneable, java.util.Iterator
Enclosing class:
ConfigurationKey

public class ConfigurationKey.KeyIterator
extends java.lang.Object
implements java.util.Iterator, 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.


Field Summary
private  boolean attribute
          Stores a flag if the actual property is an attribute.
private  java.lang.String current
          Stores the current key name.
private  int endIndex
          Stores the end index of the actual token.
private  boolean hasIndex
          Stores a flag if the actual property has an index.
private  int indexValue
          Stores the index of the actual property if there is one.
private  int startIndex
          Stores the start index of the actual token.
 
Constructor Summary
ConfigurationKey.KeyIterator()
           
 
Method Summary
private  boolean checkAttribute(java.lang.String key)
          Helper method for checking if the passed key is an attribute.
private  boolean checkIndex(java.lang.String key)
          Helper method for checking if the passed key contains an index.
 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).
private  java.lang.String findNextIndices()
          Helper method for determining the next indices.
 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.
 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.
private  java.lang.String nextKeyPart()
          Helper method for extracting the next key part.
 void remove()
          Removes the current object in the iteration.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

private java.lang.String current
Stores the current key name.


startIndex

private int startIndex
Stores the start index of the actual token.


endIndex

private int endIndex
Stores the end index of the actual token.


indexValue

private int indexValue
Stores the index of the actual property if there is one.


hasIndex

private boolean hasIndex
Stores a flag if the actual property has an index.


attribute

private boolean attribute
Stores a flag if the actual property is an attribute.

Constructor Detail

ConfigurationKey.KeyIterator

public ConfigurationKey.KeyIterator()
Method Detail

findNextIndices

private java.lang.String findNextIndices()
Helper method for determining the next indices.

Returns:
the next key part

nextKeyPart

private java.lang.String nextKeyPart()
Helper method for extracting the next key part. Takes escaping of delimiter characters into account.

Returns:
the next key part

nextKey

public java.lang.String nextKey()
Returns the next key part of this configuration key. This is a short form of nextKey(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

checkAttribute

private boolean checkAttribute(java.lang.String key)
Helper method for checking if the passed key is an attribute. If this is the case, the internal fields will be set.

Parameters:
key - the key to be checked
Returns:
a flag if the key is an attribute

checkIndex

private boolean checkIndex(java.lang.String key)
Helper method for checking if the passed key contains an index. If this is the case, internal fields will be set.

Parameters:
key - the key to be checked
Returns:
a flag if an index is defined

hasNext

public boolean hasNext()
Checks if there is a next element.

Specified by:
hasNext in interface java.util.Iterator
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 interface java.util.Iterator
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 interface java.util.Iterator

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 previous next() call had returned. (Short form of currentKey(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 after next().

Returns:
a flag if the current key is an attribute

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 after next().

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 after next().

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 class java.lang.Object
Returns:
a clone of this object