Class Type


public class Type extends StorableObject
The object type initializer. This class maps type and Java class mappings found in the storage to the actual storage type registry. Since this type mapping class is itself uses the storage object initialization feature, it will register itself twice (once for bootstrapping and once from the proper storage file).
Version:
1.0
  • Field Details

    • KEY_ALIAS

      public static final String KEY_ALIAS
      The dictionary key for the optional legacy type id.
      See Also:
    • KEY_DESCRIPTION

      public static final String KEY_DESCRIPTION
      The dictionary key for the description text.
      See Also:
    • KEY_REMOTE

      public static final String KEY_REMOTE
      The dictionary key for the remote-only flag.
      See Also:
    • KEY_INITIALIZER

      public static final String KEY_INITIALIZER
      The dictionary key for the initializer class name.
      See Also:
    • KEY_PROPERTY

      public static final String KEY_PROPERTY
      The dictionary key for the property array.
      See Also:
    • PATH

      public static final Path PATH
      The connection object storage path.
  • Constructor Details

    • Type

      public Type(String id, String type, Dict dict)
      Creates a new type mapping from a serialized representation.
      Parameters:
      id - the object identifier
      type - the object type name
      dict - the serialized representation
  • Method Details

    • all

      public static Stream<Type> all(Storage storage)
      Returns a stream of all types found in the storage.
      Parameters:
      storage - the storage to search
      Returns:
      a stream of type instances found
    • find

      public static Type find(Storage storage, String id)
      Searches for a specific type in the storage.
      Parameters:
      storage - the storage to search in
      id - the type identifier
      Returns:
      the type found, or null if not found
    • classFor

      public static Class<?> classFor(Storage storage, Dict dict)
      Returns the initializer class for creating a Java object. If no object type, initializer or className property was found, null is returned. This method will lookup the corresponding type in storage before checking for a 'className' property in the object dictionary data.
      Parameters:
      storage - the storage to use for type lookups
      dict - the object dictionary data
      Returns:
      the Java object class, or null if not found
    • constructorFor

      public static Constructor<?> constructorFor(Storage storage, Dict dict)
      Returns the constructor for creating a Java object. If no Java class was found or the constructor signature isn't correct, null is returned.
      Parameters:
      storage - the storage to use for type lookups
      dict - the object dictionary data
      Returns:
      the Java object constructor, or null if not found
      See Also:
    • loadClass

      protected static Class<?> loadClass(String className, String objId)
      Loads and returns a specified class.
      Parameters:
      className - the fully qualified class name to load
      objId - the object identifier for logging
      Returns:
      the class found in the class loader, or null if not found
    • init

      protected void init() throws StorageException
      Initializes this type mapping by registering it via the methods in the Storage class.
      Overrides:
      init in class StorableObject
      Throws:
      StorageException - if the initialization failed
    • alias

      public String alias()
      Returns the optional legacy type id (or alias).
      Returns:
      the type alias, or an empty string
    • description

      public String description()
      Returns the type description.
      Returns:
      the type description
    • remote

      public boolean remote()
      Returns the remote-only flag. Remote objects are only initialized client-side, so no corresponding Java class exist.
      Returns:
      true if objects are remote-only, or false otherwise (default)
    • initializer

      public Class<?> initializer()
      Returns the type initializer class.
      Returns:
      the type initializer class
    • properties

      public Array properties()
      Returns an array of type properties. Each property should be a dictionary object containing property information. Note that parent type properties are normally also applicable, but must be retrieved separately.
      Returns:
      the array of type properties, or an empty array if it didn't exist
    • parentType

      public Type parentType(Storage storage)
      Searches for the parent type in the type hierarchy. A parent type normally declares additional properties that may or may not be applicable also for this type.
      Parameters:
      storage - the storage to search in
      Returns:
      the parent type, or null if not found