org.springframework.rules.closure.support
Class AbstractElementGenerator

Show UML class diagram
java.lang.Object
  extended by org.springframework.rules.closure.support.AbstractElementGenerator
All Implemented Interfaces:
ClosureTemplate, ElementGenerator
Direct Known Subclasses:
AbstractElementGeneratorWorkflow

public abstract class AbstractElementGenerator
extends Object
implements ElementGenerator

Base superclass for process templates.

Author:
Keith Donald

Constructor Summary
protected AbstractElementGenerator()
          Default constructor.
protected AbstractElementGenerator(boolean runOnce)
          Constructor.
 
Method Summary
 boolean allTrue(Constraint constraint)
          Does this process produce all elements matching the given criteria?
 boolean anyTrue(Constraint constraint)
          Does this process produce an element matching the given criteria?
 ElementGenerator findAll(Constraint constraint)
          Find all elements produced by ths template that match the specified criteria.
 Object findFirst(Constraint constraint)
          Find the first element that matches the given criteria.
 Object findFirst(Constraint constraint, Object defaultIfNoneFound)
          Find the first element that matches the given criteria, return defaultIfNoneFound if none found.
protected  ElementGenerator getWrappedTemplate()
           
 boolean isFinished()
           
 boolean isRunning()
           
 boolean isStopped()
           
protected  void reset()
          Reset the ElementGenerator if possible.
abstract  void run(Closure templateCallback)
          Execute the template with the specific closure callback for the insertion of custom processing code.
 void runUntil(Closure templateCallback, Constraint constraint)
          Run a block of code (Closure) until a specific test (Constraint) is passed.
protected  void setCompleted()
          Set status completed.
protected  void setRunning()
          Set status running.
 void stop()
          Stop the generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractElementGenerator

protected AbstractElementGenerator()
Default constructor.


AbstractElementGenerator

protected AbstractElementGenerator(boolean runOnce)
Constructor.

Parameters:
runOnce - true if this ElementGenerator may only be run once (will throw an Exception if called more than once).
Method Detail

getWrappedTemplate

protected ElementGenerator getWrappedTemplate()
Returns:
the wrapped ElementGenerator or null.

allTrue

public boolean allTrue(Constraint constraint)
Does this process produce all elements matching the given criteria?

Specified by:
allTrue in interface ElementGenerator
Parameters:
constraint - the criteria
Returns:
true if yes, false otherwise

anyTrue

public boolean anyTrue(Constraint constraint)
Does this process produce an element matching the given criteria?

Specified by:
anyTrue in interface ElementGenerator
Parameters:
constraint - the criteria
Returns:
true if yes, false otherwise

findAll

public ElementGenerator findAll(Constraint constraint)
Find all elements produced by ths template that match the specified criteria.

Specified by:
findAll in interface ElementGenerator
Parameters:
constraint - the criteria
Returns:
the elements

findFirst

public Object findFirst(Constraint constraint)
Find the first element that matches the given criteria.

Specified by:
findFirst in interface ElementGenerator
Parameters:
constraint - the criteria
Returns:
the first element, or null if none found.

findFirst

public Object findFirst(Constraint constraint,
                        Object defaultIfNoneFound)
Find the first element that matches the given criteria, return defaultIfNoneFound if none found.

Specified by:
findFirst in interface ElementGenerator
Parameters:
constraint - the constraint
defaultIfNoneFound - none found object
Returns:
the first match, or defaultIfNoneFound if no match found

isStopped

public boolean isStopped()
Returns:
true if the generator is stopped.

isFinished

public boolean isFinished()
Returns:
true if the generator has completed it's task.

isRunning

public boolean isRunning()
Returns:
true if the generator is still running.

stop

public void stop()
          throws IllegalStateException
Stop the generator.

Specified by:
stop in interface ElementGenerator
Throws:
IllegalStateException

runUntil

public void runUntil(Closure templateCallback,
                     Constraint constraint)
Run a block of code (Closure) until a specific test (Constraint) is passed.

Specified by:
runUntil in interface ElementGenerator
Parameters:
templateCallback - the callback
constraint - the constraint condition

reset

protected void reset()
Reset the ElementGenerator if possible.

Throws:
UnsupportedOperationException - if this ElementGenerator was a runOnce instance.

setRunning

protected void setRunning()
Set status running.


setCompleted

protected void setCompleted()
Set status completed.


run

public abstract void run(Closure templateCallback)
Execute the template with the specific closure callback for the insertion of custom processing code.

Specified by:
run in interface ClosureTemplate
Parameters:
templateCallback - The procedure callback.


Copyright © 2004-2009 The Spring Framework. All Rights Reserved.