|
|||||||||
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
ptolemy.data.StringToken
public class StringToken
A token that contains a string, or more specifically, a reference to an instance of String. The reference is never null, although it may be an empty string (""). Note that when this token is cloned, the clone will refer to exactly the same String object. However, a String object in Java is immutable, so there is no risk when two tokens refer to the same string that one of the strings will be changed.
Red (cxh) nil token code |
Yellow (cxh) |
Field Summary | |
---|---|
private java.lang.String |
_toString
|
private java.lang.String |
_value
|
static StringToken |
NIL
A token that represents a missing value. |
Constructor Summary | |
---|---|
StringToken()
Construct a token with an empty string. |
|
StringToken(java.lang.String value)
Construct a token with the specified string. |
Method Summary | |
---|---|
protected 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 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 BooleanToken |
_isCloseTo(Token rightArgument,
double epsilon)
Test for closeness of the values of this Token and the argument Token. |
protected BooleanToken |
_isEqualTo(Token rightArgument)
Test for equality of the values of this Token and the argument Token. |
protected Token |
_modulo(Token rightArgument)
Return a new token whose value is the value of this token modulo the value of the argument token. |
protected 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 Token |
_subtract(Token rightArgument)
Return a new token whose value is the value of the argument token subtracted from the value of this token. |
static StringToken |
convert(Token token)
Convert the specified token into an instance of StringToken. |
boolean |
equals(java.lang.Object object)
Return true if the argument is an instance of StringToken with the same 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). |
java.lang.String |
stringValue()
Return the string that this token contains. |
java.lang.String |
toString()
Return the value of this Token as a string. |
Token |
zero()
Return a StringToken containing an empty string, which is considered as the additive identity of string. |
Methods inherited from class ptolemy.data.AbstractConvertibleToken |
---|
add, addReverse, divide, divideReverse, isCloseTo, isEqualTo, modulo, moduloReverse, multiply, multiplyReverse, subtract, subtractReverse |
Methods inherited from class ptolemy.data.Token |
---|
isCloseTo, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, pow, zeroReturnType |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final StringToken NIL
private java.lang.String _value
private java.lang.String _toString
Constructor Detail |
---|
public StringToken()
public StringToken(java.lang.String value)
value
- The specified string.Method Detail |
---|
public static StringToken convert(Token token) throws IllegalActionException
NIL
is returned.
Otherwise, if the argument is below StringToken in the type
hierarchy, it is converted to an instance of StringToken or
one of the subclasses of StringToken and returned. If none of
the above condition is met, an exception is thrown.
token
- The token to be converted to a StringToken.
IllegalActionException
- If the conversion cannot
be carried out.public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- An instance of Object.
public Type getType()
getType
in class Token
public int hashCode()
hashCode
in class java.lang.Object
public boolean isNil()
isNil
in class Token
NIL
token.public java.lang.String stringValue()
public java.lang.String toString()
toString
in class Token
public Token zero()
zero
in class Token
protected Token _add(Token rightArgument) throws IllegalActionException
_add
in class AbstractConvertibleToken
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 Token _divide(Token rightArgument) throws IllegalActionException
_divide
in class AbstractConvertibleToken
rightArgument
- The token to divide this token by.
IllegalActionException
- If this method is not
supported by the derived class.protected BooleanToken _isCloseTo(Token rightArgument, double epsilon) throws IllegalActionException
_isCloseTo
in class AbstractConvertibleToken
rightArgument
- The token to add to this token.epsilon
- The value that we use to determine whether two
tokens are close. This parameter is ignored by this class.
IllegalActionException
- If this method is not
supported by the derived class.protected BooleanToken _isEqualTo(Token rightArgument) throws IllegalActionException
_isEqualTo
in class AbstractConvertibleToken
rightArgument
- The token to add to this token.
IllegalActionException
- If this method is not
supported by the derived class.protected Token _modulo(Token rightArgument) throws IllegalActionException
_modulo
in class AbstractConvertibleToken
rightArgument
- The token to modulo this token by.
IllegalActionException
- If this method is not
supported by the derived class.protected Token _multiply(Token rightArgument) throws IllegalActionException
_multiply
in class AbstractConvertibleToken
rightArgument
- The token to multiply this token by.
IllegalActionException
- If this method is not
supported by the derived class.protected Token _subtract(Token rightArgument) throws IllegalActionException
_subtract
in class AbstractConvertibleToken
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 |