Interface RecordType

  • All Superinterfaces:
    Type

    @UML(identifier="RecordType",
         specification=ISO_19103)
    public interface RecordType
    extends Type
    The type definition of a record. A RecordType defines dynamically constructed data type. A RecordType is identified by a type name and contains an arbitrary amount of members. Members are (name, type) pairs. A RecordType may therefore contain another RecordType as a member.

    This interface has methods for data access, but no methods to dynamically add members. This approach ensures that once a RecordType is constructed, it is immutable.

    Comparison with Java reflection
    RecordType instances can be though as equivalent to instances of the Java Class class. The set of members in a RecordType can be though as equivalent to the set of fields in a class.
    Since:
    2.1
    See Also:
    Record.getRecordType(), RecordSchema
    • Method Detail

      • getTypeName

        @UML(identifier="typeName",
             obligation=MANDATORY,
             specification=ISO_19103)
        TypeName getTypeName()
        Returns the name that identifies this record type. If this RecordType is contained in a record schema, then the record type name shall be a valid in the name space of the record schema.
        Comparison with Java reflection
        If we think about this RecordType as equivalent to a Class instance, then this method can be though as the equivalent of the Java Class.getName() method.
        Specified by:
        getTypeName in interface Type
        Returns:
        the name that identifies this record type.
      • getMemberTypes

        @UML(identifier="memberTypes",
             obligation=MANDATORY,
             specification=ISO_19103)
        Map<MemberName,Type> getMemberTypes()
        Returns the dictionary of all (name, type) pairs in this record type. The dictionary shall be unmodifiable. If there are no attributes, this method returns the empty map.

        The name space associated with a RecordType contains only members of this RecordType. There is no potential for conflict with other record types.

        Comparison with Java reflection
        If we think about this RecordType as equivalent to a Class instance, then this method can be though as related to the Java Class.getFields() method.
        Returns:
        the dictionary of all (name, type) pairs in this record type.
        See Also:
        Record.getAttributes()
      • getMembers

        Set<MemberName> getMembers()
        Returns the set of member names defined in this RecordType's dictionary. If there are no members, this method returns the empty set.

        This method is functionally equivalent to getMemberTypes().keySet().

        Returns:
        the set of attribute names defined in this RecordType's dictionary.
        Departure from OGC/ISO specification:
        This method provides no additional information compared to the ISO standard methods, but is declared in GeoAPI as a convenient shortcut.
      • locate

        @UML(identifier="locate",
             obligation=MANDATORY,
             specification=ISO_19103)
        TypeName locate​(MemberName name)
        Looks up the provided attribute name and returns the associated type name. If the attribute name is not defined in this record type, then this method returns null. This method is functionally equivalent to the following code, omitting the check for null values:
        return getMemberTypes().get(name).getTypeName()
        Comparison with Java reflection
        If we think about this RecordType as equivalent to a Class instance, then this method can be though as related to the Java Class.getField(String) method.
        Parameters:
        name - the name of the attribute we are looking for.
        Returns:
        the type of of attribute of the given name, or null.
        See Also:
        Record.locate(MemberName)
      • isInstance

        boolean isInstance​(Record record)
        Determines if the specified record is compatible with this record type. This method returns true if the specified record argument is non-null and the following minimal condition holds:
         Set<MemberName> attributeNames = record.getAttributes().keySet();
         boolean isInstance = getMembers().containsAll();
        Vendors can put additional implementation-specific conditions. In particular, implementations are free to require that == this. The choice between more lenient or more restrictive conditions is similar to allowing or not sub-classing.
        Comparison with Java reflection
        If we think about this RecordType as equivalent to a Class instance, then this method can be though as the equivalent of the Java Class.isInstance(Object) method.
        Parameters:
        record - the record to test for compatibility.
        Returns:
        true if the given record is compatible with this record type.
        Departure from OGC/ISO specification:
        This method provides no additional information compared to the ISO standard methods, but is declared in GeoAPI as a convenient shortcut.