|
|||||||||
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.AbstractConvertibleToken
public abstract class AbstractConvertibleToken
The Token base class provides a very general interface for building new data types. However, in many ways, the interface is rather complex in order to allow consistent implementation of Token operations that operate on tokens that are defined in different classes. In particular, this requires the duplicate operation and operationReverse methods.
This base class is intended to make it easy to implement tokens that perform operations on other data types. In most (but not all) cases, these operations to be performed only on types that can be losslessly converted to this type (or vice versa). The operations are implemented to first perform the conversion to the same type, and then to perform the operation. This class provides a base class implementation of the operation methods which performs the appropriate conversion, and then defers to a protected _operation method if the type of the argument of the operation is less than or equal to this type. If the argument type is greater than this type, then the appropriate method is called on that type. If the types are incomparable, then this class throws an exception. The protected methods should be overridden in derived classes to provide type-specific operations.
Red |
Yellow (neuendor) |
Field Summary |
---|
Fields inherited from class ptolemy.data.Token |
---|
NIL |
Constructor Summary | |
---|---|
AbstractConvertibleToken()
|
Method Summary | |
---|---|
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 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. |
protected abstract 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. |
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. |
Methods inherited from class ptolemy.data.Token |
---|
getType, isCloseTo, isNil, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, pow, toString, zero, zeroReturnType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractConvertibleToken()
Method Detail |
---|
public final 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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, or the operation
does not make sense for the given types.public final 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 of incomparable types, or the operation does
not make sense for the given types.public final BooleanToken isCloseTo(Token token, double epsilon) throws IllegalActionException
Subclasses should not generally override this method, but override the protected _isCloseTo() method to ensure that type conversion is performed consistently.
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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, or the operation
does not make sense for the given types.public final 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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, or the operation does
not make sense for the given types.public final 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 of incomparable types, 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 token, double epsilon) throws IllegalActionException
token
- 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 a derived class.protected abstract BooleanToken _isEqualTo(Token token) throws IllegalActionException
token
- The token with which to test equality.
IllegalActionException
- If this method is not
supported by a derived 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |