ptolemy.data.type
Class BaseType

java.lang.Object
  extended byptolemy.data.type.BaseType
All Implemented Interfaces:
java.io.Serializable, Type
Direct Known Subclasses:
BaseType.BooleanType, BaseType.ComplexType, BaseType.DoubleType, BaseType.EventType, BaseType.GeneralType, BaseType.IntType, BaseType.LongType, BaseType.NumericalType, BaseType.ObjectType, BaseType.ScalarType, BaseType.StringType, BaseType.UnknownType, BaseType.UnsignedByteType, BaseType.XmlTokenType

public abstract class BaseType
extends java.lang.Object
implements Type, java.io.Serializable

The type of base token classes. This class provides a type safe enumeration of base types.

Since:
Ptolemy II 0.4
Version:
$Id: BaseType.java,v 1.71 2004/04/13 05:13:01 cxh Exp $
Author:
Yuhong Xiong, Steve Neuendorffer
See Also:
Serialized Form
Accepted Rating:
Red
Proposed Rating:
Red (yuhong)

Nested Class Summary
static class BaseType.BooleanType
          The boolean data type
static class BaseType.ComplexType
          The complex data type
static class BaseType.DoubleType
          The double data type
static class BaseType.EventType
          The event data type
static class BaseType.GeneralType
          The general data type: The top of the lattice.
static class BaseType.IntType
          The integer data type
static class BaseType.LongType
          The long integer data type
static class BaseType.NumericalType
          The numerical data type
static class BaseType.ObjectType
          The object data type
static class BaseType.ScalarType
          The scalar data type: The least upper bound of all the scalar types.
static class BaseType.StringType
          The string data type
static class BaseType.UnknownType
          The bottom element of the data type lattice.
static class BaseType.UnsignedByteType
          The unsigned byte data type
static class BaseType.XmlTokenType
          The XmlToken data type
 
Field Summary
static BaseType.BooleanType BOOLEAN
           
static UnsizedMatrixType.BooleanMatrixType BOOLEAN_MATRIX
           
static BaseType.ComplexType COMPLEX
           
static UnsizedMatrixType.ComplexMatrixType COMPLEX_MATRIX
           
static BaseType.DoubleType DOUBLE
           
static UnsizedMatrixType.DoubleMatrixType DOUBLE_MATRIX
           
static BaseType.EventType EVENT
           
static FixType FIX
          The fix data type
static UnsizedMatrixType.FixMatrixType FIX_MATRIX
           
static BaseType.GeneralType GENERAL
           
static BaseType.IntType INT
           
static UnsizedMatrixType.IntMatrixType INT_MATRIX
           
static BaseType.LongType LONG
           
static UnsizedMatrixType.LongMatrixType LONG_MATRIX
           
static TopMatrixType MATRIX
          The matrix data type: The least upper bound of all the matrix types.
static BaseType.NumericalType NUMERICAL
           
static BaseType.ObjectType OBJECT
           
static BaseType.ScalarType SCALAR
           
static BaseType.StringType STRING
           
static BaseType.UnknownType UNKNOWN
           
static BaseType.UnsignedByteType UNSIGNED_BYTE
           
static BaseType.XmlTokenType XMLTOKEN
           
 
Fields inherited from interface ptolemy.data.type.Type
HASH_INVALID, HASH_MAX
 
Method Summary
 java.lang.Object clone()
          Return this, that is, return the reference to this object.
abstract  Token convert(Token t)
          Convert the specified token to a token having the type represented by this object.
 boolean equals(java.lang.Object object)
          Determine if the argument represents the same BaseType as this object.
static Type forClassName(java.lang.String className)
          Return an instance of this class that corresponds to tokens of a class with the given name, or null if none exists.
static Type forName(java.lang.String name)
          Return an instance of this class with the specified name, or null if none exists.
 java.lang.Class getTokenClass()
          Return the class for tokens that this basetype represents.
 int getTypeHash()
          Return a perfect hash for this type.
 int hashCode()
          Return a hash code value for this object.
 boolean isCompatible(Type type)
          Test if the argument type is compatible with this type.
 boolean isConstant()
          Test if this Type is UNKNOWN.
 boolean isInstantiable()
          Determine if this type corresponds to an instantiable token classes.
 boolean isSubstitutionInstance(Type type)
          Return true if the argument is a substitution instance of this type.
 java.lang.String toString()
          Return the string representation of this type.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UNKNOWN

