Class DefaultRecord

java.lang.Object
org.apache.sis.util.iso.DefaultRecord
All Implemented Interfaces:
Serializable, org.opengis.util.Record

public class DefaultRecord extends Object implements org.opengis.util.Record, Serializable
A list of logically related elements as (name, value) pairs in a dictionary. By definition, all record fields have a [1 … 1] multiplicity (for a more flexible construct, see features). Since all fields are expected to be assigned a value, the initial values on DefaultRecord instantiation are unspecified. Some may be null, or some may be zero.

Limitations

  • Multi-threading: DefaultRecord instances are not thread-safe. Synchronization, if needed, shall be done externally by the caller.
  • Serialization: this class is serializable if the associated RecordType and all values are also serializable. Note in particular that DefaultRecordSchema is currently not serializable, so users wanting serialization may need to define their own schema implementation.
Since:
0.5
Version:
1.1
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private final class 
    The set of map entries to be returned by DefaultRecord.getAttributes().entrySet().
    private final class 
    A single entry in the map returned by DefaultRecord.getAttributes().
    private final class 
    The iterator to be returned by DefaultRecord.getAttributes().entrySet().iterator().
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final RecordDefinition
    The type definition of this record.
    private static final long
    For cross-version compatibility.
    private Object
    The record values in an array.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Constructs an initially empty record expecting exactly one value as a string.
     
    DefaultRecord(org.opengis.util.Record record)
    Creates a new record initialized to a shallow copy of the given record.
     
    DefaultRecord(org.opengis.util.RecordType type)
    Creates a new record for the given record type.
  • Method Summary

    Modifier and Type
    Method
    Description
    castOrCopy(org.opengis.util.Record other)
    Returns a SIS implementation with the name and fields of the given arbitrary implementation.
    boolean
    equals(Object object)
    Compares this record with the given object for equality.
    Map<org.opengis.util.MemberName,Object>
    Deprecated.
    Renamed getFields() for consistency with the 2015 revision of ISO 19103 standard.
    Map<org.opengis.util.MemberName,Object>
    Returns the dictionary of all (name, value) pairs in this record.
    org.opengis.util.RecordType
    Returns the type definition of this record.
    private String
    Returns the record value as a string.
    int
    Returns a hash code value for this record.
    locate(org.opengis.util.MemberName name)
    Returns the value for an attribute of the specified name.
    void
    set(org.opengis.util.MemberName name, Object value)
    Sets the value for the attribute of the specified name.
    void
    setAll(Object... newValues)
    Sets all attribute values in this record, in attribute order.
    private void
    Sets the record value as a string.
    Returns a string representation of this record.

    Methods inherited from class java.lang.Object

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

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • definition

      final RecordDefinition definition
      The type definition of this record. Cannot be null.
    • values

      private Object values
      The record values in an array. May be an array of primitive type for compactness, which is why the type is not Object[]. Should never be null, except temporarily during XML unmarshalling.
  • Constructor Details

    • DefaultRecord

      public DefaultRecord(org.opengis.util.RecordType type)
      Creates a new record for the given record type. The initial values are unspecified - they may be null or zero. Callers can assign values by a call to setAll(Object[]).
      Parameters:
      type - the type definition of the new record.
    • DefaultRecord

      public DefaultRecord(org.opengis.util.Record record)
      Creates a new record initialized to a shallow copy of the given record. The fields contained in the given record are not recursively copied.
      Parameters:
      record - the record to copy (cannot be null).
      Since:
      0.8
    • DefaultRecord

      private DefaultRecord()
      Constructs an initially empty record expecting exactly one value as a string. See setValue(String) for a description of the supported XML content.
  • Method Details

    • castOrCopy

      public static DefaultRecord castOrCopy(org.opengis.util.Record other)
      Returns a SIS implementation with the name and fields of the given arbitrary implementation. This method performs the first applicable action in the following choices:
      • If the given object is null, then this method returns null.
      • Otherwise if the given object is already an instance of DefaultRecord, then it is returned unchanged.
      • Otherwise a new DefaultRecord instance is created using the copy constructor and returned. Note that this is a shallow copy operation, since the fields contained in the given object are not recursively copied.
      Parameters:
      other - The object to get as a SIS implementation, or null if none.
      Returns:
      A SIS implementation containing the fields of the given object (may be the given object itself), or null if the argument was null.
      Since:
      0.8
    • getRecordType

      public org.opengis.util.RecordType getRecordType()
      Returns the type definition of this record.
      Specified by:
      getRecordType in interface org.opengis.util.Record
      Returns:
      the type definition of this record.
    • getAttributes

      @Deprecated public Map<org.opengis.util.MemberName,Object> getAttributes()
      Deprecated.
      Renamed getFields() for consistency with the 2015 revision of ISO 19103 standard.
      Returns the dictionary of all (name, value) pairs in this record. This method returns a view which will delegate all get and put operations to the locate(MemberName) and set(MemberName, Object) methods respectively.
      Specified by:
      getAttributes in interface org.opengis.util.Record
      Returns:
      the dictionary of all (name, value) pairs in this record.
      See Also:
      • RecordType.getMemberTypes()
    • getFields

      public Map<org.opengis.util.MemberName,Object> getFields()
      Returns the dictionary of all (name, value) pairs in this record. This method returns a view which will delegate all get and put operations to the locate(MemberName) and set(MemberName, Object) methods respectively.
      Returns:
      the dictionary of all (name, value) pairs in this record.
      Since:
      1.1
    • locate

      public Object locate(org.opengis.util.MemberName name)
      Returns the value for an attribute of the specified name.
      Specified by:
      locate in interface org.opengis.util.Record
      Parameters:
      name - the name of the attribute to lookup.
      Returns:
      the value of the attribute for the given name.
    • set

      public void set(org.opengis.util.MemberName name, Object value)
      Sets the value for the attribute of the specified name.
      Specified by:
      set in interface org.opengis.util.Record
      Parameters:
      name - the name of the attribute to modify.
      value - the new value for the attribute.
      Throws:
      IllegalArgumentException - if the given name is not a field of this record.
      ClassCastException - if the given value is not an instance of the expected type for this record.
    • setAll

      public void setAll(Object... newValues)
      Sets all attribute values in this record, in attribute order.
      Parameters:
      newValues - the attribute values.
      Throws:
      IllegalArgumentException - if the given number of values does not match the expected number.
      ClassCastException - if a value is not an instance of the expected type for this record.
    • equals

      public boolean equals(Object object)
      Compares this record with the given object for equality.
      Overrides:
      equals in class Object
      Parameters:
      object - the object to compare with this record for equality.
      Returns:
      true if both objects are equal.
    • hashCode

      public int hashCode()
      Returns a hash code value for this record.
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for this record.
    • toString

      public String toString()
      Returns a string representation of this record. 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.
    • getValue

      private String getValue()
      Returns the record value as a string.
    • setValue

      private void setValue(String value)
      Sets the record value as a string. This method is invoked at unmarshalling time. A record can be anything, but usages that we have seen so far write a character sequence or a code list. Examples:
      See Also: