ptolemy.data.type
Class UnsizedMatrixType

java.lang.Object
  extended byptolemy.data.type.StructuredType
      extended byptolemy.data.type.UnsizedMatrixType
All Implemented Interfaces:
java.io.Serializable, Type
Direct Known Subclasses:
UnsizedMatrixType.BooleanMatrixType, UnsizedMatrixType.ComplexMatrixType, UnsizedMatrixType.DoubleMatrixType, UnsizedMatrixType.FixMatrixType, UnsizedMatrixType.IntMatrixType, UnsizedMatrixType.LongMatrixType

public abstract class UnsizedMatrixType
extends StructuredType
implements java.io.Serializable

The base type of matrix token classes.

Since:
Ptolemy II 2.0
Version:
$Id: UnsizedMatrixType.java,v 1.20 2004/04/13 05:13:00 cxh Exp $
Author:
Steve Neuendorffer
See Also:
Serialized Form
Accepted Rating:
Red
Proposed Rating:
Red (yuhong)

Nested Class Summary
static class UnsizedMatrixType.BooleanMatrixType
          The boolean matrix data type
static class UnsizedMatrixType.ComplexMatrixType
          The complex matrix data type
static class UnsizedMatrixType.DoubleMatrixType
          The double matrix data type
static class UnsizedMatrixType.FixMatrixType
          The fix matrix data type
static class UnsizedMatrixType.IntMatrixType
          The integer matrix data type
static class UnsizedMatrixType.LongMatrixType
          The long matrix data type
 
Field Summary
 
Fields inherited from interface ptolemy.data.type.Type
HASH_INVALID, HASH_MAX
 
Constructor Summary
UnsizedMatrixType(java.lang.Class c, Type type, java.lang.String name)
          Construct a new matrix type that represents matrix tokens of the given class with the given number of rows and columns.
 
Method Summary
protected  int _compare(StructuredType type)
          Compare this type with the specified type.
protected  StructuredType _getRepresentative()
          Return a static instance of this structured type.
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 this, that is, return the reference to this object.
abstract  Token convert(Token token)
          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 MatrixType as this object.
 Type getElementType()
          Return the type of the elements contained in an instance of this matrix type.
static UnsizedMatrixType getMatrixTypeForElementType(Type elementType)
          Return a matrix type whose element type is the given element type.
 java.lang.Class getTokenClass()
          Return the class for tokens that this type represents.
 int hashCode()
          Return a hash code value for this object.
 void initialize(Type type)
          Set the elements that have declared type BaseType.UNKNOWN to the specified type.
 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()
          Test if this type corresponds to an instantiable token classes.
 boolean isSubstitutionInstance(Type type)
          Test if the argument is a substitution instance of this type.
 java.lang.String toString()
          Return the string representation of this type.
 void updateType(StructuredType newType)
          Update this StructuredType to the specified Structured Type.
 
Methods inherited from class ptolemy.data.type.StructuredType
getTypeHash
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnsizedMatrixType

public UnsizedMatrixType(java.lang.Class c,
                         Type type,
                         java.lang.String name)
Construct a new matrix type that represents matrix tokens of the given class with the given number of rows and columns.

Method Detail

clone

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

Specified by:
clone in interface Type
Specified by:
clone in class StructuredType
Returns:
A MatrixType.

convert

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

Specified by:
convert in interface Type
Parameters:
token - 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 MatrixType as this object.

Specified by:
equals in interface Type
Parameters:
object - A Type.
Returns:
True if the argument type is a matrix type representing the same class, with the same number of rows and columns.

getElementType

public Type getElementType()
Return the type of the elements contained in an instance of this matrix type. Tokens of the type returned by this method will be returned by the getElementAsToken of matrices that have this type.


getMatrixTypeForElementType

public static UnsizedMatrixType getMatrixTypeForElementType(Type elementType)
                                                     throws IllegalActionException
Return a matrix type whose element type is the given element type.

Throws:
IllegalActionException - If the elementType is not a type that has a corresponding matrix type.

getTokenClass

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

Specified by:
getTokenClass in interface Type
Returns:
A class that represents a matrix token.

hashCode

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

Returns:
The hash code for the token class of this type.

initialize

public void initialize(Type type)
Set the elements that have declared type BaseType.UNKNOWN to the specified type.

Specified by:
initialize in class StructuredType
Parameters:
type - A Type.

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 a constant. A Type is a constant if it does not contain BaseType.UNKNOWN in any level within it.

Specified by:
isConstant in interface Type
Returns:
False.

isInstantiable

public boolean isInstantiable()
Test if this type corresponds to an instantiable token classes.

Specified by:
isInstantiable in interface Type
Returns:
True.

isSubstitutionInstance

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

Specified by:
isSubstitutionInstance in interface Type
Parameters:
type - A Type.
Returns:
False.

toString

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

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

updateType

public void updateType(StructuredType newType)
                throws IllegalActionException
Update this StructuredType to the specified Structured Type. The specified type must have the same structure as this type. This method will only update the component type that is BaseType.UNKNOWN, and leave the constant part of this type intact.

Specified by:
updateType in class StructuredType
Parameters:
newType - A StructuredType.
Throws:
IllegalActionException - If the specified type has a different structure.

_compare

protected int _compare(StructuredType type)
Compare this type with the specified type. The specified type must be of the same structured type, otherwise an exception will be thrown. This method returns one of ptolemy.graph.CPO.LOWER, ptolemy.graph.CPO.SAME, ptolemy.graph.CPO.HIGHER, ptolemy.graph.CPO.INCOMPARABLE, indicating this type is lower than, equal to, higher than, or incomparable with the specified type in the type hierarchy, respectively.

Specified by:
_compare in class StructuredType
Parameters:
type - a StructuredType.
Returns:
An integer.
Throws:
java.lang.IllegalArgumentException - If the specified type is not the same structured type as this one.

_getRepresentative

protected StructuredType _getRepresentative()
Return a static instance of this structured type. The return value is used by TypeLattice to represent this type.

Specified by:
_getRepresentative in class StructuredType
Returns:
a StructuredType.

_greatestLowerBound

protected StructuredType _greatestLowerBound(StructuredType type)
Return the greatest lower bound of this type with the specified type. The specified type must be of the same structured type, otherwise an exception will be thrown.

Specified by:
_greatestLowerBound in class StructuredType
Parameters:
type - a StructuredType.
Returns:
a StructuredType.
Throws:
java.lang.IllegalArgumentException - If the specified type is not the same structured type as this one.

_leastUpperBound

protected StructuredType _leastUpperBound(StructuredType type)
Return the least upper bound of this type with the specified type. The specified type must be of the same structured type, otherwise an exception will be thrown.

Specified by:
_leastUpperBound in class StructuredType
Parameters:
type - a StructuredType.
Returns:
a StructuredType.
Throws:
java.lang.IllegalArgumentException - If the specified type is not the same structured type as this one.