ptolemy.data
Class LongToken

java.lang.Object
  |
  +--ptolemy.data.Token
        |
        +--ptolemy.data.ScalarToken
              |
              +--ptolemy.data.LongToken
All Implemented Interfaces:
java.io.Serializable

public class LongToken
extends ScalarToken

A token that contains an long integer.

Since:
Ptolemy II 0.2
Version:
$Id: LongToken.java,v 1.55 2002/02/21 18:03:51 cxh Exp $
Author:
Neil Smyth, Yuhong Xiong
See Also:
Serialized Form

Fields inherited from class ptolemy.data.ScalarToken
_unitCategoryExponents
 
Constructor Summary
LongToken()
          Construct a token with long integer 0.
LongToken(long value)
          Construct a token with the specified value.
LongToken(java.lang.String init)
          Construct a token from the given String.
 
Method Summary
 ScalarToken absolute()
          Return a LongToken containing the absolute value of the value of this token.
 Token add(Token token)
          Return a new token whose value is the sum of this token and the argument.
 Token addReverse(Token token)
          Return a new token whose value is the sum of this token and the argument.
static Token convert(Token token)
          Convert the specified token into an instance of LongToken.
 Token divide(Token divisor)
          Return a new Token whose value is the value of this token divided by the value of the argument token.
 Token divideReverse(Token dividend)
          Return a new Token whose value is the value of the argument token divided by the value of this token.
 boolean equals(java.lang.Object object)
          Return true if the argument is an instance of LongToken with the same value.
 Type getType()
          Return the type of this token.
 int hashCode()
          Return a hash code value for this token.
 BooleanToken isEqualTo(Token token)
          Test the values of this Token and the argument Token for equality.
 BooleanToken isLessThan(ScalarToken arg)
          Check if the value of this token is strictly less than that of the argument token.
 long longValue()
          Return the value in the token as a long.
 Token modulo(Token token)
          Return a new Token whose value is the value of this token modulo the value of the argument token.
 Token moduloReverse(Token token)
          Return a new Token whose value is the value of the argument token modulo the value of this token.
 Token multiply(Token rightFactor)
          Return a new Token whose value is the value of this Token multiplied by the value of the argument Token.
 Token multiplyReverse(Token leftFactor)
          Return a new Token whose value is the value of the argument Token multiplied by the value of this Token.
 Token one()
          Returns a new LongToken with value 1.
 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.
 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.
 Token zero()
          Returns a new LongToken with value 0.
 
Methods inherited from class ptolemy.data.ScalarToken
_addCategoryExponents, _areUnitsEqual, _copyOfCategoryExponents, _isUnitless, _subtractCategoryExponents, complexValue, doubleValue, fixValue, intValue, inUnitsOf, setUnitCategory, unitsString
 
Methods inherited from class ptolemy.data.Token
_notSupportedMessage, isCloseTo, isCloseTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LongToken

public LongToken()
Construct a token with long integer 0.

LongToken

public LongToken(long value)
Construct a token with the specified value.

LongToken

public LongToken(java.lang.String init)
          throws IllegalActionException
Construct a token from the given String.
Throws:
IllegalActionException - If the Token could not be created with the given String.
Method Detail

absolute

public ScalarToken absolute()
Return a LongToken containing the absolute value of the value of this token.
Overrides:
absolute in class ScalarToken
Returns:
A LongToken.

add

public Token add(Token token)
          throws IllegalActionException
Return a new token whose value is the sum of this token and the argument. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
add in class Token
Parameters:
token - The token to add to this Token.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be added to this Tokens value.

addReverse

public Token addReverse(Token token)
                 throws IllegalActionException
Return a new token whose value is the sum of this token and the argument. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
addReverse in class Token
Parameters:
token - The token to add this Token to.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be added to this Tokens value.

convert

public static Token convert(Token token)
                     throws IllegalActionException
Convert the specified token into an instance of LongToken. This method does lossless conversion. If the argument is already an instance of LongToken, it is returned without any change. Otherwise, if the argument is below LongToken in the type hierarchy, it is converted to an instance of LongToken or one of the subclasses of LongToken and returned. If none of the above condition is met, an exception is thrown.
Parameters:
token - The token to be converted to a LongToken.
Returns:
A LongToken.
Throws:
IllegalActionException - If the conversion cannot be carried out.

divide

