|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.data.Token
ptolemy.data.ScalarToken
ptolemy.data.BooleanToken
public class BooleanToken
A token that contains a boolean variable. Arithmetic on booleans is that of a two-element Galois field (modulo two arithmetic). Thus, add() is logical xor, multiply() is logical and, zero() is false, one() is true.
In order to reduce the number of instances of this object that are created, it is highly recommended that the getInstance() method be used, instead of the constructor that takes a boolean argument.
Red (cxh) |
Yellow (cxh) nil token |
Field Summary | |
---|---|
private boolean |
_value
|
static BooleanToken |
FALSE
False-valued token. |
static BooleanToken |
NIL
A token that represents a missing value. |
static BooleanToken |
TRUE
True-valued token. |
Fields inherited from class ptolemy.data.ScalarToken |
---|
_unitCategoryExponents |
Constructor Summary | |
---|---|
BooleanToken()
Construct a token with value false. |
|
BooleanToken(boolean b)
Construct a token with the specified value. |
|
BooleanToken(java.lang.String init)
Construct a token with the specified string. |
Method Summary | |
---|---|
protected ScalarToken |
_absolute()
Return this token. |
protected ScalarToken |
_add(ScalarToken rightArgument)
Return a new token whose value is the value of the argument Token added to the value of this Token. |
protected ScalarToken |
_bitwiseAnd(ScalarToken rightArgument)
Returns a token representing the bitwise AND of this token and the given token. |
protected ScalarToken |
_bitwiseNot()
Returns a token representing the bitwise NOT of this token. |
protected ScalarToken |
_bitwiseOr(ScalarToken rightArgument)
Returns a token representing the bitwise OR of this token and the given token. |
protected ScalarToken |
_bitwiseXor(ScalarToken rightArgument)
Returns a token representing the bitwise XOR of this token and the given token. |
protected ScalarToken |
_divide(ScalarToken rightArgument)
Return a new token whose value is the value of this token divided by the value of this Token. |
protected BooleanToken |
_isCloseTo(ScalarToken token,
double epsilon)
Return a true-valued token if the first argument is close to this token, where in this class, "close" means "identical to." |
protected BooleanToken |
_isEqualTo(ScalarToken token)
Test for equality of the values of this token and the argument. |
protected BooleanToken |
_isLessThan(ScalarToken rightArgument)
Throw an exception. |
protected ScalarToken |
_modulo(ScalarToken rightArgument)
Throw an exception. |
protected ScalarToken |
_multiply(ScalarToken rightArgument)
Return a new token whose value is the value of this token multiplied by the value of the argument token. |
protected ScalarToken |
_subtract(ScalarToken rightArgument)
Subtraction is not supported in Boolean algebras. |
BooleanToken |
and(BooleanToken rightArgument)
Return a new token whose value is the logical AND of the value of this token and the the value of the argument token. |
boolean |
booleanValue()
Return the value as a boolean. |
static BooleanToken |
convert(Token token)
Convert the specified token into an instance of BooleanToken. |
boolean |
equals(java.lang.Object object)
Return true if the argument's class is BooleanToken and it has the same values as this token. |
static BooleanToken |
getInstance(boolean value)
Return the instance of this class corresponding to the given boolean value. |
Type |
getType()
Return the type of this token. |
int |
hashCode()
Return a hash code value for this token. |
boolean |
isNil()
Return true if the token is nil, (aka null or missing). |
BooleanToken |
not()
Return a new BooleanToken with the logical not of the value stored in this token. |
Token |
one()
Returns a token representing the multiplicative identity. |
BooleanToken |
or(BooleanToken rightArgument)
Return a new token whose value is the logical OR of the value of this token and the the value of the argument token. |
java.lang.String |
toString()
Return the value of this token as a string that can be parsed by the expression language to recover a token with the same value. |
BooleanToken |
xor(BooleanToken rightArgument)
Return a new token whose value is the logical XOR of the value of this token and the the value of the argument token. |
Token |
zero()
Returns a token representing the additive identity. |
Methods inherited from class ptolemy.data.ScalarToken |
---|
_addCategoryExponents, _areUnitsEqual, _copyOfCategoryExponents, _isUnitless, _subtractCategoryExponents, absolute, add, addReverse, bitwiseAnd, bitwiseNot, bitwiseOr, bitwiseXor, byteValue, complexValue, divide, divideReverse, doubleValue, fixValue, floatValue, intValue, inUnitsOf, isCloseTo, isEqualTo, isGreaterThan, isLessThan, leftShift, logicalRightShift, longValue, modulo, moduloReverse, multiply, multiplyReverse, rightShift, setUnitCategory, shortValue, subtract, subtractReverse, unitsString |
Methods inherited from class ptolemy.data.Token |
---|
isCloseTo, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, pow, zeroReturnType |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final BooleanToken TRUE
public static final BooleanToken NIL
public static final BooleanToken FALSE
private boolean _value
Constructor Detail |
---|
public BooleanToken()
public BooleanToken(boolean b)
b
- The boolean value.public BooleanToken(java.lang.String init) throws IllegalActionException
init
- The initialization string.
IllegalActionException
- If the token could not
be created with the given String.Method Detail |
---|
public BooleanToken and(BooleanToken rightArgument)
NIL
is returned.
rightArgument
- The BooleanToken to OR with this one.
public boolean booleanValue()
public static BooleanToken convert(Token token) throws IllegalActionException
NIL
is
returned.
token
- The token to be converted to a BooleanToken.
IllegalActionException
- If the argument is not
a BooleanToken.public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- An instance of Object.
public static BooleanToken getInstance(boolean value)
value
- The given value.
public Type getType()
getType
in class ScalarToken
public int hashCode()
hashCode
in class java.lang.Object
public boolean isNil()
isNil
in class Token
NIL
token.public BooleanToken not()
public Token one()
one
in class Token
public BooleanToken or(BooleanToken rightArgument)
NIL
is returned.
rightArgument
- The BooleanToken to OR with this one.
public java.lang.String toString()
toString
in class Token
public BooleanToken xor(BooleanToken rightArgument)
NIL
is returned.
rightArgument
- The BooleanToken to XOR with this one.
public Token zero()
zero
in class Token
protected ScalarToken _absolute()
_absolute
in class ScalarToken
protected ScalarToken _add(ScalarToken rightArgument)
_add
in class ScalarToken
rightArgument
- The token to add to this token.
protected ScalarToken _bitwiseAnd(ScalarToken rightArgument) throws IllegalActionException
_bitwiseAnd
in class ScalarToken
rightArgument
- The DoubleToken to bitwise AND with this one.
IllegalActionException
- Always thrown by this base class.protected ScalarToken _bitwiseNot() throws IllegalActionException
_bitwiseNot
in class ScalarToken
IllegalActionException
- Always thrown by this base class.protected ScalarToken _bitwiseOr(ScalarToken rightArgument) throws IllegalActionException
_bitwiseOr
in class ScalarToken
rightArgument
- The DoubleToken to bitwise OR with this one.
IllegalActionException
- Always thrown by this base class.protected ScalarToken _bitwiseXor(ScalarToken rightArgument) throws IllegalActionException
_bitwiseXor
in class ScalarToken
rightArgument
- The DoubleToken to bitwise XOR with this one.
IllegalActionException
- Always thrown by this base class.protected ScalarToken _divide(ScalarToken rightArgument) throws IllegalActionException
_divide
in class ScalarToken
rightArgument
- The token to divide this token by
IllegalActionException
- If the argument token is
FALSE.protected BooleanToken _isCloseTo(ScalarToken token, double epsilon)
_isCloseTo
in class ScalarToken
token
- The token to compare to this token.epsilon
- Ignored in this method.
protected BooleanToken _isEqualTo(ScalarToken token)
_isEqualTo
in class ScalarToken
token
- The token to compare to this token.
protected BooleanToken _isLessThan(ScalarToken rightArgument) throws IllegalActionException
_isLessThan
in class ScalarToken
rightArgument
- The token to compare to this token.
IllegalActionException
- Always.protected ScalarToken _modulo(ScalarToken rightArgument) throws IllegalActionException
_modulo
in class ScalarToken
rightArgument
- The token to modulo this token by.
IllegalActionException
- Always.protected ScalarToken _multiply(ScalarToken rightArgument) throws IllegalActionException
_multiply
in class ScalarToken
rightArgument
- The token to multiply this token by.
IllegalActionException
- If ANDing the argument
and the token throws it.protected ScalarToken _subtract(ScalarToken rightArgument) throws IllegalActionException
_subtract
in class ScalarToken
rightArgument
- The token to subtract from this token.
IllegalActionException
- If this method is not
supported by the derived class.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |