|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectptolemy.data.type.StructuredType
ptolemy.data.type.RecordType
public class RecordType
A class representing the type of a RecordToken. To set the type of a typeable object (such as a port or parameter) to a record with particular fields, create an instance of this class and call setTypeEquals() with that instance as an argument.
Note that a record type with more fields is a subtype of a record type with a subset of the fields. For example, {x = double, y = int} is a subtype of {x = double}. When a record of type {x = double, y = int} is converted to one of type {x = double}, the extra field is discarded. The converted record, therefore, will have exactly the fields in the type.
A consequence of this is that all record types are subtypes of the empty record type. Hence, to require that a typeable object be a record type without specifying what the fields are, use
typeable.setTypeAtMost(new RecordType(new String[0], new Type[0]));Note, however, that by itself this type constraint will not be useful because it does not, by itself, prevent the type from resolving to unknown (the unknown type is at the bottom of the type lattice, and hence satisfies this type constraint).
| Red (cxh) |
| Red (neuendor) |
| Field Summary |
|---|
| Fields inherited from class ptolemy.data.type.StructuredType |
|---|
MAXDEPTHBOUND |
| Fields inherited from interface ptolemy.data.type.Type |
|---|
HASH_INVALID, HASH_MAX |
| Constructor Summary | |
|---|---|
RecordType(java.util.Map fieldMap)
Construct a RecordType with the labels and values specified by a given Map object. |
|
RecordType(java.lang.String[] labels,
Type[] types)
Construct a new RecordType with the specified labels and types. |
|
| Method Summary | |
|---|---|
protected int |
_compare(StructuredType type)
Compare this type with the specified type. |
protected StructuredType |
_getRepresentative()
Return a static instance of RecordType. |
protected StructuredType |
_greatestLowerBound(StructuredType type)
Return the greatest lower bound of this type with the specified type. |
protected StructuredType |
_leastUpperBound(StructuredType type)
Return the least Upper bound of this type with the specified type. |
java.lang.Object |
clone()
Return a deep copy of this RecordType if it is a variable, or itself if it is a constant. |
Token |
convert(Token token)
Convert the argument token into a RecordToken having this type, if lossless conversion can be done. |
int |
depth()
Return the depth of a record type. |
boolean |
equals(java.lang.Object object)
Determine if the argument represents the same RecordType as this object. |
Type |
get(java.lang.String label)
Return the type of the specified label. |
java.lang.Class |
getTokenClass()
Return the class for tokens that this type represents. |
InequalityTerm |
getTypeTerm(java.lang.String label)
Return the InequalityTerm representing the type of the specified label. |
int |
hashCode()
Return a hash code value for this object. |
void |
initialize(Type type)
Set the elements that have declared type BaseType.UNKNOWN (the leaf type variable) to the specified type. |
boolean |
isAbstract()
Return true if this type does not correspond to a single token class. |
boolean |
isCompatible(Type type)
Test if the argument type is compatible with this type. |
boolean |
isConstant()
Test if this RecordType is a constant. |
boolean |
isInstantiable()
Test if this type corresponds to an instantiable token class. |
boolean |
isSubstitutionInstance(Type type)
Test if the specified type is a substitution instance of this type. |
java.util.Set |
labelSet()
Return the labels of this record type as a Set. |
java.lang.String |
toString()
Return the string representation of this type. |
void |
updateType(StructuredType newType)
Update this Type to the specified RecordType. |
| Methods inherited from class ptolemy.data.type.StructuredType |
|---|
add, divide, getTypeHash, modulo, multiply, one, subtract, zero |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RecordType(java.lang.String[] labels,
Type[] types)
labels - An array of String.types - An array of Type.
java.lang.IllegalArgumentException - If the two arrays do not have
the same size.
java.lang.NullPointerException - If one of the arguments is null.
public RecordType(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-Type
values| Method Detail |
|---|
public java.lang.Object clone()
clone in interface Typeclone in class StructuredType
public Token convert(Token token)
throws IllegalActionException
token - A token.
IllegalActionException - If lossless conversion
cannot be done.public int depth()
depth in class StructuredTypepublic boolean equals(java.lang.Object object)
equals in interface Typeequals in class java.lang.Objectobject - Another object.
public Type get(java.lang.String label)
label - The specified label.
public java.lang.Class getTokenClass()
public InequalityTerm getTypeTerm(java.lang.String label)
label - The specified label.
InequalityTermpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean isAbstract()
isAbstract in interface TypeisAbstract in class StructuredTypepublic void initialize(Type type)
initialize in class StructuredTypetype - the type to set the leaf type variable to.public boolean isCompatible(Type type)
type - An instance of Type.
public boolean isConstant()
public boolean isInstantiable()
public boolean isSubstitutionInstance(Type type)
type - A Type.
Type.isSubstitutionInstance(ptolemy.data.type.Type)public java.util.Set labelSet()
public java.lang.String toString()
toString in interface TypetoString in class java.lang.Object
public void updateType(StructuredType newType)
throws IllegalActionException
updateType in class StructuredTypenewType - A StructuredType.
IllegalActionException - If the specified type is not a
RecordType or it does not have the same structure as this one.protected int _compare(StructuredType type)
_compare in class StructuredTypetype - a RecordType.
java.lang.IllegalArgumentException - If the specified type is
not a RecordType.protected StructuredType _getRepresentative()
_getRepresentative in class StructuredTypeprotected StructuredType _greatestLowerBound(StructuredType type)
_greatestLowerBound in class StructuredTypetype - a RecordType.
java.lang.IllegalArgumentException - If the specified type is
not a RecordType.protected StructuredType _leastUpperBound(StructuredType type)
_leastUpperBound in class StructuredTypetype - a RecordType.
java.lang.IllegalArgumentException - If the specified type is
not a RecordType.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||