com.codemesh.terp.eval.converters
Class ToIterator
java.lang.Object
com.codemesh.terp.eval.converters.ToIterator
- All Implemented Interfaces:
- Converter<java.util.Iterator>
public class ToIterator
- extends java.lang.Object
- implements Converter<java.util.Iterator>
A converter that attempts to create an Iterator from the source object.
This converter is an important part of the ${foreach()} element.
Essentially, any type that can be converted to an iterator via this
converter can be enumerated by the ${foreach()} element. Any type
that cannot be converted will result in the ${foreach()} command
being applied to the source element itself.
The returned iterator objects usually don't support the Iterator.remove()
operation. Attempts to call it yield an IllegalStateException or an
UnsupportedOperationException.
|
Method Summary |
java.util.Iterator |
fromObject(java.lang.Object obj,
TerpContext ctx)
Converts the given object into an object of the target type. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ToIterator
public ToIterator()
fromObject
public java.util.Iterator fromObject(java.lang.Object obj,
TerpContext ctx)
- Converts the given object into an object of the target type.
Conversions can be implemented in any way that makes sense.
Normally, converters will return null for null, but some converters
may choose to interpret null as an indicator to return a
default-initialized target object. An example of this type
of conversion is the ShellExecutor. null simply indicates that
no preference overrides of any kind have been provided.
- Specified by:
fromObject in interface Converter<java.util.Iterator>
- Parameters:
obj - the source object.ctx - the context in which the conversion takes place.
- Returns:
- an instance of the target type or null.
Copyright © 2008-2012 by Codemesh, Inc. All Rights Reserved.