Class LogicBlock
- java.lang.Object
-
- edu.uiuc.ncsa.security.util.functor.LogicBlock
-
- All Implemented Interfaces:
JMetaMetaFunctor
,JSONFunctor
,Serializable
public class LogicBlock extends Object implements JSONFunctor
This class contains aJFunctor
if-then-else block. You supply a JSONObject, this parses it into its correct elements at runtime. You may also use this as a utility to create such blocks by creating the if then else blcks, setting them and invoking thetoJSON()
method.Created by Jeff Gaynor
on 2/27/18 at 4:33 PM- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LogicBlock(JFunctorFactory factory)
LogicBlock(JFunctorFactory factory, jIf ifBlock, jThen thenBlock)
Constructor for case of no else clause.LogicBlock(JFunctorFactory factory, jIf ifBlock, jThen thenBlock, jElse elseBlock)
LogicBlock(JFunctorFactory factory, net.sf.json.JSONObject json)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addResults(Object obj)
void
clearState()
This clears every executed functor in the antecedent and any consequents.protected jIf
createIfBlock()
A jIf functor is a functor with the agreement that the argument in text may consists of a functor (rather than an array with a single functor).protected JFunctor
createThenOrElseBlock(FunctorTypeImpl type)
Object
execute()
jThen
getConsequent()
The consequent is either the then or else block, depending on the antecedent (the if block).jElse
getElseBlock()
jIf
getIfBlock()
Object
getResult()
ArrayList<Object>
getResults()
jThen
getThenBlock()
boolean
hasConsequent()
protected void
initialize()
boolean
isExecuted()
boolean
isIfTrue()
void
setElseBlock(jElse elseBlock)
void
setIfBlock(jIf ifBlock)
void
setThenBlock(jThen thenBlock)
net.sf.json.JSONObject
toJSON()
String
toString()
-
-
-
Constructor Detail
-
LogicBlock
public LogicBlock(JFunctorFactory factory)
-
LogicBlock
public LogicBlock(JFunctorFactory factory, jIf ifBlock, jThen thenBlock, jElse elseBlock)
-
LogicBlock
public LogicBlock(JFunctorFactory factory, jIf ifBlock, jThen thenBlock)
Constructor for case of no else clause.- Parameters:
ifBlock
-thenBlock
-
-
LogicBlock
public LogicBlock(JFunctorFactory factory, net.sf.json.JSONObject json)
-
-
Method Detail
-
getResult
public Object getResult()
- Specified by:
getResult
in interfaceJMetaMetaFunctor
-
getConsequent
public jThen getConsequent()
The consequent is either the then or else block, depending on the antecedent (the if block). If this has not executed, then null is returned. Also, if there no else and the if clause is false, it will be empty- Returns:
-
hasConsequent
public boolean hasConsequent()
-
getElseBlock
public jElse getElseBlock()
-
getThenBlock
public jThen getThenBlock()
-
getIfBlock
public jIf getIfBlock()
-
createIfBlock
protected jIf createIfBlock()
A jIf functor is a functor with the agreement that the argument in text may consists of a functor (rather than an array with a single functor). This method will enclose the argument in an array if need be.- Returns:
-
isIfTrue
public boolean isIfTrue()
-
createThenOrElseBlock
protected JFunctor createThenOrElseBlock(FunctorTypeImpl type)
-
isExecuted
public boolean isExecuted()
-
clearState
public void clearState()
This clears every executed functor in the antecedent and any consequents.
-
initialize
protected void initialize()
-
addResults
protected void addResults(Object obj)
-
execute
public Object execute()
- Specified by:
execute
in interfaceJMetaMetaFunctor
-
setIfBlock
public void setIfBlock(jIf ifBlock)
-
setThenBlock
public void setThenBlock(jThen thenBlock)
-
setElseBlock
public void setElseBlock(jElse elseBlock)
-
toJSON
public net.sf.json.JSONObject toJSON()
- Specified by:
toJSON
in interfaceJSONFunctor
-
-