|
|||||||||
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.AbstractNotConvertibleToken
ptolemy.data.RecordToken
public class RecordToken
A token that contains a set of label/token pairs. Operations on record tokens result in new record tokens containing only the common fields, where the operation specifies how to combine the data in the common fields. Thus, for example, if two record tokens are added or subtracted, then common records (those with the same labels) will be added or subtracted, and the disjoint records will not appear in the result.
Yellow (cxh) |
Green (neuendor) |
Field Summary | |
---|---|
protected java.util.Map |
_fields
The map of fields that has keys of type String and values of type token. |
static RecordToken |
EMPTY_RECORD
Empty Record. |
Fields inherited from class ptolemy.data.Token |
---|
NIL |
Constructor Summary | |
---|---|
RecordToken()
Construct a RecordToken with no fields. |
|
RecordToken(java.util.Map fieldMap)
Construct a RecordToken with the labels and values specified by a given Map object. |
|
RecordToken(java.lang.String init)
Construct a RecordToken from the specified string. |
|
RecordToken(java.lang.String[] labels,
Token[] values)
Construct a RecordToken with the specified labels and values. |
Method Summary | |
---|---|
protected Token |
_add(Token rightArgument)
Return a new token whose value is the field-wise addition of this token and the argument. |
protected RecordToken |
_createRecordToken(java.lang.String[] labels,
Token[] values)
Create a new RecordToken. |
protected java.util.Set |
_createSet()
Create a Set implementation appropriate for operations on this RecordToken Subclasses of RecordToken may return a different implementation. |
protected Token |
_divide(Token rightArgument)
Return a new token whose value is the field-wise division of this token and the argument. |
private void |
_initialize(java.lang.String[] labels,
Token[] values)
|
protected void |
_initializeStorage()
Subclasses of RecordToken may choose a different Map implementation TreeMap is used in the base class to provide naturally-ordered labels This may not be desired in some applications. |
protected BooleanToken |
_isCloseTo(Token rightArgument,
double epsilon)
Test whether 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 rightArgument)
Return true if the specified token is equal to this one. |
protected Token |
_modulo(Token rightArgument)
Return a new token whose value is the field-wise modulo of this token and the argument. |
protected Token |
_multiply(Token rightArgument)
Return a new token whose value is the field-wise multiplication of this token and the argument. |
protected Token |
_subtract(Token rightArgument)
Return a new token whose value is the field-wise subtraction of this token and the argument. |
boolean |
equals(java.lang.Object object)
Return true if the class of the argument is RecordToken, and the argument has the same set of labels as this token and the corresponding fields are equal, as determined by the equals method of the contained tokens. |
Token |
get(java.lang.String label)
Return the token with the specified label. |
Type |
getType()
Return the type of this token. |
int |
hashCode()
Return a hash code value for this token. |
java.util.Set |
labelSet()
Return the labels of this token as a Set. |
int |
length()
Return the length of this token. |
static RecordToken |
merge(RecordToken token1,
RecordToken token2)
Return a new token created by merging the two specified tokens, where preference is given to the first token when field labels are the same. |
static Type |
mergeReturnType(Type type1,
Type type2)
Return the (exact) return type of the merge function above. |
Token |
one()
Returns a new RecordToken representing the multiplicative identity. |
java.lang.String |
toString()
Return the value of this token as a string. |
Token |
zero()
Returns a new RecordToken representing the additive identity. |
Methods inherited from class ptolemy.data.AbstractNotConvertibleToken |
---|
add, addReverse, divide, divideReverse, isCloseTo, isEqualTo, modulo, moduloReverse, multiply, multiplyReverse, notSupportedDifferentClassesMessage, subtract, subtractReverse |
Methods inherited from class ptolemy.data.Token |
---|
isCloseTo, isNil, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, pow, zeroReturnType |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final RecordToken EMPTY_RECORD
protected java.util.Map _fields
Constructor Detail |
---|
public RecordToken()
public RecordToken(java.lang.String[] labels, Token[] values) throws IllegalActionException
labels
- An array of labels.values
- An array of Tokens.
IllegalActionException
- If the labels or the values array
do not have the same length, or contains null element,
or the labels array contains duplicate elements.public RecordToken(java.lang.String init) throws IllegalActionException
init
- A string expression of a record.
IllegalActionException
- If the string does not
contain a parsable record.public RecordToken(java.util.Map fieldMap) throws IllegalActionException
fieldMap
- A Map that has keys of type String and
values of type Token.
IllegalActionException
- If the map contains null
keys or values, or if it contains non-String keys or non-Token
values.Method Detail |
---|
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- An instance of Object.
hashCode()
public Token get(java.lang.String label)
label
- A String label.
public Type getType()
getType
in class Token
public int hashCode()
hashCode
in class java.lang.Object
public java.util.Set labelSet()
public int length()
public static RecordToken merge(RecordToken token1, RecordToken token2)
token1
- The higher priority record token.token2
- The lower priority record token.
public static Type mergeReturnType(Type type1, Type type2)
type1
- The type of the first argument to the
corresponding function.type2
- The type of the second argument to the
corresponding function.
public Token one() throws IllegalActionException
one
in class Token
IllegalActionException
- If multiplicative identity is not
supported by any element token.public java.lang.String toString()
{label = value, label = value, ...}
The record fields are listed in the lexicographical order of the
labels determined by the java.lang.String.compareTo() method.
toString
in class Token
public Token zero() throws IllegalActionException
zero
in class Token
IllegalActionException
- If additive identity is not
supported by any element token.protected Token _add(Token rightArgument) throws IllegalActionException
_add
in class AbstractNotConvertibleToken
rightArgument
- The token to add to this token.
IllegalActionException
- If calling the add method on
one of the record fields throws it.protected Token _divide(Token rightArgument) throws IllegalActionException
_divide
in class AbstractNotConvertibleToken
rightArgument
- The token to divide this token by.
IllegalActionException
- If calling the divide method on
one of the record fields throws it.protected BooleanToken _isCloseTo(Token rightArgument, double epsilon) throws IllegalActionException
_isCloseTo
in class AbstractNotConvertibleToken
rightArgument
- The token to compare to this token.epsilon
- The value that we use to determine whether two
tokens are close.
IllegalActionException
- If throw while checking
the closeness of an element of the record.protected BooleanToken _isEqualTo(Token rightArgument) throws IllegalActionException
_isEqualTo
in class AbstractNotConvertibleToken
rightArgument
- The token to compare to this token.
IllegalActionException
- If this method is not
supported by the derived class.protected Token _modulo(Token rightArgument) throws IllegalActionException
_modulo
in class AbstractNotConvertibleToken
rightArgument
- The token to modulo this token by.
IllegalActionException
- If calling the modulo method on
one of the record fields throws it.protected Token _multiply(Token rightArgument) throws IllegalActionException
_multiply
in class AbstractNotConvertibleToken
rightArgument
- The token to multiply this token by.
IllegalActionException
- If calling the multiply method on
one of the record fields throws it.protected Token _subtract(Token rightArgument) throws IllegalActionException
_subtract
in class AbstractNotConvertibleToken
rightArgument
- The token to subtract from this token.
IllegalActionException
- If calling the subtract
method on one of the record fields throws it.protected void _initializeStorage()
protected RecordToken _createRecordToken(java.lang.String[] labels, Token[] values) throws IllegalActionException
labels
- An array of String labels for the RecordToken to be created.values
- An array of Token values for the RecordToken to be created.
IllegalActionException
- If thrown while constructing the RecordTokenprotected java.util.Set _createSet()
private void _initialize(java.lang.String[] labels, Token[] values) throws IllegalActionException
IllegalActionException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |