org.formaria.data.pojo
Class PojoIterator

java.lang.Object
  extended by org.formaria.aria.data.DataModel
      extended by org.formaria.data.pojo.PojoModel
          extended by org.formaria.data.pojo.PojoIterator
All Implemented Interfaces:
Iterator

public class PojoIterator
extends PojoModel
implements Iterator

A set of methods to help with POJOs.

Copyright (c) Formaria Ltd., 2008
License: see license.txt


Field Summary
protected  int curIdx
           
protected  PojoModel[] elements
           
 
Fields inherited from class org.formaria.data.pojo.PojoModel
adapter, collectionElements, dataSource, dirty, elIdx, getterArgTypes, getterArgValues, pojo, properties, propertyKey, propertyName
 
Fields inherited from class org.formaria.aria.data.DataModel
parentModel, tagName
 
Constructor Summary
PojoIterator(DataModel parent, PojoDataSource ds)
          Creates a new instance of PojoIterator.
 
Method Summary
 java.lang.Object current()
          Returns the model node wrapping the current element in the iteration
 java.lang.Object first()
          Returns the model node wrapping the first object from the iterated collection and resets the iteration index to 0
 java.lang.Object get(java.lang.String element)
          Get the value of the element located at the path in the element parameter.
 java.lang.String getId()
          Gets the values of the ID attribute
 boolean hasNext()
          Indicates whether the iterator has more elements
 boolean hasPrevious()
          Indicates whether this iterator has more elements while traversing the iterated collection in the reverse direction
 java.lang.Object last()
          Returns the model node wrapping the last element of the iterated collection
 java.lang.Object next()
          Gets the model node wrapping the next element in the iterated collection
 java.lang.Object previous()
          Returns the model node wrapping the previous element in the iteration.
 void sync()
          Syncs this node with the collection stored in the parent node
 
Methods inherited from class org.formaria.data.pojo.PojoModel
append, append, clear, get, get, getAttribName, getAttribute, getAttribValue, getAttribValueAsDouble, getAttribValueAsDouble, getAttribValueAsInt, getAttribValueAsString, getCollectionElements, getDataSource, getElIdx, getGetterArgTypes, getGetterArgValues, getNumAttributes, getNumChildren, getPojo, getPropertyKey, getPropertyName, getPropertyValue, getValueAsDouble, getValueAsInt, getValueAsString, hasAutoId, hashCode, hasSetter, isAlwaysDirty, isCollection, isDirty, isTransient, isTransient, markSubtreeAsAlwaysDirty, markSubtreeAsDirty, retrieveModelNode, saveModelNode, set, set, setAlwaysDirty, setAttribValue, setAttribValue, setDirty, setId, setNumChildren, setPojo, setPropertyValue
 
Methods inherited from class org.formaria.aria.data.DataModel
addModelListener, fireModelUpdated, getParent, getTagName, hasAutoId, prefixOutputPath, removeChildren, reset, resetAttributes, setNumAttributes, setParent, setTagName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

elements

protected PojoModel[] elements

curIdx

protected int curIdx
Constructor Detail

PojoIterator

public PojoIterator(DataModel parent,
                    PojoDataSource ds)
Creates a new instance of PojoIterator.

Parameters:
parent - the parent model node wich pojo is expected to be a collection
ds - the data source object
Method Detail

get

public java.lang.Object get(java.lang.String element)
Description copied from class: PojoModel
Get the value of the element located at the path in the element parameter. The element name parameter can include an attribute name by appending '@attributeName' to the path, where attributeName is the name of the attribute.

Overrides:
get in class PojoModel
Parameters:
element - The path to the DataModel required
Returns:
The value of the DataModel or the attribute

sync

public void sync()
Syncs this node with the collection stored in the parent node

Overrides:
sync in class PojoModel

current

public java.lang.Object current()
Returns the model node wrapping the current element in the iteration

Specified by:
current in interface Iterator
Returns:
current element

hasNext

public boolean hasNext()
Indicates whether the iterator has more elements

Specified by:
hasNext in interface Iterator
Returns:
true if the iterator has more elements, false otherwise.

next

public java.lang.Object next()
Gets the model node wrapping the next element in the iterated collection

Specified by:
next in interface Iterator
Returns:
the next element in the iteration if there is one or the current element if there is no more elements in the iteration.

first

public java.lang.Object first()
Returns the model node wrapping the first object from the iterated collection and resets the iteration index to 0

Specified by:
first in interface Iterator
Returns:
first element of the iteration

last

public java.lang.Object last()
Returns the model node wrapping the last element of the iterated collection

Specified by:
last in interface Iterator
Returns:
iteration last element

hasPrevious

public boolean hasPrevious()
Indicates whether this iterator has more elements while traversing the iterated collection in the reverse direction

Specified by:
hasPrevious in interface Iterator
Returns:
true if the iterator has more elements, false otherwise

previous

public java.lang.Object previous()
Returns the model node wrapping the previous element in the iteration.

Specified by:
previous in interface Iterator
Returns:
previous element

getId

public java.lang.String getId()
Gets the values of the ID attribute

Overrides:
getId in class PojoModel
Returns:
the ID attribute