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 aJFunctorif-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 voidaddResults(Object obj)voidclearState()This clears every executed functor in the antecedent and any consequents.protected jIfcreateIfBlock()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 JFunctorcreateThenOrElseBlock(FunctorTypeImpl type)Objectexecute()jThengetConsequent()The consequent is either the then or else block, depending on the antecedent (the if block).jElsegetElseBlock()jIfgetIfBlock()ObjectgetResult()ArrayList<Object>getResults()jThengetThenBlock()booleanhasConsequent()protected voidinitialize()booleanisExecuted()booleanisIfTrue()voidsetElseBlock(jElse elseBlock)voidsetIfBlock(jIf ifBlock)voidsetThenBlock(jThen thenBlock)net.sf.json.JSONObjecttoJSON()StringtoString() 
 - 
 
- 
- 
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:
 getResultin 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:
 executein 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:
 toJSONin interfaceJSONFunctor
 
 - 
 
 -