public abstract class AbstractNotConvertibleToken extends Token
This base class is intended to make it easy to implement tokens where operations are only defined for other tokens that are defined in the same class. In these cases, the operation() and operationReverse() method can share the same code. This class implements these methods to ensure that the argument of each operation is actually an instance of the correct class. The implementation then defers to a protected _operation() method. These protected methods should be overridden in derived classes to provide type-specific operations.
This class is used a base class for ArrayToken and RecordToken. Note that these classes actually represent tokens having different types in the type lattice.
Green (cxh) |
Green (neuendor) |
Constructor and Description |
---|
AbstractNotConvertibleToken() |
Modifier and Type | Method and Description |
---|---|
protected abstract Token |
_add(Token rightArgument)
Return a new token whose value is the value of the argument
token added to the value of this token.
|
protected abstract Token |
_divide(Token rightArgument)
Return a new token whose value is the value of this token
divided by the value of the argument token.
|
protected abstract BooleanToken |
_isCloseTo(Token rightArgument,
double epsilon)
Test that the value of this Token is close to the first argument,
where "close" means that the distance between them is less than
or equal to the second argument.
|
protected BooleanToken |
_isEqualTo(Token token)
Test for equality of the values of this token and the argument.
|
protected abstract Token |
_modulo(Token rightArgument)
Return a new token whose value is the value of this token
modulo the value of the argument token.
|
protected abstract Token |
_multiply(Token rightArgument)
Return a new token whose value is the value of this token
multiplied by the value of the argument token.
|
protected abstract Token |
_subtract(Token rightArgument)
Return a new token whose value is the value of the argument
token subtracted from the value of this token.
|
Token |
add(Token rightArgument)
Return a new token whose value is the sum of this token and
the argument.
|
Token |
addReverse(Token leftArgument)
Return a new token whose value is the sum of this token and
the argument.
|
Token |
divide(Token rightArgument)
Return a new token whose value is the value of this token
divided by the value of the argument token.
|
Token |
divideReverse(Token leftArgument)
Return a new token whose value is the value of the argument
token divided by the value of this token.
|
BooleanToken |
isCloseTo(Token token,
double epsilon)
Test that the value of this token is close to the first argument,
where "close" means that the distance between them is less than
or equal to the second argument.
|
BooleanToken |
isEqualTo(Token rightArgument)
Test for equality of the values of this token and the argument
token.
|
Token |
modulo(Token rightArgument)
Return a new token whose value is the value of this token
modulo the value of the argument token.
|
Token |
moduloReverse(Token leftArgument)
Return a new token whose value is the value of the argument token
modulo the value of this token.
|
Token |
multiply(Token rightArgument)
Return a new token whose value is the value of this token
multiplied by the value of the argument token.
|
Token |
multiplyReverse(Token leftArgument)
Return a new token whose value is the value of the argument token
multiplied by the value of this token.
|
static java.lang.String |
notSupportedDifferentClassesMessage(java.lang.String operation,
Token firstToken,
Token secondToken)
Return a string with an error message that states that the
given operation is not supported between two tokens, because
they have incomparable types and cannot be converted to the
same type.
|
Token |
subtract(Token rightArgument)
Return a new token whose value is the value of the argument token
subtracted from the value of this token.
|
Token |
subtractReverse(Token leftArgument)
Return a new token whose value is the value of this token
subtracted from the value of the argument token.
|
getType, isCloseTo, isNil, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, pow, toString, zero, zeroReturnType
public Token add(Token rightArgument) throws IllegalActionException
add
in class Token
rightArgument
- The token to add to this token.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public Token addReverse(Token leftArgument) throws IllegalActionException
addReverse
in class Token
leftArgument
- The token to add this token to.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public Token divide(Token rightArgument) throws IllegalActionException
divide
in class Token
rightArgument
- The token to divide into this token.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public Token divideReverse(Token leftArgument) throws IllegalActionException
divideReverse
in class Token
leftArgument
- The token to be divided by the value of
this token.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public BooleanToken isCloseTo(Token token, double epsilon) throws IllegalActionException
isCloseTo
in class Token
token
- The token to test closeness of this token with.epsilon
- The value that we use to determine whether two
tokens are close.IllegalActionException
- If the argument token and
this token are implemented in different classes.public BooleanToken isEqualTo(Token rightArgument) throws IllegalActionException
isEqualTo
in class Token
rightArgument
- The token with which to test equality.IllegalActionException
- If the argument token and
this token are implemented in different classes.public Token modulo(Token rightArgument) throws IllegalActionException
modulo
in class Token
rightArgument
- The token to divide into this token.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public Token moduloReverse(Token leftArgument) throws IllegalActionException
moduloReverse
in class Token
leftArgument
- The token to apply modulo to by the value
of this token.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public Token multiply(Token rightArgument) throws IllegalActionException
multiply
in class Token
rightArgument
- The token to multiply this token by.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public Token multiplyReverse(Token leftArgument) throws IllegalActionException
multiplyReverse
in class Token
leftArgument
- The token to be multiplied by the value of
this token.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public static java.lang.String notSupportedDifferentClassesMessage(java.lang.String operation, Token firstToken, Token secondToken)
operation
- A string naming the unsupported token
operation.firstToken
- The first token in the message.secondToken
- The second token in the message.public Token subtract(Token rightArgument) throws IllegalActionException
subtract
in class Token
rightArgument
- The token to subtract from this token.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.public Token subtractReverse(Token leftArgument) throws IllegalActionException
subtractReverse
in class Token
leftArgument
- The token to subtract this token from.IllegalActionException
- If the argument token and
this token are implemented in different classes, or the
operation does not make sense for the given types.protected abstract Token _add(Token rightArgument) throws IllegalActionException
rightArgument
- The token whose value we add to the value
of this token.IllegalActionException
- If this method is not
supported by the derived class.protected abstract Token _divide(Token rightArgument) throws IllegalActionException
rightArgument
- The token to divide this token by.IllegalActionException
- If this method is not
supported by the derived class.protected abstract BooleanToken _isCloseTo(Token rightArgument, double epsilon) throws IllegalActionException
rightArgument
- The token with which to test closeness.epsilon
- The value that we use to determine whether two
tokens are close.IllegalActionException
- If this method is not
supported by the derived class.protected BooleanToken _isEqualTo(Token token) throws IllegalActionException
token
- The token to compare to this token.IllegalActionException
- Not thrown in this base class.protected abstract Token _modulo(Token rightArgument) throws IllegalActionException
rightArgument
- The token to modulo this token by.IllegalActionException
- If this method is not
supported by the derived class.protected abstract Token _multiply(Token rightArgument) throws IllegalActionException
rightArgument
- The token to multiply this token by.IllegalActionException
- If this method is not
supported by the derived class.protected abstract Token _subtract(Token rightArgument) throws IllegalActionException
rightArgument
- The token to subtract from this token.IllegalActionException
- If this method is not
supported by the derived class.