Package org.apache.sis.util.iso
Class DefaultRecord
java.lang.Object
org.apache.sis.util.iso.DefaultRecord
- All Implemented Interfaces:
Serializable,org.opengis.util.Record
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:
DefaultRecordinstances are not thread-safe. Synchronization, if needed, shall be done externally by the caller. - Serialization: this class is serializable if the associated
RecordTypeand all values are also serializable. Note in particular thatDefaultRecordSchemais 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 ClassesModifier and TypeClassDescriptionprivate final classThe set of map entries to be returned byDefaultRecord.getAttributes().entrySet().private final classA single entry in the map returned byDefaultRecord.getAttributes().private final classThe iterator to be returned byDefaultRecord.getAttributes().entrySet().iterator(). -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final RecordDefinitionThe type definition of this record.private static final longFor cross-version compatibility.private ObjectThe record values in an array. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstructs 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 TypeMethodDescriptionstatic DefaultRecordcastOrCopy(org.opengis.util.Record other) Returns a SIS implementation with the name and fields of the given arbitrary implementation.booleanCompares this record with the given object for equality.Deprecated.Returns the dictionary of all (name, value) pairs in this record.org.opengis.util.RecordTypeReturns the type definition of this record.private StringgetValue()Returns the record value as a string.inthashCode()Returns a hash code value for this record.locate(org.opengis.util.MemberName name) Returns the value for an attribute of the specified name.voidSets the value for the attribute of the specified name.voidSets all attribute values in this record, in attribute order.private voidSets the record value as a string.toString()Returns a string representation of this record.
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
definition
The type definition of this record. Cannot benull. -
values
The record values in an array. May be an array of primitive type for compactness, which is why the type is notObject[]. Should never benull, 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 tosetAll(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. SeesetValue(String)for a description of the supported XML content.
-
-
Method Details
-
castOrCopy
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 returnsnull. - Otherwise if the given object is already an instance of
DefaultRecord, then it is returned unchanged. - Otherwise a new
DefaultRecordinstance 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, ornullif none.- Returns:
- A SIS implementation containing the fields of the given object
(may be the given object itself), or
nullif the argument wasnull. - Since:
- 0.8
- If the given object is
-
getRecordType
public org.opengis.util.RecordType getRecordType()Returns the type definition of this record.- Specified by:
getRecordTypein interfaceorg.opengis.util.Record- Returns:
- the type definition of this record.
-
getAttributes
Deprecated.RenamedgetFields()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 allgetandputoperations to thelocate(MemberName)andset(MemberName, Object)methods respectively.- Specified by:
getAttributesin interfaceorg.opengis.util.Record- Returns:
- the dictionary of all (name, value) pairs in this record.
- See Also:
-
RecordType.getMemberTypes()
-
getFields
Returns the dictionary of all (name, value) pairs in this record. This method returns a view which will delegate allgetandputoperations to thelocate(MemberName)andset(MemberName, Object)methods respectively.- Returns:
- the dictionary of all (name, value) pairs in this record.
- Since:
- 1.1
-
locate
Returns the value for an attribute of the specified name.- Specified by:
locatein interfaceorg.opengis.util.Record- Parameters:
name- the name of the attribute to lookup.- Returns:
- the value of the attribute for the given name.
-
set
Sets the value for the attribute of the specified name.- Specified by:
setin interfaceorg.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
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
Compares this record with the given object for equality. -
hashCode
public int hashCode()Returns a hash code value for this record. -
toString
Returns a string representation of this record. The string representation is for debugging purpose and may change in any future SIS version. -
getValue
Returns the record value as a string. -
setValue
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:
-
getFields()for consistency with the 2015 revision of ISO 19103 standard.