ptolemy.data.type
Interface Type
- All Known Implementing Classes:
- ActorType, ArrayType, BaseType, BaseType.ArrayBottomType, BaseType.BooleanType, BaseType.ComplexType, 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, FixType, FunctionType, KeyToken.KeyType, LocationType, MatrixType, MatrixType.BooleanMatrixType, MatrixType.ComplexMatrixType, MatrixType.DoubleMatrixType, MatrixType.FixMatrixType, MatrixType.IntMatrixType, MatrixType.LongMatrixType, ObjectType, PointerToken.PointerType, RecordType, Scene2DToken.Scene2DType, SceneGraphToken.SceneGraphType, StructuredType, UnionType
public interface Type
An interface representing the type of a Token.
- Since:
- Ptolemy II 0.4
- Version:
- $Id: Type.java 57040 2010-01-27 20:52:32Z cxh $
- Author:
- Yuhong Xiong, Steve Neuendorffer
- Accepted Rating:
- Proposed Rating:
Field Summary |
static int |
HASH_INVALID
Used to indicate that the type comparison cache is invalid. |
static int |
HASH_MAX
The maximum size of the type hash. |
Method Summary |
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. |
java.lang.Object |
clone()
Return a deep clone of this type. |
Token |
convert(Token token)
Convert the specified token into a token having the type
represented by this object. |
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. |
boolean |
equals(java.lang.Object object)
Determine if the argument represents the same type as this object. |
java.lang.Class |
getTokenClass()
Return the class for tokens that this type represents. |
int |
getTypeHash()
Return a perfect hash for this 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 Type is a constant. |
boolean |
isInstantiable()
Determine if this Type corresponds to an instantiable token
class. |
boolean |
isSubstitutionInstance(Type type)
Return true if the specified type is a substitution instance of this
type. |
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. |
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. |
Type |
one()
Return the type of the multiplicative identity for elements of
this type. |
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. |
java.lang.String |
toString()
Return the string representation of this type. |
Type |
zero()
Return the type of the additive identity for elements of
this type. |
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
HASH_MAX
static final int HASH_MAX
- The maximum size of the type hash.
- See Also:
- Constant Field Values
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.CloneNotSupportedException
- Return 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:
equals
in class java.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 between 0 and HASH_MAX, 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:
toString
in class java.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.