Package ptolemy.data
Class XMLToken
- java.lang.Object
-
- ptolemy.data.Token
-
- ptolemy.data.XMLToken
-
public class XMLToken extends Token
A token that contains a xml document. Currently, no operations between function tokens (add, multiply, etc.) are supported.- Since:
- Ptolemy II 4.0
- Version:
- $Id$
- Author:
- Yang Zhao
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (neuendor)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.static XMLToken
convert(Token token)
Convert the specified token into an instance of XMLToken.boolean
equals(java.lang.Object object)
Return true if the argument is an instance of XMLToken with the same value.org.w3c.dom.Document
getDomTree()
Return the dom document parsed from the xml string.Type
getType()
Return the type of this token.int
hashCode()
Return the hash code for the XMLToken object.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.java.lang.String
toString()
Return the value of this Token as a string.-
Methods inherited from class ptolemy.data.Token
add, addReverse, divide, divideReverse, isCloseTo, isEqualTo, isNil, modulo, moduloReverse, multiply, multiplyReverse, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, one, pow, subtract, subtractReverse, zero, zeroReturnType
-
-
-
-
Constructor Detail
-
XMLToken
public XMLToken()
Construct an empty token.
-
XMLToken
public XMLToken(java.lang.String init) throws java.lang.Exception
Construct an XmlToken from the specified string.- Parameters:
init
- The initialization string.- Throws:
java.lang.Exception
- If the string is not parsable.
-
-
Method Detail
-
convert
public static XMLToken convert(Token token) throws IllegalActionException
Convert the specified token into an instance of XMLToken. If the specified token is not an instance of XMLToken, an exception is thrown.- Parameters:
token
- The token to be converted to a XMLToken.- Returns:
- A XMLToken.
- Throws:
IllegalActionException
- If the conversion cannot be carried out.
-
getDomTree
public org.w3c.dom.Document getDomTree()
Return the dom document parsed from the xml string.- Returns:
- A Document.
-
equals
public boolean equals(java.lang.Object object)
Return true if the argument is an instance of XMLToken with the same value.- Overrides:
equals
in classjava.lang.Object
- Parameters:
object
- An instance of Object.- Returns:
- True if the argument is an IntToken with the same value. If either this object or the argument is nil, return false.
-
hashCode
public int hashCode()
Return the hash code for the XMLToken object. If two XMLToken objects contains the same String then they have the same hashcode.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hash code for this XMLToken object.
-
isCloseTo
public final BooleanToken isCloseTo(Token token, double epsilon) throws IllegalActionException
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. This method only makes sense for tokens where the distance between them is reasonably represented as a double. If the argument token is not of the same type as this token, then either this token or the argument will be converted, if possible, to the type of the other.Subclasses should not generally override this method, but override the protected _isCloseTo() method to ensure that type conversion is performed consistently.
- Overrides:
isCloseTo
in classToken
- Parameters:
token
- The token to test closeness of this token with.epsilon
- The value that we use to determine whether two tokens are close.- Returns:
- A boolean token that contains the value true if the value and units of this token are close to those of the argument token.
- Throws:
IllegalActionException
- If the argument token and this token are of incomparable types, or the operation does not make sense for the given types.
-
getType
public Type getType()
Return the type of this token.
-
toString
public java.lang.String toString()
Return the value of this Token as a string.
-
_isCloseTo
protected BooleanToken _isCloseTo(Token rightArgument, double epsilon) throws IllegalActionException
Test for closeness of the values of this Token and the argument Token. It is assumed that the type of the argument is an XMLToken.- Parameters:
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.- Returns:
- A BooleanToken containing the result.
- Throws:
IllegalActionException
- If this method is not supported by the derived class.
-
_isEqualTo
protected BooleanToken _isEqualTo(Token rightArgument) throws IllegalActionException
Test for equality of the values of this Token and the argument Token. It is assumed that the type of the argument is XMLToken.- Parameters:
rightArgument
- The token to add to this token.- Returns:
- A BooleanToken containing the result.
- Throws:
IllegalActionException
- If this method is not supported by the derived class.
-
-