Package org.oddjob.jobs
Class CheckJob
java.lang.Object
org.oddjob.jobs.CheckJob
- All Implemented Interfaces:
Serializable,Runnable,ArooaSessionAware
- Author:
- rob
- See Also:
Description
Checks a value for certain criteria. This job is analogous to the Unix 'test' command.This Job will COMPLETE if all checks pass. It will be INCOMPLETE if any fail.
The conditional values are converted into the type of the value before the checks are made. Thus in the example below if the row count property is an integer, the 1000 is converted into an integer for the comparison.
If the value property is not provided the job will be INCOMPLETE unless the null property is set to true.
Example
Example text comparisons. All these checks COMPLETE.
<oddjob>
<job>
<sequential>
<jobs>
<check value="apple" eq="apple"/>
<check value="apple" ne="orange"/>
<check value="apple" lt="orange"/>
<check value="apple" le="apple"/>
<check value="orange" gt="apple"/>
<check value="orange" ge="orange"/>
<check value="anything" null="false"/>
<check value="${missing}" null="true"/>
<check value="pear" z="false"/>
<check value="" z="true"/>
</jobs>
</sequential>
</job>
</oddjob>
Checks that are INCOMPLETE.
<oddjob>
<job>
<!-- needed to force predictable state transitions for the unit test,
so Oddjob goes to INCOMPLETE not ACTIVE first. -->
<state:join xmlns:state="http://rgordon.co.uk/oddjob/state">
<job>
<parallel id="all-checks">
<jobs>
<check value="apple" eq="orange"/>
<check value="apple" ne="apple"/>
<check value="orange" lt="apple"/>
<check value="orange" le="apple"/>
<check value="apple" gt="orange"/>
<check value="apple" ge="orange"/>
<check value="anything" null="true"/>
<check value="${missing}" null="false"/>
</jobs>
</parallel>
</job>
</state:join>
</job>
</oddjob>
Numeric checks. Note that the value must be the numeric value. The
operand attributes values are converted to the type of the value before
the comparison. If the value was "999" and the lt was "${sequence.current}"
this check would not be COMPLETE because the text "999" is greater than
"1000".
<oddjob>
<job>
<sequential>
<jobs>
<sequence id="sequence" from="1000"/>
<check value="${sequence.current}" eq="1000"/>
<check value="${sequence.current}" ne="999"/>
<check value="${sequence.current}" lt="1001"/>
<check value="${sequence.current}" le="1000"/>
<check value="${sequence.current}" gt="999"/>
<check value="${sequence.current}" ge="1000"/>
</jobs>
</sequential>
</job>
</oddjob>
Check a Property Exists. The second check will be INCOMPLETE because the
property doesn't exist.
<oddjob>
<job>
<sequential>
<jobs>
<properties>
<values>
<value key="property.that.exists" value="some-value"/>
</values>
</properties>
<check name="Check Something that Exists" value="${property.that.exists}" id="should-complete"/>
<check name="Check Something that doesn't Exist" value="${property.doesnt.exist}" id="should-incomplete"/>
</jobs>
</sequential>
</job>
</oddjob>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetEq()getGe()getGt()getLe()getLt()getName()getNe()booleangetNull()intgetValue()getZ()voidrun()voidsetArooaSession(ArooaSession session) Accept the current Arooa Session.voidsetEq(ArooaValue eq) voidsetGe(ArooaValue ge) voidsetGt(ArooaValue gt) voidsetLe(ArooaValue le) voidsetLt(ArooaValue lt) voidvoidsetNe(ArooaValue ne) voidsetNull(boolean value) voidvoidtoString()
-
Constructor Details
-
CheckJob
public CheckJob()
-
-
Method Details
-
run
public void run() -
setArooaSession
Description copied from interface:ArooaSessionAwareAccept the current Arooa Session.- Specified by:
setArooaSessionin interfaceArooaSessionAware- Parameters:
session- The Arooa Session. Never null.
-
getName
-
setName
-
getNull
public boolean getNull() -
setNull
public void setNull(boolean value) -
getZ
-
setZ
-
getValue
-
setValue
-
getEq
-
setEq
-
getNe
-
setNe
-
getLt
-
setLt
-
getGt
-
setGt
-
getLe
-
setLe
-
getGe
-
setGe
-
getResult
public int getResult() -
toString
-