Class SwitchHandler
- java.lang.Object
-
- edu.uiuc.ncsa.security.util.functor.parser.AbstractHandler
-
- edu.uiuc.ncsa.security.util.functor.parser.event.SwitchHandler
-
- All Implemented Interfaces:
CommaListener
,DelimiterListener
,Serializable
,EventListener
public class SwitchHandler extends AbstractHandler implements DelimiterListener, CommaListener
Event-Driven Logic BlockS handler. This is the outermost part of any parsing operation. LogicBlocks are basicallt just a type of switch statement that allows for some awareness of how to evaluate the components (standard switch is to evaluate exactly one, out xor case). This has a few specialized calls to let you get results from running logic blocks.Created by Jeff Gaynor
on 7/16/18 at 2:34 PM- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class edu.uiuc.ncsa.security.util.functor.parser.AbstractHandler
closeDelimiterCount, CONDITIONAL_TYPE, FUNCTOR_TYPE, openDelimiterCount, SWITCH_TYPE, used
-
-
Constructor Summary
Constructors Constructor Description SwitchHandler(ConditionalHandler conditionalHandler, JFunctorFactory functorFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeDelimiter(DelimiterEvent delimeterEvent)
void
execute()
jThen
getConsequentAt(int index)
Get the logic block at theindex
and return the consequent (i.e.List<JFunctor>
getFunctorMapEntry(String key)
int
getHandlerType()
Allows for determining the type of handler without resorting to a lot of java class operations.LogicBlocks<? extends LogicBlock>
getLogicBlocks()
Object
getResultAt(int consequentIndex, int resultIndex)
Fetches the consequent atconsequentIndex
then grabs the list atresultIndex
(since consequents have lists of results) and returns the object.void
gotComma(CommaEvent commaEvent)
boolean
hasConsequentAt(int index)
void
openDelimiter(DelimiterEvent delimeterEvent)
void
reset()
void
runLogicBlocks()
-
Methods inherited from class edu.uiuc.ncsa.security.util.functor.parser.AbstractHandler
areDelimitersBalanced, convertType, equals, getFunctorFactory, isUsed, toString
-
-
-
-
Constructor Detail
-
SwitchHandler
public SwitchHandler(ConditionalHandler conditionalHandler, JFunctorFactory functorFactory)
-
-
Method Detail
-
runLogicBlocks
public void runLogicBlocks()
-
getHandlerType
public int getHandlerType()
Description copied from class:AbstractHandler
Allows for determining the type of handler without resorting to a lot of java class operations.- Specified by:
getHandlerType
in classAbstractHandler
- Returns:
-
getConsequentAt
public jThen getConsequentAt(int index)
Get the logic block at theindex
and return the consequent (i.e. result of having executed the logic block.)- Parameters:
index
-- Returns:
-
getResultAt
public Object getResultAt(int consequentIndex, int resultIndex)
Fetches the consequent atconsequentIndex
then grabs the list atresultIndex
(since consequents have lists of results) and returns the object.- Parameters:
consequentIndex
-resultIndex
-- Returns:
-
hasConsequentAt
public boolean hasConsequentAt(int index)
-
getLogicBlocks
public LogicBlocks<? extends LogicBlock> getLogicBlocks()
-
execute
public void execute()
-
gotComma
public void gotComma(CommaEvent commaEvent)
- Specified by:
gotComma
in interfaceCommaListener
-
openDelimiter
public void openDelimiter(DelimiterEvent delimeterEvent)
- Specified by:
openDelimiter
in interfaceDelimiterListener
- Overrides:
openDelimiter
in classAbstractHandler
-
closeDelimiter
public void closeDelimiter(DelimiterEvent delimeterEvent)
- Specified by:
closeDelimiter
in interfaceDelimiterListener
- Overrides:
closeDelimiter
in classAbstractHandler
-
reset
public void reset()
- Specified by:
reset
in interfaceDelimiterListener
- Overrides:
reset
in classAbstractHandler
-
-