public class ObjectType extends StructuredType implements java.lang.Cloneable
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| Modifier and Type | Class and Description |
|---|---|
static class |
ObjectType.BottomClass
An artificial Java class that serves as the bottom element.
|
| Modifier and Type | Field and Description |
|---|---|
static ObjectType |
BOTTOM
The bottom element among all ObjectTypes.
|
static ObjectType |
TOP
The top element among all ObjectTypes.
|
MAXDEPTHBOUNDHASH_INVALID| Constructor and Description |
|---|
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.
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
_compare(StructuredType type)
Compare this type with the specified type.
|
protected StructuredType |
_getRepresentative()
Return a static instance of this object 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 a deep clone of this type.
|
Token |
convert(Token token)
Convert the specified token into a token having the type
represented by this object.
|
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.
|
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.
|
void |
initialize(Type type)
Ignore, as this type does not have elements.
|
boolean |
isAbstract()
Return true if this type does not correspond to a single token
class.
|
boolean |
isCompatible(Type type)
Return true if the specified type is less than or equal to this type.
|
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.
|
java.lang.String |
toString()
Return a string describing this object.
|
add, depth, divide, getTypeHash, modulo, multiply, one, subtract, updateType, zeropublic static final ObjectType BOTTOM
public static final ObjectType TOP
BaseType.OBJECT so that
code generation can use "xxx == BaseType.OBJECT".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.public java.lang.Object clone()
clone in interface Typeclone in class StructuredTypepublic Token convert(Token token) throws IllegalActionException
convert in interface Typetoken - a token.IllegalActionException - If lossless conversion
cannot be done.public boolean equals(java.lang.Object object)
public java.lang.Class<?> getTokenClass()
ObjectToken.getTokenClass in interface Typepublic java.lang.Object getValue()
public java.lang.Class<?> getValueClass()
public int hashCode()
hashCode in class java.lang.Objectpublic void initialize(Type type)
initialize in class StructuredTypetype - The type to initialize unknown elements to.public boolean isAbstract()
isAbstract in interface TypeisAbstract in class StructuredTypepublic boolean isCompatible(Type type)
isCompatible in interface Typetype - The type to be checkedpublic boolean isConstant()
isConstant in interface Typepublic boolean isInstantiable()
isInstantiable in interface Typepublic boolean isSubstitutionInstance(Type type)
isSubstitutionInstance in interface Typetype - A Type.public java.lang.String toString()
protected int _compare(StructuredType type)
_compare in class StructuredTypetype - a StructuredType.java.lang.IllegalArgumentException - If the specified type is
not the same structured type as this one.protected StructuredType _getRepresentative()
_getRepresentative in class StructuredTypeprotected StructuredType _greatestLowerBound(StructuredType type)
_greatestLowerBound in class StructuredTypetype - a StructuredType.java.lang.IllegalArgumentException - If the specified type is
not the same structured type as this one.protected StructuredType _leastUpperBound(StructuredType type)
_leastUpperBound in class StructuredTypetype - a StructuredType.java.lang.IllegalArgumentException - If the specified type is
not the same structured type as this one.