ptolemy.data.type
Class TypeConstant

java.lang.Object
  extended by ptolemy.data.type.TypeConstant
All Implemented Interfaces:
InequalityTerm

public class TypeConstant
extends java.lang.Object
implements InequalityTerm

An InequalityTerm that encapsulates a constant type. The constant type is specified in the constructor. This class represents a constant term in an inequality constraint for type resolution.

Since:
Ptolemy II 0.4
Version:
$Id: TypeConstant.java 57040 2010-01-27 20:52:32Z cxh $
Author:
Yuhong Xiong
See Also:
InequalityTerm
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (yuhong)

Field Summary
private  Type _type
           
 
Constructor Summary
TypeConstant(Type type)
          Construct a TypeConstant.
 
Method Summary
 boolean equals(java.lang.Object object)
          Override to return true if the type is the same in this object as the specified object.
 java.lang.Object getAssociatedObject()
          Return null.
 java.lang.Object getValue()
          Return the constant type represented by this term.
 InequalityTerm[] getVariables()
          Return an array of size zero.
 int hashCode()
          Return the hashCode of the type.
 void initialize(java.lang.Object e)
          Throw an Exception since type constant cannot be initialized.
 boolean isSettable()
          Return false since this term represent a constant.
 boolean isValueAcceptable()
          Check whether the current type of this term is acceptable, and return true if it is.
 void setValue(java.lang.Object e)
          Throw IllegalActionException since the value of this term cannot be changed.
 java.lang.String toString()
          Return a string representation of this term.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_type

private Type _type
Constructor Detail

TypeConstant

public TypeConstant(Type type)
Construct a TypeConstant.

Parameters:
type - An instance of Type.
Method Detail

equals

public boolean equals(java.lang.Object object)
Override to return true if the type is the same in this object as the specified object.

Overrides:
equals in class java.lang.Object
Parameters:
object - The object to compare against.
Returns:
true if the argument is equal to this argument.

getAssociatedObject

public java.lang.Object getAssociatedObject()
Return null.

Specified by:
getAssociatedObject in interface InequalityTerm
Returns:
null.

getValue

public java.lang.Object getValue()
Return the constant type represented by this term.

Specified by:
getValue in interface InequalityTerm
Returns:
A Type.
See Also:
setValue(Object)

getVariables

public InequalityTerm[] getVariables()
Return an array of size zero.

Specified by:
getVariables in interface InequalityTerm
Returns:
An array of InequalityTerm of size 0.

hashCode

public int hashCode()
Return the hashCode of the type. This ensures that if equals() returns true then the two objects return the same hashCode.

Overrides:
hashCode in class java.lang.Object
Returns:
The hashCode of this object.

initialize

public void initialize(java.lang.Object e)
                throws IllegalActionException
Throw an Exception since type constant cannot be initialized.

Specified by:
initialize in interface InequalityTerm
Parameters:
e - An Object representing an element in the underlying CPO.
Throws:
IllegalActionException - Always thrown.

isSettable

public boolean isSettable()
Return false since this term represent a constant.

Specified by:
isSettable in interface InequalityTerm
Returns:
false.

isValueAcceptable

public boolean isValueAcceptable()
Check whether the current type of this term is acceptable, and return true if it is. A type is acceptable if it represents an instantiable object.

Specified by:
isValueAcceptable in interface InequalityTerm
Returns:
True if the current type is acceptable.

setValue

public void setValue(java.lang.Object e)
              throws IllegalActionException
Throw IllegalActionException since the value of this term cannot be changed.

Specified by:
setValue in interface InequalityTerm
Parameters:
e - An Object representing an element in the underlying CPO.
Throws:
IllegalActionException - Always thrown.
See Also:
getValue()

toString

public java.lang.String toString()
Return a string representation of this term.

Overrides:
toString in class java.lang.Object
Returns:
A String.