ptolemy.data.type
Class TypeConstant

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

public class TypeConstant
extends java.lang.Object
implements InequalityTerm

An InequalityTerm that encapsulate 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,v 1.19 2004/04/13 03:22:41 cxh Exp $
Author:
Yuhong Xiong
See Also:
InequalityTerm
Accepted Rating:
Red (cxh)
Proposed Rating:
Red (yuhong)

Constructor Summary
TypeConstant(Type type)
          Construct a TypeConstant.
 
Method Summary
 java.lang.Object getAssociatedObject()
          Return null.
 java.lang.Object getValue()
          Return the constant type represented by this term.
 InequalityTerm[] getVariables()
          Return an array of variables contained in this term.
 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypeConstant

public TypeConstant(Type type)
Construct a TypeConstant.

Parameters:
type - An instance of Type.
Method Detail

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.

getVariables

public InequalityTerm[] getVariables()
Description copied from interface: InequalityTerm
Return an array of variables contained in this term. If this term is a constant, return an array of size zero; if this term is a variable, return an array of size one that contains this variable; if this term is a function, return an array containing all the variables in the function.

Specified by:
getVariables in interface InequalityTerm
Returns:
An array of InequalityTerms

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.

toString

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

Returns:
A String.