Package jadex.rules.state
Class OAVTypeModel
- java.lang.Object
-
- jadex.rules.state.OAVTypeModel
-
public class OAVTypeModel extends java.lang.Object
A type model contains all known types. Type models must be associated with a state which uses the type model to ensure that no objects of undefined types are defined.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.ClassLoader
classloader
The class loader.protected java.lang.String
name
The model name.protected static java.lang.Class[]
PCL
The argument types for property change listener adding/removal (cached for speed).protected OAVTypeModel[]
tmodels
The contained type models.protected java.util.Map
types
All object types (name -> type).
-
Constructor Summary
Constructors Constructor Description OAVTypeModel(java.lang.String name)
Create a new model.OAVTypeModel(java.lang.String name, java.lang.ClassLoader classloader)
Create a new model.OAVTypeModel(java.lang.String name, java.lang.ClassLoader classloader, OAVTypeModel[] subtypemodels)
Create a new model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTypeModel(OAVTypeModel tmodel)
Adds a type model to the state.boolean
contains(OAVObjectType type)
Test if a type is contained.OAVJavaType
createJavaType(java.lang.Class clazz, java.lang.String kind)
Create a Java type.OAVObjectType
createType(java.lang.String name)
Create a type.OAVObjectType
createType(java.lang.String name, OAVObjectType supertype)
Create a type.boolean
equals(java.lang.Object object)
Test if two types are equal.java.lang.ClassLoader
getClassLoader()
Get the class loader.protected OAVObjectType
getDeepType(java.lang.String typename)
Search for a type in this model and all submodels.OAVTypeModel
getDirectTypeModel()
Get a copy of the typemodel without contained models.OAVJavaType
getJavaType(java.lang.Class clazz)
Get a type for a java class.java.lang.String
getName()
Get the name.OAVObjectType
getObjectType(java.lang.Class clazz)
Get a type per name.OAVObjectType
getObjectType(java.lang.String typename)
Get a type per name.OAVTypeModel[]
getTypeModels()
Get the contained typemodels.int
hashCode()
Get the hash code.boolean
removeType(OAVObjectType type)
Remove an existing type.void
setClassLoader(java.lang.ClassLoader classloader)
Set the classloader.
-
-
-
Field Detail
-
PCL
protected static java.lang.Class[] PCL
The argument types for property change listener adding/removal (cached for speed).
-
name
protected java.lang.String name
The model name.
-
types
protected java.util.Map types
All object types (name -> type).
-
tmodels
protected OAVTypeModel[] tmodels
The contained type models.
-
classloader
protected java.lang.ClassLoader classloader
The class loader.
-
-
Constructor Detail
-
OAVTypeModel
public OAVTypeModel(java.lang.String name)
Create a new model.- Parameters:
name
- The name.
-
OAVTypeModel
public OAVTypeModel(java.lang.String name, java.lang.ClassLoader classloader)
Create a new model.- Parameters:
name
- The name.
-
OAVTypeModel
public OAVTypeModel(java.lang.String name, java.lang.ClassLoader classloader, OAVTypeModel[] subtypemodels)
Create a new model.- Parameters:
name
- The name.
-
-
Method Detail
-
createType
public OAVObjectType createType(java.lang.String name)
Create a type. Creates a type that can be used to create objects.- Parameters:
name
- The type name.- Returns:
- The type.
-
createType
public OAVObjectType createType(java.lang.String name, OAVObjectType supertype)
Create a type. Creates a type that can be used to create objects.- Parameters:
name
- The type name.supertype
- The supertype.- Returns:
- The type.
-
createJavaType
public OAVJavaType createJavaType(java.lang.Class clazz, java.lang.String kind)
Create a Java type.- Parameters:
clazz
- The java class.kind
- The kind of type as defined in OAVJavaType.- Returns:
- The new type.
-
removeType
public boolean removeType(OAVObjectType type)
Remove an existing type. Deletes the type from the state.- Parameters:
type
- The object type.- Returns:
- True, if could be removed.
-
addTypeModel
public void addTypeModel(OAVTypeModel tmodel)
Adds a type model to the state.- Parameters:
tmodel
- The type model.
-
contains
public boolean contains(OAVObjectType type)
Test if a type is contained.- Parameters:
type
- The type.- Returns:
- True, if type is part of type model.
-
getObjectType
public OAVObjectType getObjectType(java.lang.Class clazz)
Get a type per name. Creates implicit java types on the fly. TODO: Unify with getObjectType(String typename)- Parameters:
typename
- The type name.- Returns:
- The type if contained.
- Throws:
java.lang.RuntimeException
- when the type is not found.
-
getObjectType
public OAVObjectType getObjectType(java.lang.String typename)
Get a type per name. Creates implicit java types on the fly. TODO: Unify with getObjectType(Class clazz)- Parameters:
typename
- The type name.- Returns:
- The type if contained.
- Throws:
java.lang.RuntimeException
- when the type is not found.
-
getName
public java.lang.String getName()
Get the name.- Returns:
- The name.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Get the class loader.- Returns:
- The class loader.
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader classloader)
Set the classloader.- Parameters:
classloader
- The classloader to set.
-
equals
public boolean equals(java.lang.Object object)
Test if two types are equal.- Overrides:
equals
in classjava.lang.Object
- Returns:
- True if equal.
-
hashCode
public int hashCode()
Get the hash code.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- The hashcode.
-
getJavaType
public OAVJavaType getJavaType(java.lang.Class clazz)
Get a type for a java class.
-
getTypeModels
public OAVTypeModel[] getTypeModels()
Get the contained typemodels.
-
getDirectTypeModel
public OAVTypeModel getDirectTypeModel()
Get a copy of the typemodel without contained models.
-
getDeepType
protected OAVObjectType getDeepType(java.lang.String typename)
Search for a type in this model and all submodels.- Returns:
- null if not found.
-
-