Interface Record


@UML(identifier="Record", specification=ISO_19103) public interface Record
A list of logically related fields as (name, value) pairs in a dictionary. A Record is an instance of an RecordType. For example, a Record may be a row in a table described by a RecordType.

Relationship with Java Record class

This interface serves a purpose similar to the Record abstract class provided by the standard Java platform, but is used in a different context. The standard Java Record class provides static records (i.e., with structure defined at compile time), while this GeoAPI Record interfaces provides dynamic records. The former is more convenient, efficient and type-safe, while the latter is the only option when the record structure is not known in advance, for example when it is determined by the content of a data file being read. If interoperability between the two models is desired, a GeoAPI Record implementation could delegate all operations to a wrapped Java Record using RecordComponent.
Since:
2.1
See Also:
  • Method Details

    • getRecordType

      Returns the type definition of this record. All fields named in this record must be defined in the returned record type. In other words, the following assertion must holds:
      Set<MemberName> members = getRecordType().getMembers();
      Set<MemberName> fields  = getFields().keySet();
      assert members.containsAll(fields);
      
      This association is optional according ISO 19103. But implementers are encouraged to provide a value in all cases.
      Comparison with Java reflection: if we think about this Record as equivalent to an Object instance, then this method can be though as the equivalent of the Java Object.getClass() method.
      Returns:
      the type definition of this record. May be null.
    • getFields

      Returns the dictionary of all (name, value) pairs in this record. The returned map should not allows entry addition or removal. It may allows the replacement of values for existing keys only.
      Returns:
      the dictionary of all (name, value) pairs in this record.
      Since:
      3.1
      See Also:
    • getAttributes

      Deprecated.
      Renamed getFields().
      Returns the dictionary of all (name, value) pairs in this record. The returned map should not allows key addition or removal. It may allows the replacement of values for existing keys only.
      Returns:
      the dictionary of all (name, value) pairs in this record.
      See Also:
    • locate

      Deprecated.
      This method has been removed in ISO 19103:2015. The same functionality is available with getFields().get(name).
      Returns the value for a field of the specified name. This is functionally equivalent to getFields().get(name). The type of the returned object is given by getRecordType().locate(name).
      Parameters:
      name - the name of the field to lookup.
      Returns:
      the value of the field for the given name.
      See Also:
    • set

      @Deprecated default void set(MemberName name, Object value) throws UnsupportedOperationException
      Deprecated.
      Use getFields().put(name, value) instead.
      Sets the value for the field of the specified name. This is functionally equivalent to getFields().put(name, value). Remind that name keys are constrained to record type members only.
      Parameters:
      name - the name of the field to modify.
      value - the new value for the field.
      Throws:
      UnsupportedOperationException - if this record is not modifiable.
      Departure from OGC/ISO abstract specification:
      Extension for convenience without introduction of new functionality This method provides no additional functionality compared to the ISO standard methods, but is declared in GeoAPI as a convenient shortcut.