ptolemy.data.type
Class TypeLattice.TheTypeLattice

java.lang.Object
  extended by ptolemy.data.type.TypeLattice.TheTypeLattice
All Implemented Interfaces:
CPO
Enclosing class:
TypeLattice

private static class TypeLattice.TheTypeLattice
extends java.lang.Object
implements CPO


Field Summary
private  DirectedAcyclicGraph _basicLattice
           
 
Fields inherited from interface ptolemy.graph.CPO
HIGHER, INCOMPARABLE, LOWER, SAME
 
Constructor Summary
private TypeLattice.TheTypeLattice()
           
 
Method Summary
private  Type _toRepresentative(Type t)
           
 java.lang.Object bottom()
          Return the bottom element of the type lattice, which is UNKNOWN.
 int compare(java.lang.Object t1, java.lang.Object t2)
          Compare two types in the type lattice.
 java.lang.Object[] downSet(java.lang.Object e)
          Throw an exception.
 java.lang.Object greatestElement(java.lang.Object[] subset)
          Return the greatest type of a set of types, or null if the greatest one does not exist.
 java.lang.Object greatestLowerBound(java.lang.Object[] subset)
          Return the greatest lower bound of a subset.
 java.lang.Object greatestLowerBound(java.lang.Object t1, java.lang.Object t2)
          Return the greatest lower bound of two types.
 boolean isLattice()
          Return true.
 java.lang.Object leastElement(java.lang.Object[] subset)
          Return the least type of a set of types, or null if the least one does not exist.
 java.lang.Object leastUpperBound(java.lang.Object[] subset)
          Return the least upper bound of a subset.
 java.lang.Object leastUpperBound(java.lang.Object t1, java.lang.Object t2)
          Return the least upper bound of two types.
 java.lang.Object top()
          Return the top element of the type lattice, which is General.
 java.lang.Object[] upSet(java.lang.Object e)
          Throw an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_basicLattice

private DirectedAcyclicGraph _basicLattice
Constructor Detail

TypeLattice.TheTypeLattice

private TypeLattice.TheTypeLattice()
Method Detail

bottom

public java.lang.Object bottom()
Return the bottom element of the type lattice, which is UNKNOWN.

Specified by:
bottom in interface CPO
Returns:
The Type object representing UNKNOWN.

compare

public int compare(java.lang.Object t1,
                   java.lang.Object t2)
Compare two types in the type lattice. The arguments must be instances of 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 the first argument is lower than, equal to, higher than, or incomparable with the second argument in the type hierarchy, respectively.

Specified by:
compare in interface CPO
Parameters:
t1 - an instance of Type.
t2 - an instance of Type.
Returns:
An integer.
Throws:
java.lang.IllegalArgumentException - If one or both arguments are not instances of Type.

downSet

public java.lang.Object[] downSet(java.lang.Object e)
Throw an exception. This operation is not supported since the type lattice is infinite,

Specified by:
downSet in interface CPO
Parameters:
e - An Object representing an element in this CPO.
Returns:
An array of Objects representing the elements in the down-set of the specified element.
Throws:
java.lang.UnsupportedOperationException - Always thrown.

greatestLowerBound

public java.lang.Object greatestLowerBound(java.lang.Object t1,
                                           java.lang.Object t2)
Return the greatest lower bound of two types.

Specified by:
greatestLowerBound in interface CPO
Parameters:
t1 - an instance of Type.
t2 - an instance of Type.
Returns:
an instance of Type.
Throws:
java.lang.IllegalArgumentException - If one or both of the specified arguments are not instances of Type.

greatestLowerBound

public java.lang.Object greatestLowerBound(java.lang.Object[] subset)
Return the greatest lower bound of a subset.

Specified by:
greatestLowerBound in interface CPO
Parameters:
subset - an array of Types.
Returns:
an instance of Type.

greatestElement

public java.lang.Object greatestElement(java.lang.Object[] subset)
Return the greatest type of a set of types, or null if the greatest one does not exist. Note, that this only returns an element within the subset. To find the least upper bound of a set, see leastUpperBound(Object[]).

Specified by:
greatestElement in interface CPO
Parameters:
subset - an array of Types.
Returns:
A Type or null.

isLattice

public boolean isLattice()
Return true.

Specified by:
isLattice in interface CPO
Returns:
true.

leastElement

public java.lang.Object leastElement(java.lang.Object[] subset)
Return the least type of a set of types, or null if the least one does not exist. Note, that this only returns an element within the subset. To find the greatest lower bound of a set, see greatestLowerBound(Object[]).

Specified by:
leastElement in interface CPO
Parameters:
subset - an array of Types.
Returns:
A Type or null.

leastUpperBound

public java.lang.Object leastUpperBound(java.lang.Object t1,
                                        java.lang.Object t2)
Return the least upper bound of two types.

Specified by:
leastUpperBound in interface CPO
Parameters:
t1 - an instance of Type.
t2 - an instance of Type.
Returns:
an instance of Type.

leastUpperBound

public java.lang.Object leastUpperBound(java.lang.Object[] subset)
Return the least upper bound of a subset.

Specified by:
leastUpperBound in interface CPO
Parameters:
subset - an array of Types.
Returns:
an instance of Type.

top

public java.lang.Object top()
Return the top element of the type lattice, which is General.

Specified by:
top in interface CPO
Returns:
The Type object representing General.

upSet

public java.lang.Object[] upSet(java.lang.Object e)
Throw an exception. This operation is not supported since the type lattice is infinite, this operation is not supported.

Specified by:
upSet in interface CPO
Parameters:
e - An Object representing an element in this CPO.
Returns:
An array of Objects representing the elements in the up-set of the specified element.
Throws:
java.lang.UnsupportedOperationException - Always thrown.

_toRepresentative

private Type _toRepresentative(Type t)