|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ptolemy.data.type.ObjectType
public class ObjectType
A type of tokens that contain arbitrary Java objects. An instance of this class specifies the Java class that the contents of the ObjectTokens of that type must be instances of.
A special type lattice is defined for variants of ObjectType. The top element of the elements in the type lattice is an ObjectType that does not specify any Java class as the class for the contents of its tokens. In the expression language, that element can be referred to with "object" or "object()". Any ObjectToken conforms to this type. A subtype of this type specifies a Java class. In the expression language, such a subtype can be defined with "object(string)", where string is a string (starting and ending with a quote). For example, the following expression refers to a variant of ObjectType to which only ObjectTokens containing atomic actors as their contents conform:
object("ptolemy.actor.AtomicActor")This ObjectType is a subtype of the most general ObjectType, "object". Furthermore, it is also a subtype of "object(\"ptolemy.kernel.Entity\")", and at the same time a supertype of "object(\"ptolemy.actor.lib.Const\")".
The bottom element of the type lattice is an artificial ObjectType
with ObjectType.BottomClass
as its specified Java class. In Java, the
class hierarchy does not form a lattice, so this artificial type is
needed to be the greatest lower bound for any two classes if one is
not a subclass of the other.
ObjectToken
Red (tfeng) |
Red (tfeng) |
Nested Class Summary | |
---|---|
static class |
ObjectType.BottomClass
An artificial Java class that serves as the bottom element. |
Field Summary | |
---|---|
private java.lang.Class<?> |
_class
The Java class specified in this type. |
private java.lang.Object |
_value
The actual Object, or null if the actual object is unknown. |
static ObjectType |
BOTTOM
The bottom element among all ObjectTypes. |
static ObjectType |
TOP
The top element among all ObjectTypes. |
Fields inherited from interface ptolemy.data.type.Type |
---|
HASH_INVALID, HASH_MAX |
Constructor Summary | |
---|---|
ObjectType()
Construct an ObjectType with null as the Java class specified in it. |
|
ObjectType(java.lang.Class<?> valueClass)
Construct an ObjectType with the given Java class as the class specified in it. |
|
ObjectType(java.lang.Object value,
java.lang.Class<?> valueClass)
Construct an ObjectType with the given Java class as the class specified in it. |
Method Summary | |
---|---|
protected Type |
_greatestLowerBound(Type type)
Compute the type representing the greatest lower bound of this type and the given type. |
private boolean |
_isLessThanOrEqualTo(ObjectType t1,
ObjectType t2)
Test whether the first type is less than or equal to the second in the type lattice. |
protected Type |
_leastUpperBound(Type type)
Compute the type representing the least upper bound of this type and the given type. |
Type |
add(Type rightArgumentType)
Return a new type which represents the type that results from adding a token of this type and a token of the given argument type. |
java.lang.Object |
clone()
Return a deep clone of this type. |
Token |
convert(Token token)
Convert the specified token into a token having the type represented by this object. |
Type |
divide(Type rightArgumentType)
Return a new type which represents the type that results from dividing a token of this type and a token of the given argument type. |
boolean |
equals(java.lang.Object object)
Determine if the argument represents the same type as this object. |
java.lang.Class<?> |
getTokenClass()
Return the class for tokens that this type represents. |
int |
getTypeHash()
Return a perfect hash for this type. |
java.lang.Object |
getValue()
Get the actual value. |
java.lang.Class<?> |
getValueClass()
Get the Java class specified in this type, of which the contents of ObjectTokens conforming to this type must be instances. |
int |
hashCode()
Return the hash code for this object. |
boolean |
isAbstract()
Return true if this type does not correspond to a single token class. |
boolean |
isCompatible(Type type)
Return true if this type does not correspond to a single token class. |
boolean |
isConstant()
Test if the argument type is compatible with this type. |
boolean |
isInstantiable()
Determine if this Type corresponds to an instantiable token class. |
boolean |
isSubstitutionInstance(Type type)
Return true if the specified type is a substitution instance of this type. |
Type |
modulo(Type rightArgumentType)
Return a new type which represents the type that results from moduloing a token of this type and a token of the given argument type. |
Type |
multiply(Type rightArgumentType)
Return a new type which represents the type that results from multiplying a token of this type and a token of the given argument type. |
Type |
one()
Return the type of the multiplicative identity for elements of this type. |
Type |
subtract(Type rightArgumentType)
Return a new type which represents the type that results from subtracting a token of this type and a token of the given argument type. |
java.lang.String |
toString()
Return a string describing this object. |
Type |
zero()
Return the type of the additive identity for elements of this type. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final ObjectType BOTTOM
public static final ObjectType TOP
private java.lang.Class<?> _class
private java.lang.Object _value
Constructor Detail |
---|
public ObjectType()
public ObjectType(java.lang.Class<?> valueClass)
valueClass
- The Java class.public ObjectType(java.lang.Object value, java.lang.Class<?> valueClass) throws IllegalActionException
value
- The actual object value, or null if the value is unknown.valueClass
- The Java class.
IllegalActionException
- If the value is not
an instance of valueClass.Method Detail |
---|
public Type add(Type rightArgumentType)
add
in interface Type
rightArgumentType
- The type to add to this type.
public java.lang.Object clone()
clone
in interface Type
clone
in class java.lang.Object
public Token convert(Token token) throws IllegalActionException
convert
in interface Type
token
- a token.
IllegalActionException
- If lossless conversion
cannot be done.public Type divide(Type rightArgumentType)
divide
in interface Type
rightArgumentType
- The type to add to this type.
public boolean equals(java.lang.Object object)
equals
in interface Type
equals
in class java.lang.Object
object
- A Type.
public java.lang.Class<?> getTokenClass()
ObjectToken
.
getTokenClass
in interface Type
public int getTypeHash()
getTypeHash
in interface Type
public java.lang.Object getValue()
public java.lang.Class<?> getValueClass()
public int hashCode()
hashCode
in class java.lang.Object
public boolean isAbstract()
isAbstract
in interface Type
public boolean isCompatible(Type type)
isCompatible
in interface Type
type
- The type to be checked
public boolean isConstant()
isConstant
in interface Type
public boolean isInstantiable()
isInstantiable
in interface Type
public boolean isSubstitutionInstance(Type type)
isSubstitutionInstance
in interface Type
type
- A Type.
public Type modulo(Type rightArgumentType)
modulo
in interface Type
rightArgumentType
- The type to add to this type.
public Type multiply(Type rightArgumentType)
multiply
in interface Type
rightArgumentType
- The type to add to this type.
public Type one()
one
in interface Type
public Type subtract(Type rightArgumentType)
subtract
in interface Type
rightArgumentType
- The type to add to this type.
public java.lang.String toString()
toString
in interface Type
toString
in class java.lang.Object
public Type zero()
zero
in interface Type
protected Type _greatestLowerBound(Type type)
type
- The given type.
protected Type _leastUpperBound(Type type)
type
- The given type.
private boolean _isLessThanOrEqualTo(ObjectType t1, ObjectType t2)
t1
- The first class.t2
- The second class.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |