Class RecordDefinition

java.lang.Object
org.apache.sis.util.iso.RecordDefinition
Direct Known Subclasses:
DefaultRecordType, RecordDefinition.Adapter

abstract class RecordDefinition extends Object
Holds a Record definition in a way more convenient for Apache SIS than what the RecordType interface provides.

Serialization

This base class is intentionally not serializable, and all private fields are marked as transient for making this decision more visible. This is because the internal details of this class are quite arbitrary, so we do not want to expose them in serialization for compatibility reasons. Furthermore, some information are redundant, so a serialization performed by subclasses may be more compact. Serialization of all necessary data shall be performed by subclasses, and the transient fields shall be reconstructed by a call to computeTransientFields(Map).
Since:
0.5
Version:
1.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static final class 
    RecordDefinition implementation used as a fallback when the user supplied RecordType is not an instance of DefaultRecordType.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private Class<?>
    The common parent of all value classes.
    private Map<org.opengis.util.MemberName,Integer>
    Indices of field names.
    private org.opengis.util.MemberName[]
    Field names.
    private Class<?>[]
    Classes of expected values, or null if there is no restriction.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) final Class<?>
    Returns the common parent of all value classes.
    (package private) final org.opengis.util.Type[]
    computeTransientFields(Map<? extends org.opengis.util.MemberName,? extends org.opengis.util.Type> fieldTypes)
    Invoked on construction or deserialization for computing the transient fields.
    (package private) final Map<org.opengis.util.MemberName,Integer>
    Read-only access to the map of field indices.
    (package private) final org.opengis.util.MemberName
    getName(int index)
    Returns the name of the field at the given index.
    (package private) abstract org.opengis.util.RecordType
    Returns the record type for which this object is a definition.
    (package private) final Class<?>
    getValueClass(int index)
    Returns the expected class of values in the given column, or null if unspecified.
    (package private) final Integer
    indexOf(org.opengis.util.MemberName fieldName)
    Returns the index of the given name, or null if none.
    (package private) final int
    Returns the number of elements in records.
    Returns a string representation of this object.
    (package private) final String
    toString(String head, Object values)
    Returns a string representation of a Record or RecordType.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • fieldIndices

      private transient Map<org.opengis.util.MemberName,Integer> fieldIndices
      Indices of field names. Created on construction or deserialization, and shall be considered final and unmodifiable after that point.
      See Also:
    • fieldNames

      private transient org.opengis.util.MemberName[] fieldNames
      Field names. Created on construction or deserialization, and shall be considered final and unmodifiable after that point.
    • valueClasses

      private transient Class<?>[] valueClasses
      Classes of expected values, or null if there is no restriction. Created on construction or deserialization, and shall be considered final and unmodifiable after that point.
    • baseValueClass

      private transient Class<?> baseValueClass
      The common parent of all value classes. May be a primitive type.
  • Constructor Details

    • RecordDefinition

      RecordDefinition()
      Creates a new instance. Subclasses shall invoke computeTransientFields(Map) in their constructor.
  • Method Details

    • getRecordType

      abstract org.opengis.util.RecordType getRecordType()
      Returns the record type for which this object is a definition.
    • computeTransientFields

      final org.opengis.util.Type[] computeTransientFields(Map<? extends org.opengis.util.MemberName,? extends org.opengis.util.Type> fieldTypes)
      Invoked on construction or deserialization for computing the transient fields.
      Parameters:
      fieldTypes - the (name, type) pairs in this record type.
      Returns:
      the values in the given map. This information is not stored in RecordDefinition because not needed by this class, but the DefaultRecordType subclass will store it.
    • baseValueClass

      final Class<?> baseValueClass()
      Returns the common parent of all value classes. May be a primitive type.
    • fieldIndices

      final Map<org.opengis.util.MemberName,Integer> fieldIndices()
      Read-only access to the map of field indices.
    • size

      final int size()
      Returns the number of elements in records.
    • indexOf

      final Integer indexOf(org.opengis.util.MemberName fieldName)
      Returns the index of the given name, or null if none.
    • getName

      final org.opengis.util.MemberName getName(int index)
      Returns the name of the field at the given index.
    • getValueClass

      final Class<?> getValueClass(int index)
      Returns the expected class of values in the given column, or null if unspecified.
    • toString

      public String toString()
      Returns a string representation of this object. The string representation is for debugging purpose and may change in any future SIS version.
      Overrides:
      toString in class Object
      Returns:
      a string representation of this record type.
    • toString

      final String toString(String head, Object values)
      Returns a string representation of a Record or RecordType.
      Parameters:
      head - either "Record" or "RecordType" or null.
      values - the values as an array, or null for writing the types instead.
      Returns:
      the string representation.