Package com.ezylang.evalex.config
Class MapBasedOperatorDictionary
- java.lang.Object
-
- com.ezylang.evalex.config.MapBasedOperatorDictionary
-
- All Implemented Interfaces:
OperatorDictionaryIfc
public class MapBasedOperatorDictionary extends java.lang.Object implements OperatorDictionaryIfc
A default case-insensitive implementation of the operator dictionary that uses a localMap.Entry<String,OperatorIfc>for storage.
-
-
Constructor Summary
Constructors Constructor Description MapBasedOperatorDictionary()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOperator(java.lang.String operatorString, OperatorIfc operator)Allows to add an operator to the dictionary.OperatorIfcgetInfixOperator(java.lang.String operatorString)Get the operator definition for an infix operator name.OperatorIfcgetPostfixOperator(java.lang.String operatorString)Get the operator definition for a postfix operator name.OperatorIfcgetPrefixOperator(java.lang.String operatorString)Get the operator definition for a prefix operator name.static OperatorDictionaryIfcofOperators(java.util.Map.Entry<java.lang.String,OperatorIfc>... operators)Creates a new operator dictionary with the specified list of operators.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.ezylang.evalex.config.OperatorDictionaryIfc
hasInfixOperator, hasPostfixOperator, hasPrefixOperator
-
-
-
-
Method Detail
-
ofOperators
public static OperatorDictionaryIfc ofOperators(java.util.Map.Entry<java.lang.String,OperatorIfc>... operators)
Creates a new operator dictionary with the specified list of operators.- Parameters:
operators- variable number of arguments that specify the operator names and definitions that will initially be added.- Returns:
- A newly created operator dictionary with the specified operators.
-
addOperator
public void addOperator(java.lang.String operatorString, OperatorIfc operator)Description copied from interface:OperatorDictionaryIfcAllows to add an operator to the dictionary. Implementation is optional, if you have a fixed set of operators, this method can throw an exception.- Specified by:
addOperatorin interfaceOperatorDictionaryIfc- Parameters:
operatorString- The operator name.operator- The operator implementation.
-
getPrefixOperator
public OperatorIfc getPrefixOperator(java.lang.String operatorString)
Description copied from interface:OperatorDictionaryIfcGet the operator definition for a prefix operator name.- Specified by:
getPrefixOperatorin interfaceOperatorDictionaryIfc- Parameters:
operatorString- The name of the operator.- Returns:
- The operator definition or
nullif no operator was found.
-
getPostfixOperator
public OperatorIfc getPostfixOperator(java.lang.String operatorString)
Description copied from interface:OperatorDictionaryIfcGet the operator definition for a postfix operator name.- Specified by:
getPostfixOperatorin interfaceOperatorDictionaryIfc- Parameters:
operatorString- The name of the operator.- Returns:
- The operator definition or
nullif no operator was found.
-
getInfixOperator
public OperatorIfc getInfixOperator(java.lang.String operatorString)
Description copied from interface:OperatorDictionaryIfcGet the operator definition for an infix operator name.- Specified by:
getInfixOperatorin interfaceOperatorDictionaryIfc- Parameters:
operatorString- The name of the operator.- Returns:
- The operator definition or
nullif no operator was found.
-
-