Class Schema

java.lang.Object
io.permazen.core.Schema

public class Schema extends Object
Reflects one Schema recorded in a Database as seen by a particular Transaction.

Instances are immutable and thread safe.

  • Method Details

    • isEmpty

      public boolean isEmpty()
      Determine whether this schema is empty, i.e., contains zero object types.

      Empty schemas are not recorded in the database.

      Returns:
      true if empty, otherwise false
    • getSchemaBundle

      public SchemaBundle getSchemaBundle()
      Get the schema bundle that this instance is a member of.
      Returns:
      the containing schema bundle
    • getSchemaIndex

      public int getSchemaIndex()
      Get the schema index associated with this instance.
      Returns:
      schema index, or zero if this is the empty schema
    • getSchemaId

      public SchemaId getSchemaId()
      Get the schema ID associated with this instance.
      Returns:
      schema ID
    • getSchemaModel

      public SchemaModel getSchemaModel()
      Get the original SchemaModel on which this instance is based as it is recorded in the database.

      Equivalent to: getSchemaModel(boolean)(false).

      Returns:
      schema model
    • getSchemaModel

      public SchemaModel getSchemaModel(boolean withStorageIds)
      Get the SchemaModel on which this instance is based, optionally including explicit storage ID assignments.

      If withStorageIds is true, then all of the schema items in the returned model will have non-zero storage ID's reflecting their storage ID assignments in the database.

      Parameters:
      withStorageIds - true to include all storage ID assignments, false for the original model
      Returns:
      schema model with storage ID assignments
    • getObjTypes

      public NavigableMap<String,ObjType> getObjTypes()
      Get all of the ObjTypes that constitute this schema, indexed by type name.
      Returns:
      unmodifiable mapping from type name to ObjType
    • getObjType

      public ObjType getObjType(String typeName)
      Get the ObjType in this schema with the given name.
      Parameters:
      typeName - object type name
      Returns:
      the corresponding ObjType
      Throws:
      UnknownTypeException - if no such ObjType exists
      IllegalArgumentException - if typeName is null
    • getObjType

      public ObjType getObjType(int storageId)
      Get the ObjType in this schema with the given storage ID.
      Parameters:
      storageId - object type storage ID
      Returns:
      the corresponding ObjType
      Throws:
      UnknownTypeException - if no such ObjType exists
      IllegalArgumentException - if storageId is invalid
    • toString

      public String toString()
      Overrides:
      toString in class Object