Package ptolemy.data.type
Interface Type
-
- All Known Implementing Classes:
ActorType,ArrayType,AssociativeType,BaseType,BaseType.ArrayBottomType,BaseType.BooleanType,BaseType.ComplexType,BaseType.DateType,BaseType.DoubleType,BaseType.EventType,BaseType.FloatType,BaseType.GeneralType,BaseType.IntType,BaseType.LongType,BaseType.NilType,BaseType.PetiteType,BaseType.ScalarType,BaseType.ShortType,BaseType.StringType,BaseType.UnknownType,BaseType.UnsignedByteType,BaseType.UnsizedFixType,BaseType.XmlTokenType,ConceptType,FixType,FunctionType,KeyToken.KeyType,LocationType,MatrixType,MatrixType.BooleanMatrixType,MatrixType.ComplexMatrixType,MatrixType.DoubleMatrixType,MatrixType.FixMatrixType,MatrixType.IntMatrixType,MatrixType.LongMatrixType,MetroIIPtidesPlatform.PtidesNetworkType,ObjectType,PointerToken.PointerType,PtidesPlatform.PtidesNetworkModelTimeType,PtidesPlatform.PtidesNetworkRealTimeType,RecordType,Scene2DToken.Scene2DType,SceneGraphToken.SceneGraphType,StructuredType,TestToken.TestType,TupleType,UnionType
public interface TypeAn interface representing the type of a Token.- Since:
- Ptolemy II 0.4
- Version:
- $Id$
- Author:
- Yuhong Xiong, Steve Neuendorffer
- Pt.AcceptedRating:
- Red (cxh)
- Pt.ProposedRating:
- Red (neuendor)
-
-
Field Summary
Fields Modifier and Type Field Description static intHASH_INVALIDUsed to indicate that the type comparison cache is invalid.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Typeadd(Type rightArgumentType)Return a new type which represents the type that results from adding a token of this type and a token of the given argument type.java.lang.Objectclone()Return a deep clone of this type.Tokenconvert(Token token)Convert the specified token into a token having the type represented by this object.Typedivide(Type rightArgumentType)Return a new type which represents the type that results from dividing a token of this type and a token of the given argument type.booleanequals(java.lang.Object object)Determine if the argument represents the same type as this object.java.lang.ClassgetTokenClass()Return the class for tokens that this type represents.intgetTypeHash()Return a perfect hash for this type.booleanisAbstract()Return true if this type does not correspond to a single token class.booleanisCompatible(Type type)Test if the argument type is compatible with this type.booleanisConstant()Test if this Type is a constant.booleanisInstantiable()Determine if this Type corresponds to an instantiable token class.booleanisSubstitutionInstance(Type type)Return true if the specified type is a substitution instance of this type.Typemodulo(Type rightArgumentType)Return a new type which represents the type that results from moduloing a token of this type and a token of the given argument type.Typemultiply(Type rightArgumentType)Return a new type which represents the type that results from multiplying a token of this type and a token of the given argument type.Typeone()Return the type of the multiplicative identity for elements of this type.Typesubtract(Type rightArgumentType)Return a new type which represents the type that results from subtracting a token of this type and a token of the given argument type.java.lang.StringtoString()Return the string representation of this type.Typezero()Return the type of the additive identity for elements of this type.
-
-
-
Field Detail
-
HASH_INVALID
static final int HASH_INVALID
Used to indicate that the type comparison cache is invalid.- Since:
- Ptolemy II 2.1
- See Also:
- Constant Field Values
-
-
Method Detail
-
add
Type add(Type rightArgumentType)
Return a new type which represents the type that results from adding a token of this type and a token of the given argument type.- Parameters:
rightArgumentType- The type to add to this type.- Returns:
- A new type, or BaseType.GENERAL, if the operation does not make sense for the given types.
-
clone
java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturn a deep clone of this type.- Returns:
- A Type.
- Throws:
java.lang.CloneNotSupportedException- If an instance cannot be cloned.
-
convert
Token convert(Token token) throws IllegalActionException
Convert the specified token into a token having the type represented by this object.- Parameters:
token- a token.- Returns:
- a token.
- Throws:
IllegalActionException- If lossless conversion cannot be done.
-
divide
Type divide(Type rightArgumentType)
Return a new type which represents the type that results from dividing a token of this type and a token of the given argument type.- Parameters:
rightArgumentType- The type to add to this type.- Returns:
- A new type, or BaseType.GENERAL, if the operation does not make sense for the given types.
-
equals
boolean equals(java.lang.Object object)
Determine if the argument represents the same type as this object.- Overrides:
equalsin classjava.lang.Object- Parameters:
object- A Type.- Returns:
- True if the argument represents the same type as this object; false otherwise.
-
getTypeHash
int getTypeHash()
Return a perfect hash for this type. This number corresponds uniquely to a particular type, and is used to improve performance of certain operations in the TypeLattice class. All instances of a particular type (e.g. integer array) must return the same number. Types that return HASH_INVALID will not have results in TypeLattice cached. Note that it is safer to return HASH_INVALID, than to return a number that is not unique, or different number for the same type from different instances.- Returns:
- A number greater than or equal to 0, or HASH_INVALID.
-
getTokenClass
java.lang.Class getTokenClass()
Return the class for tokens that this type represents.- Returns:
- The class for tokens that this type represents.
-
isAbstract
boolean isAbstract()
Return true if this type does not correspond to a single token class. This occurs if the type is not instantiable, or it represents either an abstract base class or an interface.- Returns:
- True if this type does not correspond to a single token class.
-
isCompatible
boolean isCompatible(Type type)
Test if the argument type is compatible with this type. Compatible is defined as follows: If this type is a constant, the argument is compatible if it is the same or less than this type in the type lattice; If this type is a variable, the argument is compatible if it is a substitution instance of this type.- Parameters:
type- An instance of Type.- Returns:
- True if the argument is compatible with this type.
-
isConstant
boolean isConstant()
Test if this Type is a constant. A Type is a constant if it does not contain BaseType.UNKNOWN in any level within it.- Returns:
- True if this type is a constant.
-
isInstantiable
boolean isInstantiable()
Determine if this Type corresponds to an instantiable token class.- Returns:
- True if this type corresponds to an instantiable token class.
-
isSubstitutionInstance
boolean isSubstitutionInstance(Type type)
Return true if the specified type is a substitution instance of this type. For the argument to be a substitution instance, it must be either the same as this type, or it must be a type that can be obtained by replacing the BaseType.UNKNOWN component of this type by another type.- Parameters:
type- A Type.- Returns:
- True if the argument is a substitution instance of this type.
-
modulo
Type modulo(Type rightArgumentType)
Return a new type which represents the type that results from moduloing a token of this type and a token of the given argument type.- Parameters:
rightArgumentType- The type to add to this type.- Returns:
- A new type, or BaseType.GENERAL, if the operation does not make sense for the given types.
-
multiply
Type multiply(Type rightArgumentType)
Return a new type which represents the type that results from multiplying a token of this type and a token of the given argument type.- Parameters:
rightArgumentType- The type to add to this type.- Returns:
- A new type, or BaseType.GENERAL, if the operation does not make sense for the given types.
-
one
Type one()
Return the type of the multiplicative identity for elements of this type.- Returns:
- A new type, or BaseType.GENERAL, if the operation does not make sense for the given types.
-
subtract
Type subtract(Type rightArgumentType)
Return a new type which represents the type that results from subtracting a token of this type and a token of the given argument type.- Parameters:
rightArgumentType- The type to add to this type.- Returns:
- A new type, or BaseType.GENERAL, if the operation does not make sense for the given types.
-
toString
java.lang.String toString()
Return the string representation of this type.- Overrides:
toStringin classjava.lang.Object- Returns:
- A String.
-
zero
Type zero()
Return the type of the additive identity for elements of this type.- Returns:
- A new type, or BaseType.GENERAL, if the operation does not make sense for the given types.
-
-