Class 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 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 class java.lang.Object
        Returns:
        True if equal.
      • hashCode

        public int hashCode()
        Get the hash code.
        Overrides:
        hashCode in class java.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.