Class DefaultRecord

Object
DefaultRecord
All Implemented Interfaces:
Serializable, Record

public class DefaultRecord extends Object implements 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 Default­Record instantiation are unspecified. Some may be null, or some may be zero.

Limitations

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

Defined in the sis-metadata module

  • Constructor Details

    • DefaultRecord

      public DefaultRecord(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 set­All(Object[]).
      Parameters:
      type - the type definition of the new record.
    • DefaultRecord

      public DefaultRecord(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 (can not be null).
      Since:
      0.8
  • Method Details

    • castOrCopy

      public static DefaultRecord castOrCopy(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 Default­Record, then it is returned unchanged.
      • Otherwise a new Default­Record 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 RecordType getRecordType()
      Returns the type definition of this record.
      Specified by:
      get­Record­Type in interface Record
      Returns:
      the type definition of this record.
    • getAttributes

      @Deprecated public Map<MemberName,Object> getAttributes()
      Deprecated.
      Renamed get­Fields() 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(Member­Name) and set(Member­Name, Object) methods respectively.
      Specified by:
      get­Attributes in interface Record
      Returns:
      the dictionary of all (name, value) pairs in this record.
      See Also:
    • getFields

      public Map<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(Member­Name) and set(Member­Name, Object) methods respectively.
      Returns:
      the dictionary of all (name, value) pairs in this record.
      Since:
      1.1
    • locate

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

      public void set(MemberName name, Object value)
      Sets the value for the attribute of the specified name.
      Specified by:
      set in interface Record
      Parameters:
      name - the name of the attribute to modify.
      value - the new value for the attribute.
      Throws:
      Illegal­Argument­Exception - if the given name is not a field of this record.
      Class­Cast­Exception - 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:
      new­Values - the attribute values.
      Throws:
      Illegal­Argument­Exception - if the given number of values does not match the expected number.
      Class­Cast­Exception - 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:
      hash­Code 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:
      to­String in class Object
      Returns:
      a string representation of this record.