Package com.singularsys.jep.misc.bitwise
Class BitwiseOperatorTable
- java.lang.Object
-
- com.singularsys.jep.EmptyOperatorTable
-
- com.singularsys.jep.OperatorTable2
-
- com.singularsys.jep.standard.StandardOperatorTable2
-
- com.singularsys.jep.misc.bitwise.BitwiseOperatorTable
-
- All Implemented Interfaces:
JepComponent
,OperatorTableI
,java.io.Serializable
- Direct Known Subclasses:
JavaOperatorTable
public class BitwiseOperatorTable extends StandardOperatorTable2
An operator table with a selection of bitwise operators.
- And: a & b
- Or: a | b
- Complement: ~a
- Xor: a ^ b
- Left shift: a >> b
- Right shift: a << b
- Right shift with zero extension: a <<< b
The BitwiseOperatorTable can be used as a drop in replacement for the StandardOperatorTable.
jep.setComponent(new BitwiseOperatorTable("**","^"));
Note the standard symbol used for power ^ conflicts with java's symbol used for xor, the constructor for the BitwiseOperatorTable takes two strings specifying the symbols used for power and xor respectively.
- Author:
- Richard Morris
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BitwiseOperatorTable.BitwiseOperators
-
Nested classes/interfaces inherited from class com.singularsys.jep.OperatorTable2
OperatorTable2.BasicOperators, OperatorTable2.PsudoOperators, OperatorTable2.SpecialOperators
-
Nested classes/interfaces inherited from class com.singularsys.jep.EmptyOperatorTable
EmptyOperatorTable.OperatorKey
-
-
Constructor Summary
Constructors Modifier Constructor Description BitwiseOperatorTable(OperatorTable2 oldTable, java.lang.String powerSymbol, java.lang.String xorSymbol)
A decerator constructor.BitwiseOperatorTable(java.lang.String powerSymbol, java.lang.String xorSymbol)
Standard constructor.protected
BitwiseOperatorTable(java.util.Map<EmptyOperatorTable.OperatorKey,Operator> map)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addBitOperators(java.lang.String powerSymbol, java.lang.String xorSymbol)
Operator
getBitAnd()
Operator
getBitComp()
Operator
getBitOr()
Operator
getBitXor()
Operator
getLShift()
Operator
getRShift()
Operator
getURShift()
protected void
setBasicPfmcs()
A do nothing implementation.protected void
setBitPfmcs()
protected void
setPsudoPfmcs()
A do nothing implementation.protected void
setSpecialPfmcs()
A do nothing implementation.OperatorTableI
shallowCopy()
Create a new version of this OperatorTable.-
Methods inherited from class com.singularsys.jep.OperatorTable2
getAdd, getAnd, getAssign, getCross, getDivide, getDot, getEle, getEQ, getGE, getGT, getLE, getList, getLT, getMod, getMultiply, getNE, getNop, getNot, getOr, getPower, getRange, getSubtract, getUDivide, getUMinus, getUPlus
-
Methods inherited from class com.singularsys.jep.EmptyOperatorTable
addOperator, addOperator, addOperator, appendOperator, appendOperator, entrySet, getKey, getLightWeightInstance, getNumOps, getOperator, getOperatorMap, getOperators, getOperatorsByName, getOperatorsBySymbol, init, insertOperator, insertOperator, keySet, removeOperator, removeOperator, replaceOperator, replaceOperator, setBinaryInverseOp, setDistributiveOver, setGroupOperatorRelations, setGroupOperatorRelations, setInverseOp, setPrecedenceTable, setRootOp, setStandardOperatorRelations, threadSafeMapCopy, toString
-
-
-
-
Constructor Detail
-
BitwiseOperatorTable
public BitwiseOperatorTable(java.lang.String powerSymbol, java.lang.String xorSymbol)
Standard constructor.- Parameters:
powerSymbol
- string used to represent power.xorSymbol
- string used to represent xor.
-
BitwiseOperatorTable
public BitwiseOperatorTable(OperatorTable2 oldTable, java.lang.String powerSymbol, java.lang.String xorSymbol)
A decerator constructor. Takes all the operators suplied in the oldTable and add extra bitwise operations.- Parameters:
oldTable
- table with most operators.powerSymbol
- string used to represent power.xorSymbol
- string used to represent xor.
-
BitwiseOperatorTable
protected BitwiseOperatorTable(java.util.Map<EmptyOperatorTable.OperatorKey,Operator> map)
-
-
Method Detail
-
setBasicPfmcs
protected void setBasicPfmcs()
A do nothing implementation.- Overrides:
setBasicPfmcs
in classStandardOperatorTable2
- See Also:
OperatorTable2.BasicOperators
-
setSpecialPfmcs
protected void setSpecialPfmcs()
A do nothing implementation.- Overrides:
setSpecialPfmcs
in classStandardOperatorTable2
- See Also:
OperatorTable2.SpecialOperators
-
setPsudoPfmcs
protected void setPsudoPfmcs()
A do nothing implementation.- Overrides:
setPsudoPfmcs
in classStandardOperatorTable2
-
addBitOperators
protected void addBitOperators(java.lang.String powerSymbol, java.lang.String xorSymbol)
-
setBitPfmcs
protected void setBitPfmcs()
-
getBitAnd
public Operator getBitAnd()
-
getBitOr
public Operator getBitOr()
-
getBitXor
public Operator getBitXor()
-
getBitComp
public Operator getBitComp()
-
getLShift
public Operator getLShift()
-
getRShift
public Operator getRShift()
-
getURShift
public Operator getURShift()
-
shallowCopy
public OperatorTableI shallowCopy()
Description copied from class:EmptyOperatorTable
Create a new version of this OperatorTable. Operators are copied into new table. However Operators whose pfmc implement JepComponent are duplicated. This means the table could be used in a separate thread without problem. Subclasses should override with method to return a table of the correct type, a typical implementation would be@Override public OperatorTableI shallowCopy() { Map<OperatorKey, Operator> map = this.threadSafeMapCopy(); return new MyOperatorTable(map); }
using theEmptyOperatorTable.threadSafeMapCopy()
method to return a copy of the map of operators and a constructor taking this map which uses theEmptyOperatorTable(Map)
constructor.- Specified by:
shallowCopy
in interfaceOperatorTableI
- Overrides:
shallowCopy
in classStandardOperatorTable2
- Returns:
- a new Table
-
-