net.groboclown.xml.xdstates.v1.modules
Class AbstractVSelect

java.lang.Object
  |
  +--net.groboclown.xml.xdstates.v1.modules.AbstractVSelect
All Implemented Interfaces:
IPermuteValueModule, IValueModule
Direct Known Subclasses:
VSelectEach

public abstract class AbstractVSelect
extends Object
implements IPermuteValueModule

A generic value module that selects a subset of items from the underlying collection. The subclasses must getIndex(), setIndex(), and setHasMore() in its selection method.

Version:
Alpha 0.9.0 - JDK 1.2+
Author:
Matt Albrecht

Field Summary
private  boolean hasMore
           
private  int position
           
private static String[] values
           
 
Constructor Summary
AbstractVSelect(String[] values)
           
 
Method Summary
 boolean checkValue(String value)
           
 IValueModule copy()
           
protected abstract  AbstractVSelect copyAbstractVSelect()
           
 IDataList fire(String value, IDataList orig)
          Fire the module.
protected  int getIndex()
          Returns the current index value.
 boolean hasAnotherState()
           
protected abstract  void select(IItem[] in, ArrayList out)
          Load the given out list with the selected items from the in list, using the current getIndex().
protected  void setHasMore(boolean hasMore)
          Sets the return value of the hasAnotherState() method.
protected  void setIndex(int index)
          Sets the index, which will be returned by each successive getIndex() call.
 boolean shouldFireTreeParse(String value, IDataList list)
          Used to determine the owning IAttributeModule's return value from the method with the same name.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

values

private static String[] values

position

private int position

hasMore

private boolean hasMore
Constructor Detail

AbstractVSelect

public AbstractVSelect(String[] values)
Method Detail

copy

public final IValueModule copy()
Specified by:
copy in interface IValueModule

copyAbstractVSelect

protected abstract AbstractVSelect copyAbstractVSelect()

select

protected abstract void select(IItem[] in,
                               ArrayList out)
Load the given out list with the selected items from the in list, using the current getIndex(). At the end of this method, the implementors must call setIndex() and setHasMore() to their correct state.

If the in item list is empty, then this method will not be called.


setHasMore

protected final void setHasMore(boolean hasMore)
Sets the return value of the hasAnotherState() method. The default value is false. If this is ever called with a false argument, then the position will be reset to 0.

getIndex

protected final int getIndex()
Returns the current index value. The default value is 0, and will be reset to 0 when setHasMore() is called with a false argument.

setIndex

protected final void setIndex(int index)
Sets the index, which will be returned by each successive getIndex() call.

hasAnotherState

public boolean hasAnotherState()
Specified by:
hasAnotherState in interface IPermuteValueModule
See Also:
IAttributeModule.hasAnotherState()

checkValue

public boolean checkValue(String value)
Specified by:
checkValue in interface IValueModule
Returns:
true if the given value is OK for firing in this module.

shouldFireTreeParse

public boolean shouldFireTreeParse(String value,
                                   IDataList list)
Used to determine the owning IAttributeModule's return value from the method with the same name.

Determines if the tree at the node in the list should be fired. At the point this is called, the list contains no IItems. If any attribute returns false, then the tree and its sub-nodes are not fired. However, if all the attributes return true from this method, then the tree and its sub-nodes are fired.

This is useful for performing conditional branching on a tree to prevent the sub-nodes for executing any actions which may be undesired (such as property adjustments).

Specified by:
shouldFireTreeParse in interface IValueModule

fire

public IDataList fire(String value,
                      IDataList orig)
Fire the module.
Specified by:
fire in interface IValueModule
Returns:
the new list of data, or null if there is no change.


Written under the LGPL