net.sf.sapjcosupport
Class ReflectionFieldIterator

java.lang.Object
  extended bynet.sf.sapjcosupport.ReflectionFieldIterator
All Implemented Interfaces:
Iterator

public class ReflectionFieldIterator
extends Object
implements Iterator

Iterator implementation that iterates through the fields declared in a class, and retrieves the values for an instance.

This implementation does not support item removal, and will throw a NotImplementedException when the remove() method is called.

Since:
4 Jun, 2006 - 10:12:07 PM
Author:
Jo Vandermeeren

Nested Class Summary
 class ReflectionFieldIterator.IllegalAccessRuntimeException
          RuntimeException wrapper for IllegalAccessException.
 class ReflectionFieldIterator.RuntimeWrapperException
          Wraps any Throwable instance in a RuntimeException.
 
Constructor Summary
ReflectionFieldIterator(Object instance)
          Simple constructor.
ReflectionFieldIterator(Object instance, String regularExpression)
          Advanced constructor.
 
Method Summary
 boolean hasNext()
          Checks if more fields are available to iterate through.
 Object next()
          Retrieves the next available field value.
 void remove()
          Deprecated. Do not use this method, it is not implemented and throws a runtime exception
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectionFieldIterator

public ReflectionFieldIterator(Object instance)
Simple constructor.

Parameters:
instance - instance to operate on
See Also:
ReflectionFieldIterator(Object, String)

ReflectionFieldIterator

public ReflectionFieldIterator(Object instance,
                               String regularExpression)
Advanced constructor.

This constructor accepts a regular expression by which the field names are evaluated.
Only fields with matching names will be considered; if the regularExpression parameter is null or does not compile to a pattern, all fields will be considered.

If the instance passed to this constructor is null, no exception will be thrown, but the hasNext() method will return false.

Parameters:
instance - instance to operate on
regularExpression - regular expression pattern to match field names
Method Detail

hasNext

public boolean hasNext()
Checks if more fields are available to iterate through.

Specified by:
hasNext in interface Iterator
Returns:
true if more fields are available

next

public Object next()
Retrieves the next available field value.

Specified by:
next in interface Iterator
Returns:
next object in sequence
Throws:
NoSuchElementException - if no more objects are available

remove

public void remove()
Deprecated. Do not use this method, it is not implemented and throws a runtime exception

Specified by:
remove in interface Iterator


Copyright © 2006 null. All Rights Reserved.