ptolemy.data.type
Class TopMatrixType

java.lang.Object
  extended byptolemy.data.type.StructuredType
      extended byptolemy.data.type.TopMatrixType
All Implemented Interfaces:
java.io.Serializable, Type

public class TopMatrixType
extends StructuredType
implements java.io.Serializable

The least upper bound for all matrix types.

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

Field Summary
 
Fields inherited from interface ptolemy.data.type.Type
HASH_INVALID, HASH_MAX
 
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.
 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.
static TopMatrixType getInstance()
          Return the singleton instance of this class.
 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
 

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 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.

getInstance

public static TopMatrixType getInstance()
Return the singleton instance of this class.


getTokenClass

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

Specified by:
getTokenClass in interface Type

hashCode

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

Returns:
The hash code for the TopMatrixType class.

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:
False.

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.