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`, `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 enum`
  `BitwiseOperatorTable.BitwiseOperators`
  Keys to identify the bitwise operators.

  ## 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, String powerSymbol, String xorSymbol)`
  A decorator constructor.
  ``
  `BitwiseOperatorTable(String powerSymbol, String xorSymbol)`
  Standard constructor.
  `protected`
  `BitwiseOperatorTable(Map<EmptyOperatorTable.OperatorKey,Operator> map)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addBitOperators(String powerSymbol, 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, getAllOperatorsByName, getKey, getKeys, getLightWeightInstance, getNumOps, getOperator, getOperatorByName, getOperatorMap, getOperators, getOperatorsByName, getOperatorsBySymbol, init, insertOperator, insertOperator, keySet, removeOperator, removeOperator, replaceOperator, replaceOperator, setBinaryInverseOp, setDistributiveOver, setGroupOperatorRelations, setGroupOperatorRelations, setInverseOp, setPrecedenceTable, setRootOp, setStandardOperatorRelations, threadSafeMapCopy, toString`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### BitwiseOperatorTable

    public BitwiseOperatorTable(String powerSymbol, String xorSymbol)
    Standard constructor.
    Parameters:
      `powerSymbol` - string used to represent power.
      `xorSymbol` - string used to represent xor.

  - ### BitwiseOperatorTable

    public BitwiseOperatorTable(OperatorTable2 oldTable, String powerSymbol, String xorSymbol)
    A decorator constructor. Takes all the operators supplied 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(Map<EmptyOperatorTable.OperatorKey,Operator> map)

- ## Method Details

  - ### setBasicPfmcs

    protected void setBasicPfmcs()
    A do nothing implementation.
    Overrides:
      `setBasicPfmcs` in class `StandardOperatorTable2`
    See Also:
      - `OperatorTable2.BasicOperators`

  - ### setSpecialPfmcs

    protected void setSpecialPfmcs()
    A do nothing implementation.
    Overrides:
      `setSpecialPfmcs` in class `StandardOperatorTable2`
    See Also:
      - `OperatorTable2.SpecialOperators`

  - ### setPsudoPfmcs

    protected void setPsudoPfmcs()
    A do nothing implementation.
    Overrides:
      `setPsudoPfmcs` in class `StandardOperatorTable2`

  - ### addBitOperators

    protected void addBitOperators(String powerSymbol, 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 the `EmptyOperatorTable.threadSafeMapCopy()` method to return a copy of the map of operators and a constructor taking this map which uses the `EmptyOperatorTable(Map)` constructor.
    Specified by:
      `shallowCopy` in interface `OperatorTableI`
    Overrides:
      `shallowCopy` in class `StandardOperatorTable2`
    Returns:
      a new Table