public static final BaseType.UnknownType UNKNOWN

BOOLEAN

public static final BaseType.BooleanType BOOLEAN

BOOLEAN_MATRIX

public static final UnsizedMatrixType.BooleanMatrixType BOOLEAN_MATRIX

UNSIGNED_BYTE

public static final BaseType.UnsignedByteType UNSIGNED_BYTE

COMPLEX

public static final BaseType.ComplexType COMPLEX

COMPLEX_MATRIX

public static final UnsizedMatrixType.ComplexMatrixType COMPLEX_MATRIX

DOUBLE

public static final BaseType.DoubleType DOUBLE

DOUBLE_MATRIX

public static final UnsizedMatrixType.DoubleMatrixType DOUBLE_MATRIX

FIX

public static final FixType FIX
The fix data type


FIX_MATRIX

public static final UnsizedMatrixType.FixMatrixType FIX_MATRIX

INT

public static final BaseType.IntType INT

INT_MATRIX

public static final UnsizedMatrixType.IntMatrixType INT_MATRIX

LONG

public static final BaseType.LongType LONG

LONG_MATRIX

public static final UnsizedMatrixType.LongMatrixType LONG_MATRIX

MATRIX

public static final TopMatrixType MATRIX
The matrix data type: The least upper bound of all the matrix types.


NUMERICAL

public static final BaseType.NumericalType NUMERICAL

OBJECT

public static final BaseType.ObjectType OBJECT

XMLTOKEN

public static final BaseType.XmlTokenType XMLTOKEN

SCALAR

public static final BaseType.ScalarType SCALAR

STRING

public static final BaseType.StringType STRING

GENERAL

public static final BaseType.GeneralType GENERAL

EVENT

public static final BaseType.EventType EVENT
Method Detail

clone

public java.lang.Object clone()
Return this, that is, return the reference to this object.

Specified by:
clone in interface Type
Returns:
A BaseType.

convert

public abstract Token convert(Token t)
                       throws IllegalActionException
Convert the specified token to a token having the type represented by this object.

Specified by:
convert in interface Type
Parameters:
t - A token.
Returns:
A token.
Throws:
IllegalActionException - If lossless conversion cannot be done.

equals

public boolean equals(java.lang.Object object)
Determine if the argument represents the same BaseType as this object.

Specified by:
equals in interface Type
Parameters:
object - Another object.
Returns:
True if the argument represents the same BaseType as this object; false otherwise.

forClassName

public static Type forClassName(java.lang.String className)
Return an instance of this class that corresponds to tokens of a class with the given name, or null if none exists.

Returns:
An instance of BaseType.

forName

public static Type forName(java.lang.String name)
Return an instance of this class with the specified name, or null if none exists.

Returns:
An instance of BaseType.

getTokenClass

public java.lang.Class getTokenClass()
Return the class for tokens that this basetype represents.

Specified by:
getTokenClass in interface Type

getTypeHash

public 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. This base class returns HASH_INVALID.

Specified by:
getTypeHash in interface Type
Returns:
A number between 0 and HASH_MAX, or HASH_INVALID.

hashCode

public int hashCode()
Return a hash code value for this object.


isCompatible

public boolean isCompatible(Type type)
Test if the argument type is compatible with this type. The method returns true if this type is UNKNOWN, since any type is a substitution instance of it. If this type is not UNKNOWN, this method returns true if the argument type is less than or equal to this type in the type lattice, and false otherwise.

Specified by:
isCompatible in interface Type
Parameters:
type - An instance of Type.
Returns:
True if the argument is compatible with this type.

isConstant

public boolean isConstant()
Test if this Type is UNKNOWN.

Specified by:
isConstant in interface Type
Returns:
True if this Type is not UNKNOWN; false otherwise.

isInstantiable

public boolean isInstantiable()
Determine if this type corresponds to an instantiable token classes. A BaseType is instantiable if it does not correspond to an abstract token class, or an interface, or UNKNOWN.

Specified by:
isInstantiable in interface Type
Returns:
True if this type is instantiable.

isSubstitutionInstance

public boolean isSubstitutionInstance(Type type)
Return true if the argument is a substitution instance of this type.

Specified by:
isSubstitutionInstance in interface Type
Parameters:
type - A Type.
Returns:
True if this type is UNKNOWN; false otherwise.

toString

public java.lang.String toString()
Return the string representation of this type.

Specified by:
toString in interface Type
Returns:
A String.