public Token divide(Token divisor)
             throws IllegalActionException
Return a new Token whose value is the value of this token divided by the value of the argument token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion. If two integers are divided, the result will be an integer which is the quotient.
Overrides:
divide in class Token
Parameters:
divisor - The token to divide this Token by
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be divide this Tokens value by.

divideReverse

public Token divideReverse(Token dividend)
                    throws IllegalActionException
Return a new Token whose value is the value of the argument token divided by the value of this token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
divideReverse in class Token
Parameters:
dividend - The token to be divided by the value of this Token.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be divided by this Tokens value.

equals

public boolean equals(java.lang.Object object)
Return true if the argument is an instance of LongToken with the same value.
Overrides:
equals in class Token
Parameters:
object - An instance of Object.
Returns:
True if the argument is an instance of LongToken with the same value.

getType

public Type getType()
Return the type of this token.
Overrides:
getType in class ScalarToken
Returns:
BaseType.LONG_MATRIX

hashCode

public int hashCode()
Return a hash code value for this token. This method returns the value of this token, casted to integer.
Overrides:
hashCode in class Token
Returns:
A hash code value for this token.

isEqualTo

public BooleanToken isEqualTo(Token token)
                       throws IllegalActionException
Test the values of this Token and the argument Token for equality. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
isEqualTo in class Token
Parameters:
token - The token to test equality of this token with.
Returns:
BooleanToken indicating whether the values are equal.
Throws:
IllegalActionException - If the passed token is not of a type that can be compared with this Tokens value.

isLessThan

public BooleanToken isLessThan(ScalarToken arg)
                        throws IllegalActionException
Check if the value of this token is strictly less than that of the argument token.
Overrides:
isLessThan in class ScalarToken
Parameters:
arg - A ScalarToken.
Returns:
A BooleanToken with value true if this token is strictly less than the argument.
Throws:
IllegalActionException - If the type of the argument token is incomparable with the type of this token.

longValue

public long longValue()
Return the value in the token as a long.
Overrides:
longValue in class ScalarToken
Following copied from class: ptolemy.data.ScalarToken
Returns:
A long
Throws:
IllegalActionException - Always thrown.

modulo

public Token modulo(Token token)
             throws IllegalActionException
Return a new Token whose value is the value of this token modulo the value of the argument token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
modulo in class Token
Parameters:
token - The token to modulo this Token by.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be used with modulo.

moduloReverse

public Token moduloReverse(Token token)
                    throws IllegalActionException
Return a new Token whose value is the value of the argument token modulo the value of this token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
moduloReverse in class Token
Parameters:
token - The token to apply modulo to by the value of this Token.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can apply modulo by this Tokens value.

multiply

public Token multiply(Token rightFactor)
               throws IllegalActionException
Return a new Token whose value is the value of this Token multiplied by the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
multiply in class Token
Parameters:
rightFactor - The token to multiply this Token by.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be multiplied to this Tokens value.

multiplyReverse

public Token multiplyReverse(Token leftFactor)
                      throws IllegalActionException
Return a new Token whose value is the value of the argument Token multiplied by the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
multiplyReverse in class Token
Parameters:
leftFactor - The token to be multiplied by the value of this Token.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be multiplied by this Tokens value.

one

public Token one()
Returns a new LongToken with value 1.
Overrides:
one in class Token
Returns:
A new LongToken with value 1.

subtract

public Token subtract(Token rightArgument)
               throws IllegalActionException
Return a new Token whose value is the value of the argument Token subtracted from the value of this Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
subtract in class Token
Parameters:
rightArgument - The token to subtract to this Token.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be subtracted from this Tokens value.

subtractReverse

public Token subtractReverse(Token leftArgument)
                      throws IllegalActionException
Return a new Token whose value is the value of this Token subtracted from the value of the argument Token. Type resolution also occurs here, with the returned Token type chosen to achieve a lossless conversion.
Overrides:
subtractReverse in class Token
Parameters:
leftArgument - The token to add this Token to.
Returns:
A new Token containing the result.
Throws:
IllegalActionException - If the passed token is not of a type that can be added to this Tokens value.

toString

public 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.
Overrides:
toString in class Token
Returns:
A String formed using java.lang.Long.toString().

zero

public Token zero()
Returns a new LongToken with value 0.
Overrides:
zero in class Token
Returns:
A new LongToken with value 0.