- All Superinterfaces:
Type
@Classifier(METACLASS)
@UML(identifier="RecordType",
specification=ISO_19103)
public interface RecordType
extends Type
The type definition of a record.
A
RecordType
defines dynamically constructed data type.
It is identified by a type name
and contains an arbitrary number of fields.
Fields are (name, type) pairs where the type is often the wrapper
for a primitive type or a String
, but can also be another RecordType
.
Field values can be read and written but cannot be added or removed.
This approach ensures that once a RecordType
is constructed, it is immutable.
Comparison with features and Java reflection
If we think aboutRecordType
as similar to a simple feature (ISO 19109) or a Java Class
with public fields, then we can establish the following equivalence table:
ISO 19103 | ISO 19109 | Similar to Java |
---|---|---|
Record |
Feature |
Object |
Record.getRecordType() |
Feature.getType() |
Object.getClass() |
RecordType |
FeatureType |
Class |
getTypeName() |
FeatureType.getName() |
Class.getName() |
getContainer() |
Class.getPackage() |
|
getFieldTypes() |
FeatureType.getProperties(boolean) |
Class.getFields() |
RecordType.locate(MemberName) |
getProperty(String) |
Class.getField(String) |
RecordType.isInstance(Record) |
Class.isInstance(Object) |
|
RecordSchema |
Package |
- Since:
- 2.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Returns the dictionary of all (name, type) pairs in this record type.default Set
<MemberName> Returns the names of fields defined in thisRecordType
's dictionary.default Map
<MemberName, Type> Deprecated.RenamedgetFieldTypes()
in the 2015 revision of ISO 19103.Returns the name that identifies this record type.boolean
isInstance
(Record record) Determines if the specified record is compatible with this record type.default TypeName
locate
(MemberName name) Looks up the provided field name and returns the associated type name.Methods inherited from interface org.opengis.util.Type
toJavaType
-
Method Details
-
getTypeName
@UML(identifier="typeName", obligation=MANDATORY, specification=ISO_19103, version=2005) TypeName getTypeName()Returns the name that identifies this record type. This is similar to class name in the Java language.- Specified by:
getTypeName
in interfaceType
- Returns:
- the name that identifies this record type.
-
getContainer
@Deprecated(since="3.1") @UML(identifier="schema", obligation=MANDATORY, specification=ISO_19103, version=2005) RecordSchema getContainer()Deprecated.TheRecordSchema
interface has been removed in the 2015 revision of ISO 19103 standard.Returns the schema that contains this record type.- Returns:
- the schema that contains this record type.
-
getFieldTypes
@UML(identifier="fieldType", obligation=MANDATORY, specification=ISO_19103) Map<MemberName,Type> getFieldTypes()Returns the dictionary of all (name, type) pairs in this record type. The dictionary shall contain at least one entry and should be unmodifiable. This is similar to class fields in the Java language.- Returns:
- the dictionary of all (name, type) pairs in this record type. Shall contain at least one entry.
- Since:
- 3.1
- See Also:
-
getMemberTypes
@Deprecated(since="3.1") @UML(identifier="memberType", obligation=MANDATORY, specification=ISO_19103, version=2005) default Map<MemberName,Type> getMemberTypes()Deprecated.RenamedgetFieldTypes()
in the 2015 revision of ISO 19103.Returns the dictionary of all (name, type) pairs in this record type. The dictionary should be unmodifiable. If there are no fields, this method returns the empty map.- Returns:
- the dictionary of all (name, type) pairs in this record type.
- See Also:
-
getMembers
Returns the names of fields defined in thisRecordType
's dictionary. This is a convenience method functionally equivalent to the following code:return getFieldTypes().keySet();
- Returns:
- the set of field names defined in this
RecordType
's dictionary.
Convenience extension to OGC/ISO standard
This is a convenience shortcut for a common operation. -
locate
@UML(identifier="locate", obligation=MANDATORY, specification=ISO_19103, version=2005) default TypeName locate(MemberName name) Looks up the provided field name and returns the associated type name. If the field name is not defined in this record type, then this method returnsnull
. This method is functionally equivalent to the following code:Type type = getFieldTypes().get(name); return (type != null) ? type.getTypeName() : null;
- Parameters:
name
- the name of the field to lookup.- Returns:
- the type of the field of the given name, or
null
. - See Also:
Departure from OGC/ISO standard for historical reason
This method was provided in ISO 19103:2003 and removed in ISO 10103:2015. GeoAPI keeps it for compatibility reasons, since this method can be seen as a shortcut to other methods. -
isInstance
Determines if the specified record is compatible with this record type. This method returnsfalse
if the givenrecord
is null, or if the following condition is false:return (record != null) && getMembers().containsAll(record.getFields().keySet());
true
. Implementations are free to use more restrictive criteria. In particular, it is valid to implement this method like below:return (record != null) && equals(record.getRecordType());
containsAll
approach accepts "sub-types" (defined as records with additional fields) in a way similar to assignement-compatibility check in the Java language, while theequals
approach accepts only the exact same record definition.- Parameters:
record
- the record to test for compatibility with this type, ornull
.- Returns:
true
if the given record is non-null and compatible with this record type.
Convenience extension to OGC/ISO standard
This method provides no additional information compared to the ISO standard methods, but is declared in GeoAPI for convenience.
-
RecordSchema
interface has been removed in the 2015 revision of ISO 19103 standard.