This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 37bab9c Update for a change in GeoAPI: upgrade Record types from ISO
19103:2005 to ISO 19103:2015. The `Record` API has been simplified (some
methods have been deprecated). ISO 19103:2005 "members" have been replaced by
ISO 19103:2015 "fields". We reflect that change of word in the Javadoc texts
and in comments.
37bab9c is described below
commit 37bab9c535cb91dedf5da4d345c97bd765b0a8a9
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Thu Mar 11 22:03:33 2021 +0100
Update for a change in GeoAPI: upgrade Record types from ISO 19103:2005 to
ISO 19103:2015.
The `Record` API has been simplified (some methods have been deprecated).
ISO 19103:2005 "members" have been replaced by ISO 19103:2015 "fields".
We reflect that change of word in the Javadoc texts and in comments.
https://github.com/opengeospatial/geoapi/issues/17
---
.../org/apache/sis/util/iso/DefaultRecord.java | 44 +++----
.../apache/sis/util/iso/DefaultRecordSchema.java | 24 ++--
.../org/apache/sis/util/iso/DefaultRecordType.java | 131 +++++++++++----------
.../org/apache/sis/util/iso/RecordDefinition.java | 54 ++++-----
.../java/org/apache/sis/util/iso/package-info.java | 2 +-
.../sis/util/iso/DefaultRecordSchemaTest.java | 18 +--
.../apache/sis/util/iso/DefaultRecordTypeTest.java | 46 ++++----
7 files changed, 161 insertions(+), 158 deletions(-)
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
index a9b0563..b473aa7 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecord.java
@@ -40,9 +40,9 @@ import org.apache.sis.internal.metadata.RecordSchemaSIS;
/**
* A list of logically related elements as (<var>name</var>, <var>value</var>)
pairs in a dictionary.
- * By definition, all record members have a [1 … 1] multiplicity
+ * By definition, all record fields have a [1 … 1] multiplicity
* (for a more flexible construct, see {@linkplain org.apache.sis.feature
features}).
- * Since all members are expected to be assigned a value, the initial values
on {@code DefaultRecord}
+ * Since all fields are expected to be assigned a value, the initial values on
{@code DefaultRecord}
* instantiation are unspecified. Some may be null, or some may be zero.
*
* <h2>Limitations</h2>
@@ -57,7 +57,7 @@ import org.apache.sis.internal.metadata.RecordSchemaSIS;
*
* @author Martin Desruisseaux (Geomatys)
* @author Cullen Rombach (Image Matters)
- * @version 1.0
+ * @version 1.1
*
* @see DefaultRecordType
* @see DefaultRecordSchema
@@ -102,7 +102,7 @@ public class DefaultRecord implements Record, Serializable {
/**
* Creates a new record initialized to a shallow copy of the given record.
- * The members contained in the given record are <strong>not</strong>
recursively copied.
+ * The fields contained in the given record are <strong>not</strong>
recursively copied.
*
* @param record the record to copy (can not be null).
*
@@ -115,7 +115,7 @@ public class DefaultRecord implements Record, Serializable {
final Object source = ((DefaultRecord) record).values;
System.arraycopy(source, 0, values, 0, Array.getLength(source));
} else {
- for (final Map.Entry<MemberName,Integer> entry :
definition.memberIndices().entrySet()) {
+ for (final Map.Entry<MemberName,Integer> entry :
definition.fieldIndices().entrySet()) {
final MemberName name = entry.getKey();
final Object value = record.locate(name);
if (value != null) {
@@ -132,7 +132,7 @@ public class DefaultRecord implements Record, Serializable {
}
/**
- * Returns a SIS implementation with the name and members of the given
arbitrary implementation.
+ * 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:
*
* <ul>
@@ -141,12 +141,12 @@ public class DefaultRecord implements Record,
Serializable {
* then it is returned unchanged.</li>
* <li>Otherwise a new {@code DefaultRecord} instance is created using
the
* {@linkplain #DefaultRecord(Record) copy constructor} and returned.
- * Note that this is a shallow copy operation, since the members
contained
+ * Note that this is a shallow copy operation, since the fields
contained
* in the given object are not recursively copied.</li>
* </ul>
*
* @param other The object to get as a SIS implementation, or {@code
null} if none.
- * @return A SIS implementation containing the members of the given object
+ * @return A SIS implementation containing the fields of the given object
* (may be the given object itself), or {@code null} if the
argument was {@code null}.
*
* @since 0.8
@@ -176,15 +176,15 @@ public class DefaultRecord implements Record,
Serializable {
*
* @return the dictionary of all (<var>name</var>, <var>value</var>) pairs
in this record.
*
- * @see RecordType#getMemberTypes()
+ * @see RecordType#getFieldTypes()
*/
@Override
- public Map<MemberName, Object> getAttributes() {
+ public Map<MemberName, Object> getFields() {
if (values == null) { // Should never be null,
except temporarily at XML unmarshalling time.
return Collections.emptyMap();
}
return new AbstractMap<MemberName, Object>() {
- /** Returns the number of members in the record. */
+ /** Returns the number of fields in the record. */
@Override
public int size() {
return definition.size();
@@ -217,13 +217,13 @@ public class DefaultRecord implements Record,
Serializable {
* {@link AbstractMap} uses this set for providing a default
implementation of most methods.
*/
private final class Entries extends
AbstractSet<Map.Entry<MemberName,Object>> {
- /** Returns the number of members in the record. */
+ /** Returns the number of fields in the record. */
@Override
public int size() {
return definition.size();
}
- /** Returns an iterator over all record members. */
+ /** Returns an iterator over all record fields. */
@Override
public Iterator<Map.Entry<MemberName, Object>> iterator() {
return new Iter();
@@ -236,16 +236,16 @@ public class DefaultRecord implements Record,
Serializable {
* default implementation of most methods.
*/
private final class Iter implements Iterator<Map.Entry<MemberName,Object>>
{
- /** Index of the next record member to return in the iteration. */
+ /** Index of the next record field to return in the iteration. */
private int index;
- /** Returns {@code true} if there is more record members to iterate
over. */
+ /** Returns {@code true} if there is more record fields to iterate
over. */
@Override
public boolean hasNext() {
return index < definition.size();
}
- /** Returns an entry containing the name and value of the next record
member. */
+ /** Returns an entry containing the name and value of the next record
field. */
@Override
public Map.Entry<MemberName, Object> next() {
if (hasNext()) {
@@ -261,27 +261,27 @@ public class DefaultRecord implements Record,
Serializable {
* and {@link DefaultRecord#set(MemberName, Object)} methods.
*/
private final class Entry extends AbstractMapEntry<MemberName,Object> {
- /** Index of the record member represented by this entry. */
+ /** Index of the record field represented by this entry. */
private final int index;
- /** Creates a new entry for the record member at the given index. */
+ /** Creates a new entry for the record field at the given index. */
Entry(final int index) {
this.index = index;
}
- /** Returns the name of the record member contained in this entry. */
+ /** Returns the name of the record field contained in this entry. */
@Override
public MemberName getKey() {
return definition.getName(index);
}
- /** Returns the current record member value. */
+ /** Returns the current record field value. */
@Override
public Object getValue() {
return locate(getKey());
}
- /** Sets the record member value and returns the previous value. */
+ /** Sets the record field value and returns the previous value. */
@Override
public Object setValue(final Object value) {
final MemberName name = getKey();
@@ -308,7 +308,7 @@ public class DefaultRecord implements Record, Serializable {
*
* @param name the name of the attribute to modify.
* @param value the new value for the attribute.
- * @throws IllegalArgumentException if the given name is not a member of
this record.
+ * @throws IllegalArgumentException if the given name is not a field of
this record.
* @throws ClassCastException if the given value is not an instance of the
expected type for this record.
*/
@Override
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java
index 149f2a8..7046f7f 100644
---
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java
+++
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordSchema.java
@@ -149,35 +149,35 @@ public class DefaultRecordSchema implements RecordSchema {
}
/**
- * Creates a new record type of the given name, which will contain the
given members.
- * Members are declared in iteration order.
+ * Creates a new record type of the given name, which will contain the
given fields.
+ * Fields are declared in iteration order.
*
* @param typeName the record type name.
- * @param members the name of each record member, together with the
expected value types.
- * @return a record type of the given name and members.
- * @throws IllegalArgumentException if a record already exists for the
given name but with different members.
+ * @param fields the name of each record field, together with the
expected value types.
+ * @return a record type of the given name and fields.
+ * @throws IllegalArgumentException if a record already exists for the
given name but with different fields.
*/
- public RecordType createRecordType(final CharSequence typeName, final
Map<CharSequence,Class<?>> members)
+ public RecordType createRecordType(final CharSequence typeName, final
Map<CharSequence,Class<?>> fields)
throws IllegalArgumentException
{
ArgumentChecks.ensureNonNull("typeName", typeName);
- ArgumentChecks.ensureNonNull("members", members);
+ ArgumentChecks.ensureNonNull("fields", fields);
final TypeName name = nameFactory.createTypeName(namespace, typeName);
- final Map<CharSequence,Type> memberTypes =
ObjectConverters.derivedValues(members, CharSequence.class, toTypes);
+ final Map<CharSequence,Type> fieldTypes =
ObjectConverters.derivedValues(fields, CharSequence.class, toTypes);
RecordType record;
synchronized (description) {
record = description.get(typeName);
if (record == null) {
- record = new DefaultRecordType(name, this, memberTypes,
nameFactory);
+ record = new DefaultRecordType(name, this, fieldTypes,
nameFactory);
description.put(name, record);
return record;
}
}
/*
- * If a record type already exists for the given name, verify that it
contains the same members.
+ * If a record type already exists for the given name, verify that it
contains the same fields.
*/
- final Iterator<Map.Entry<CharSequence,Class<?>>> it1 =
members.entrySet().iterator();
- final Iterator<Map.Entry<MemberName,Type>> it2 =
record.getMemberTypes().entrySet().iterator();
+ final Iterator<Map.Entry<CharSequence,Class<?>>> it1 =
fields.entrySet().iterator();
+ final Iterator<Map.Entry<MemberName,Type>> it2 =
record.getFieldTypes().entrySet().iterator();
boolean hasNext;
while ((hasNext = it1.hasNext()) == it2.hasNext()) {
if (!hasNext) {
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
index d107128..9d06b2a 100644
---
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
+++
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/DefaultRecordType.java
@@ -50,12 +50,12 @@ import org.apache.sis.internal.metadata.RecordSchemaSIS;
/**
* An immutable definition of the type of a {@linkplain DefaultRecord record}.
* A {@code RecordType} is identified by a {@linkplain #getTypeName() type
name} and contains an
- * arbitrary amount of {@linkplain #getMembers() members} as (<var>name</var>,
<var>type</var>) pairs.
- * A {@code RecordType} may therefore contain another {@code RecordType} as a
member.
+ * arbitrary amount of {@linkplain #getMembers() members} (fields) as
(<var>name</var>, <var>type</var>) pairs.
+ * A {@code RecordType} may therefore contain another {@code RecordType} as a
field.
*
* <div class="note"><b>Comparison with Java reflection:</b>
* {@code RecordType} instances can be though as equivalent to instances of
the Java {@link Class} class.
- * The set of members in a {@code RecordType} can be though as equivalent to
the set of fields in a class.
+ * The set of fields in a {@code RecordType} can be though as equivalent to
the set of fields in a class.
* </div>
*
* <h2>Instantiation</h2>
@@ -68,12 +68,12 @@ import org.apache.sis.internal.metadata.RecordSchemaSIS;
* DefaultRecordSchema schema = new DefaultRecordSchema(null, null,
"MySchema");
* // The same instance can be reused for all records to create in that
schema.
*
- * Map<CharSequence,Class<?>> members = new LinkedHashMap<>();
- * members.put("city", String .class);
- * members.put("latitude", Double .class);
- * members.put("longitude", Double .class);
- * members.put("population", Integer.class);
- * RecordType record = schema.createRecordType("MyRecordType", members);
+ * Map<CharSequence,Class<?>> fields = new LinkedHashMap<>();
+ * fields.put("city", String .class);
+ * fields.put("latitude", Double .class);
+ * fields.put("longitude", Double .class);
+ * fields.put("population", Integer.class);
+ * RecordType record = schema.createRecordType("MyRecordType", fields);
* }
* </div>
*
@@ -89,7 +89,7 @@ import org.apache.sis.internal.metadata.RecordSchemaSIS;
* so users wanting serialization may need to provide their own schema.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 1.0
+ * @version 1.1
*
* @see DefaultRecord
* @see DefaultRecordSchema
@@ -120,21 +120,21 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
private final RecordSchema container;
/**
- * The type of each members.
+ * The type of each fields.
*
- * @see #getMemberTypes()
+ * @see #getFieldTypes()
*/
- private transient Type[] memberTypes;
+ private transient Type[] fieldTypes;
/**
- * Creates a new record with the same names and members than the given one.
+ * Creates a new record with the same names and fields than the given one.
*
* @param other the {@code RecordType} to copy.
*/
public DefaultRecordType(final RecordType other) {
- typeName = other.getTypeName();
- container = other.getContainer();
- memberTypes = computeTransientFields(other.getMemberTypes());
+ typeName = other.getTypeName();
+ container = other.getContainer();
+ fieldTypes = computeTransientFields(other.getFieldTypes());
}
/**
@@ -149,19 +149,19 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
*
* @param typeName the name that identifies this record type.
* @param container the schema that contains this record type.
- * @param members the name and type of the members to be included in
this record type.
+ * @param fields the name and type of the fields to be included in
this record type.
*
* @see DefaultRecordSchema#createRecordType(CharSequence, Map)
*/
public DefaultRecordType(final TypeName typeName, final RecordSchema
container,
- final Map<? extends MemberName, ? extends Type> members)
+ final Map<? extends MemberName, ? extends Type> fields)
{
ArgumentChecks.ensureNonNull("typeName", typeName);
ArgumentChecks.ensureNonNull("container", container);
- ArgumentChecks.ensureNonNull("members", members);
- this.typeName = typeName;
- this.container = container;
- this.memberTypes = computeTransientFields(members);
+ ArgumentChecks.ensureNonNull("field", fields);
+ this.typeName = typeName;
+ this.container = container;
+ this.fieldTypes = computeTransientFields(fields);
/*
* Ensure that the record namespace is equals to the schema name. For
example if the schema
* name is "MyNameSpace", then the record type name can be
"MyNameSpace:MyRecordType".
@@ -174,7 +174,7 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
final int size = size();
for (int i=0; i<size; i++) {
final MemberName name = getName(i);
- final Type type = this.memberTypes[i];
+ final Type type = this.fieldTypes[i];
if (type == null ||
name.getAttributeType().compareTo(type.getTypeName()) != 0) {
throw new
IllegalArgumentException(Errors.format(Errors.Keys.IllegalMemberType_2, name,
type));
}
@@ -186,30 +186,30 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
}
/**
- * Creates a new record from member names specified as character sequence.
+ * Creates a new record from field names specified as character sequence.
* This constructor builds the {@link MemberName} instance itself.
*
* @param typeName the name that identifies this record type.
* @param container the schema that contains this record type.
- * @param members the name of the members to be included in this
record type.
+ * @param fields the name of the fields to be included in this
record type.
* @param nameFactory the factory to use for instantiating {@link
MemberName}.
*/
DefaultRecordType(final TypeName typeName, final RecordSchema container,
- final Map<? extends CharSequence, ? extends Type> members, final
NameFactory nameFactory)
+ final Map<? extends CharSequence, ? extends Type> fields, final
NameFactory nameFactory)
{
this.typeName = typeName;
this.container = container;
final NameSpace namespace = nameFactory.createNameSpace(typeName,
null);
- final Map<MemberName,Type> memberTypes = new
LinkedHashMap<>(Containers.hashMapCapacity(members.size()));
- for (final Map.Entry<? extends CharSequence, ? extends Type> entry :
members.entrySet()) {
+ final Map<MemberName,Type> fieldTypes = new
LinkedHashMap<>(Containers.hashMapCapacity(fields.size()));
+ for (final Map.Entry<? extends CharSequence, ? extends Type> entry :
fields.entrySet()) {
final Type type = entry.getValue();
final CharSequence name = entry.getKey();
final MemberName member =
nameFactory.createMemberName(namespace, name, type.getTypeName());
- if (memberTypes.put(member, type) != null) {
+ if (fieldTypes.put(member, type) != null) {
throw new
IllegalArgumentException(Errors.format(Errors.Keys.DuplicatedElement_1,
member));
}
}
- this.memberTypes = computeTransientFields(memberTypes);
+ this.fieldTypes = computeTransientFields(fieldTypes);
}
/**
@@ -223,25 +223,25 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
private void readObject(final ObjectInputStream in) throws IOException,
ClassNotFoundException {
in.defaultReadObject();
final int size = in.readInt();
- final Map<MemberName,Type> members = new
LinkedHashMap<>(Containers.hashMapCapacity(size));
+ final Map<MemberName,Type> fields = new
LinkedHashMap<>(Containers.hashMapCapacity(size));
for (int i=0; i<size; i++) {
final MemberName member = (MemberName) in.readObject();
final Type type = (Type) in.readObject();
- if (members.put(member, type) != null) {
+ if (fields.put(member, type) != null) {
throw new
InvalidObjectException(Errors.format(Errors.Keys.DuplicatedElement_1, member));
}
}
- memberTypes = computeTransientFields(members);
+ fieldTypes = computeTransientFields(fields);
}
/**
- * Invoked on serialization for writing the member names and their type.
+ * Invoked on serialization for writing the field names and their type.
*
* @param out the output stream where to serialize this object.
* @throws IOException if an I/O error occurred while writing.
*
- * @serialData the number of members as an {@code int}, followed by a
- * ({@code MemberName}, {@code Type}) pair for each member.
+ * @serialData the number of fields as an {@code int}, followed by a
+ * ({@code MemberName}, {@code Type}) pair for each field.
*/
private void writeObject(final ObjectOutputStream out) throws IOException {
final int size = size();
@@ -249,12 +249,12 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
out.writeInt(size);
for (int i=0; i<size; i++) {
out.writeObject(getName(i));
- out.writeObject(memberTypes[i]);
+ out.writeObject(fieldTypes[i]);
}
}
/**
- * Returns a SIS implementation with the name and members of the given
arbitrary implementation.
+ * 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:
*
* <ul>
@@ -263,12 +263,12 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
* then it is returned unchanged.</li>
* <li>Otherwise a new {@code DefaultRecordType} instance is created
using the
* {@linkplain #DefaultRecordType(RecordType) copy constructor} and
returned.
- * Note that this is a shallow copy operation, since the members
contained
+ * Note that this is a shallow copy operation, since the fields
contained
* in the given object are not recursively copied.</li>
* </ul>
*
* @param other the object to get as a SIS implementation, or {@code
null} if none.
- * @return a SIS implementation containing the members of the given object
+ * @return a SIS implementation containing the fields of the given object
* (may be the given object itself), or {@code null} if the
argument was {@code null}.
*/
public static DefaultRecordType castOrCopy(final RecordType other) {
@@ -312,8 +312,11 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
* Returns the schema that contains this record type.
*
* @return the schema that contains this record type.
+ *
+ * @deprecated The {@code RecordSchema} interface has been removed in the
2015 revision of ISO 19103 standard.
*/
@Override
+ @Deprecated
public RecordSchema getContainer() {
return container;
}
@@ -330,8 +333,8 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
* @return the dictionary of (<var>name</var>, <var>type</var>) pairs, or
an empty map if none.
*/
@Override
- public Map<MemberName,Type> getMemberTypes() {
- return ObjectConverters.derivedValues(memberIndices(),
MemberName.class, new SurjectiveConverter<Integer,Type>() {
+ public Map<MemberName,Type> getFieldTypes() {
+ return ObjectConverters.derivedValues(fieldIndices(),
MemberName.class, new SurjectiveConverter<Integer,Type>() {
@Override public Class<Integer> getSourceClass() {return
Integer.class;}
@Override public Class<Type> getTargetClass() {return
Type.class;}
@Override public Type apply(final Integer index) {return
getType(index);}
@@ -340,24 +343,24 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
/**
* Returns the set of attribute names defined in this {@code RecordType}'s
dictionary.
- * This method is functionally equivalent to:
+ * This method is functionally equivalent to the following code, but
slightly more efficient:
*
* {@preformat java
- * getMemberTypes().keySet();
+ * getFieldTypes().keySet();
* }
*
- * @return the set of attribute names, or an empty set if none.
+ * @return the set of field names, or an empty set if none.
*/
@Override
public Set<MemberName> getMembers() {
- return memberIndices().keySet();
+ return fieldIndices().keySet();
}
/**
* Returns the type at the given index.
*/
final Type getType(final int index) {
- return memberTypes[index];
+ return fieldTypes[index];
}
/**
@@ -365,7 +368,7 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
* This method is functionally equivalent to (omitting the check for null
value):
*
* {@preformat java
- * getMemberTypes().get(memberName).getTypeName();
+ * getFieldTypes().get(name).getTypeName();
* }
*
* <div class="note"><b>Comparison with Java reflection:</b>
@@ -373,12 +376,12 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
* this method can be though as related to the Java {@link
Class#getField(String)} method.
* </div>
*
- * @param memberName the attribute name for which to get the associated
type name.
+ * @param fieldName the attribute name for which to get the associated
type name.
* @return the associated type name, or {@code null} if none.
*/
@Override
- public TypeName locate(final MemberName memberName) {
- final Integer index = indexOf(memberName);
+ public TypeName locate(final MemberName fieldName) {
+ final Integer index = indexOf(fieldName);
return (index != null) ? getType(index).getTypeName() : null;
}
@@ -416,10 +419,10 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
}
if (other != null && other.getClass() == getClass()) {
final DefaultRecordType that = (DefaultRecordType) other;
- return Objects.equals(typeName, that.typeName) &&
- Objects.equals(container, that.container) &&
- Arrays .equals(memberTypes, that.memberTypes) &&
- memberIndices().equals(that.memberIndices());
+ return Objects.equals(typeName, that.typeName) &&
+ Objects.equals(container, that.container) &&
+ Arrays .equals(fieldTypes, that.fieldTypes) &&
+ fieldIndices().equals(that.fieldIndices());
}
return false;
}
@@ -429,7 +432,7 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
*/
@Override
public int hashCode() {
- return Objects.hashCode(typeName) + 31*(memberIndices().hashCode() +
31*Arrays.hashCode(memberTypes));
+ return Objects.hashCode(typeName) + 31*(fieldIndices().hashCode() +
31*Arrays.hashCode(fieldTypes));
}
@@ -458,20 +461,20 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
}
/**
- * Returns the record type value as a string. Current implementation
returns the members with
- * one member per line, but it may change in any future version for
adapting to common practice.
+ * Returns the record type value as a string. Current implementation
returns the fields with
+ * one field per line, but it may change in any future version for
adapting to common practice.
*/
@XmlValue
private String getValue() {
switch (size()) {
case 0: return null;
- case 1: return String.valueOf(memberTypes[0]);
+ case 1: return String.valueOf(fieldTypes[0]);
default: return toString(null, null);
}
}
/**
- * Sets the record type value as a string. Current implementation expect
one member per line.
+ * Sets the record type value as a string. Current implementation expect
one field per line.
* A record can be anything, but usages that we have seen so far write a
character sequence
* of what seems <var>key</var>-<var>description</var> pairs. Examples:
*
@@ -486,7 +489,7 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
*/
private void setValue(final String value) {
if (value != null) {
- final Map<MemberName,Type> members = new LinkedHashMap<>();
+ final Map<MemberName,Type> fields = new LinkedHashMap<>();
for (CharSequence element : CharSequences.splitOnEOL(value)) {
final int s = ((String) element).indexOf(':');
if (s >= 0) {
@@ -494,9 +497,9 @@ public class DefaultRecordType extends RecordDefinition
implements RecordType, S
// TODO: the part after ":" is the description. For now,
we have no room for storing it.
}
final MemberName m = Names.createMemberName(null, null,
element, String.class);
- members.put(m,
RecordSchemaSIS.INSTANCE.toAttributeType(String.class));
+ fields.put(m,
RecordSchemaSIS.INSTANCE.toAttributeType(String.class));
}
- memberTypes = computeTransientFields(members);
+ fieldTypes = computeTransientFields(fields);
}
}
}
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/RecordDefinition.java
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/RecordDefinition.java
index 53cb85f..cb8a8d1 100644
---
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/RecordDefinition.java
+++
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/RecordDefinition.java
@@ -77,7 +77,7 @@ abstract class RecordDefinition {
// Inten
*/
Adapter(final RecordType recordType) {
this.recordType = recordType;
- computeTransientFields(recordType.getMemberTypes());
+ computeTransientFields(recordType.getFieldTypes());
}
/**
@@ -89,7 +89,7 @@ abstract class RecordDefinition {
// Inten
*/
private void readObject(final ObjectInputStream in) throws
IOException, ClassNotFoundException {
in.defaultReadObject();
- computeTransientFields(recordType.getMemberTypes());
+ computeTransientFields(recordType.getFieldTypes());
}
/**
@@ -102,18 +102,18 @@ abstract class RecordDefinition {
// Inten
}
/**
- * Indices of member names. Created on construction or deserialization,
+ * Indices of field names. Created on construction or deserialization,
* and shall be considered final and unmodifiable after that point.
*
- * @see #memberIndices()
+ * @see #fieldIndices()
*/
- private transient Map<MemberName,Integer> memberIndices;
+ private transient Map<MemberName,Integer> fieldIndices;
/**
- * Member names. Created on construction or deserialization, and shall be
considered
+ * Field names. Created on construction or deserialization, and shall be
considered
* final and unmodifiable after that point.
*/
- private transient MemberName[] members;
+ private transient MemberName[] fieldNames;
/**
* Classes of expected values, or {@code null} if there is no restriction.
Created on
@@ -140,17 +140,17 @@ abstract class RecordDefinition {
// Inten
/**
* Invoked on construction or deserialization for computing the transient
fields.
*
- * @param memberTypes the (<var>name</var>, <var>type</var>) pairs in
this record type.
+ * @param fieldTypes the (<var>name</var>, <var>type</var>) pairs in
this record type.
* @return the values in the given map. This information is not stored in
{@code RecordDefinition}
* because not needed by this class, but the {@link
DefaultRecordType} subclass will store it.
*/
- final Type[] computeTransientFields(final Map<? extends MemberName, ?
extends Type> memberTypes) {
- final int size = memberTypes.size();
- members = new MemberName[size];
- memberIndices = new LinkedHashMap<>(Containers.hashMapCapacity(size));
+ final Type[] computeTransientFields(final Map<? extends MemberName, ?
extends Type> fieldTypes) {
+ final int size = fieldTypes.size();
+ fieldNames = new MemberName[size];
+ fieldIndices = new LinkedHashMap<>(Containers.hashMapCapacity(size));
final Type[] types = new Type[size];
int i = 0;
- for (final Map.Entry<? extends MemberName, ? extends Type> entry :
memberTypes.entrySet()) {
+ for (final Map.Entry<? extends MemberName, ? extends Type> entry :
fieldTypes.entrySet()) {
final Type type = entry.getValue();
if (type instanceof AttributeType) {
final Class<?> c = ((AttributeType) type).getValueClass();
@@ -163,12 +163,12 @@ abstract class RecordDefinition {
// Inten
}
}
final MemberName name = entry.getKey();
- members[i] = name;
- memberIndices.put(name, i);
+ fieldNames[i] = name;
+ fieldIndices.put(name, i);
types[i] = type;
i++;
}
- memberIndices = CollectionsExt.unmodifiableOrCopy(memberIndices);
+ fieldIndices = CollectionsExt.unmodifiableOrCopy(fieldIndices);
baseValueClass = (baseValueClass != null) ?
Numbers.wrapperToPrimitive(baseValueClass) : Object.class;
return types;
}
@@ -181,33 +181,33 @@ abstract class RecordDefinition {
// Inten
}
/**
- * Read-only access to the map of member indices.
+ * Read-only access to the map of field indices.
*/
@SuppressWarnings("ReturnOfCollectionOrArrayField")
- final Map<MemberName,Integer> memberIndices() {
- return memberIndices;
+ final Map<MemberName,Integer> fieldIndices() {
+ return fieldIndices;
}
/**
* Returns the number of elements in records.
*/
final int size() {
- // 'members' should not be null, but let be safe.
- return (members != null) ? members.length : 0;
+ // `fieldNames` should not be null, but let be safe.
+ return (fieldNames != null) ? fieldNames.length : 0;
}
/**
* Returns the index of the given name, or {@code null} if none.
*/
- final Integer indexOf(final MemberName memberName) {
- return memberIndices.get(memberName);
+ final Integer indexOf(final MemberName fieldName) {
+ return fieldIndices.get(fieldName);
}
/**
- * Returns the name of the member at the given index.
+ * Returns the name of the field at the given index.
*/
final MemberName getName(final int index) {
- return members[index];
+ return fieldNames[index];
}
/**
@@ -242,7 +242,7 @@ abstract class RecordDefinition {
// Inten
final String margin;
int width = 0;
for (int i=0; i<names.length; i++) {
- width = Math.max(width, (names[i] =
members[i].toString()).length());
+ width = Math.max(width, (names[i] =
fieldNames[i].toString()).length());
}
if (head == null) {
width = 0; // Ignore the width computation, but we still
need the names in the array.
@@ -254,7 +254,7 @@ abstract class RecordDefinition {
// Inten
for (int i=0; i<names.length; i++) {
final String name = names[i];
buffer.append(margin).append(name);
- final Object value = (values != null) ? Array.get(values, i) :
members[i].getAttributeType();
+ final Object value = (values != null) ? Array.get(values, i) :
fieldNames[i].getAttributeType();
if (value != null) {
buffer.append(CharSequences.spaces(width -
name.length())).append(" : ").append(value);
}
diff --git
a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/package-info.java
b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/package-info.java
index d2b676e..1c52dd3 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/util/iso/package-info.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/util/iso/package-info.java
@@ -108,7 +108,7 @@
* </table>
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 1.0
+ * @version 1.1
* @since 0.3
* @module
*/
diff --git
a/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
b/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
index 8f1117f..558ee4a 100644
---
a/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
+++
b/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordSchemaTest.java
@@ -35,7 +35,7 @@ import static org.junit.Assert.*;
* Tests the {@link DefaultRecordSchema} implementation.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.1
* @since 0.5
* @module
*/
@@ -50,19 +50,19 @@ public final strictfp class DefaultRecordSchemaTest extends
TestCase {
@Test
public void testCreateRecordType() {
final DefaultRecordSchema schema = new DefaultRecordSchema(null, null,
"MySchema");
- final Map<CharSequence,Class<?>> members = new LinkedHashMap<>(8);
- assertNull(members.put("city", String.class));
- assertNull(members.put("latitude", Double.class));
- assertNull(members.put("longitude", Double.class));
- assertNull(members.put("population", Integer.class));
- final RecordType recordType = schema.createRecordType("MyRecordType",
members);
+ final Map<CharSequence,Class<?>> fields = new LinkedHashMap<>(8);
+ assertNull(fields.put("city", String.class));
+ assertNull(fields.put("latitude", Double.class));
+ assertNull(fields.put("longitude", Double.class));
+ assertNull(fields.put("population", Integer.class));
+ final RecordType recordType = schema.createRecordType("MyRecordType",
fields);
/*
* Inspect properties.
*/
assertSame("container", schema, recordType.getContainer());
assertEquals("typeName", Names.createTypeName("MySchema", ":",
"MyRecordType"), recordType.getTypeName());
int count = 0;
- for (final Map.Entry<MemberName,Type> entry :
recordType.getMemberTypes().entrySet()) {
+ for (final Map.Entry<MemberName,Type> entry :
recordType.getFieldTypes().entrySet()) {
final String expectedName;
final String expectedType;
final Class<?> expectedClass;
@@ -108,7 +108,7 @@ public final strictfp class DefaultRecordSchemaTest extends
TestCase {
final DefaultRecordType copy = new DefaultRecordType(
recordType.getTypeName(),
recordType.getContainer(),
- recordType.getMemberTypes());
+ recordType.getFieldTypes());
assertEquals(recordType, copy);
}
}
diff --git
a/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java
b/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java
index f161dc5..ee2f906 100644
---
a/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java
+++
b/core/sis-metadata/src/test/java/org/apache/sis/util/iso/DefaultRecordTypeTest.java
@@ -36,16 +36,16 @@ import static
org.apache.sis.test.TestUtilities.getSingleton;
* Tests the {@link DefaultRecordType} implementation.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.1
* @since 0.5
* @module
*/
@DependsOn(TypeNamesTest.class)
public final strictfp class DefaultRecordTypeTest extends TestCase {
- /** Value of {@link DefaultRecordType#getContainer()}. */ private
DefaultRecordSchema container;
- /** Value of {@link DefaultRecordType#getTypeName()}. */ private
DefaultTypeName recordTypeName;
- /** Value of {@link DefaultRecordType#getMembers()}. */ private
DefaultMemberName memberName;
- /** Value of {@link DefaultRecordType#getMemberTypes()}. */ private
DefaultTypeName memberTypeName;
+ /** Value of {@link DefaultRecordType#getContainer()}. */ private
DefaultRecordSchema container;
+ /** Value of {@link DefaultRecordType#getTypeName()}. */ private
DefaultTypeName recordTypeName;
+ /** Value of {@link DefaultRecordType#getMembers()}. */ private
DefaultMemberName fieldName;
+ /** Value of {@link DefaultRecordType#getFieldTypes()}. */ private
DefaultTypeName fieldTypeName;
/**
* Initializes the private fields.
@@ -53,23 +53,23 @@ public final strictfp class DefaultRecordTypeTest extends
TestCase {
*/
private void init() {
final DefaultNameSpace recordNamespace;
- final DefaultNameSpace memberNamespace;
+ final DefaultNameSpace fieldNamespace;
recordNamespace = new DefaultNameSpace (null, "MyNameSpace", ":", ":");
recordTypeName = new DefaultTypeName (recordNamespace,
"MyRecordType");
- memberNamespace = new DefaultNameSpace (recordNamespace,
"MyRecordType", ":", ":");
- memberTypeName = new DefaultTypeName (new DefaultNameSpace(null,
"gco", ":", ":"), "Integer");
- memberName = new DefaultMemberName(memberNamespace, "aMember",
memberTypeName);
+ fieldNamespace = new DefaultNameSpace (recordNamespace,
"MyRecordType", ":", ":");
+ fieldTypeName = new DefaultTypeName (new DefaultNameSpace(null,
"gco", ":", ":"), "Integer");
+ fieldName = new DefaultMemberName(fieldNamespace, "aMember",
fieldTypeName);
container = new SerializableRecordSchema("MyNameSpace");
- assertEquals("MyNameSpace:MyRecordType:aMember",
memberName.toFullyQualifiedName().toString());
+ assertEquals("MyNameSpace:MyRecordType:aMember",
fieldName.toFullyQualifiedName().toString());
}
/**
* Creates a new record type from the current values of private fields.
*/
private DefaultRecordType create() throws IllegalArgumentException {
- final Type memberType = new SimpleAttributeType<>(memberTypeName,
Integer.class);
- return new DefaultRecordType(recordTypeName, container,
Collections.singletonMap(memberName, memberType));
+ final Type fieldType = new SimpleAttributeType<>(fieldTypeName,
Integer.class);
+ return new DefaultRecordType(recordTypeName, container,
Collections.singletonMap(fieldName, fieldType));
}
/**
@@ -84,13 +84,13 @@ public final strictfp class DefaultRecordTypeTest extends
TestCase {
assertEquals("baseValueClass", Integer.TYPE, type.baseValueClass());
// Public properties
- assertSame("container", container, type.getContainer());
- assertSame("typeName", recordTypeName, type.getTypeName());
- assertSame("members", memberName,
getSingleton(type.getMembers()));
- assertSame("memberTypes", memberName,
getSingleton(type.getMemberTypes().keySet()));
- assertSame("memberTypes", memberTypeName,
getSingleton(type.getMemberTypes().values()).getTypeName());
- assertSame("locate", memberTypeName, type.locate(memberName));
- assertNull("locate", type.locate(new
DefaultMemberName(null, "otherMember", memberTypeName)));
+ assertSame("container", container, type.getContainer());
+ assertSame("typeName", recordTypeName, type.getTypeName());
+ assertSame("fields", fieldName,
getSingleton(type.getMembers()));
+ assertSame("fieldTypes", fieldName,
getSingleton(type.getFieldTypes().keySet()));
+ assertSame("fieldTypes", fieldTypeName,
getSingleton(type.getFieldTypes().values()).getTypeName());
+ assertSame("locate", fieldTypeName, type.locate(fieldName));
+ assertNull("locate", type.locate(new
DefaultMemberName(null, "otherMember", fieldTypeName)));
}
/**
@@ -102,7 +102,7 @@ public final strictfp class DefaultRecordTypeTest extends
TestCase {
public void testArgumentChecks() {
init();
final DefaultTypeName correctRecordName = recordTypeName;
- final NameSpace correctMemberNamespace = memberName.scope();
+ final NameSpace correctMemberNamespace = fieldName.scope();
final DefaultNameSpace wrongNamespace = new
DefaultNameSpace(null, "WrongNameSpace", ":", ":");
/*
* RecordType namespace validation.
@@ -122,7 +122,7 @@ public final strictfp class DefaultRecordTypeTest extends
TestCase {
* Constructor shall require "MyNameSpace:MyRecordType:aMember".
*/
recordTypeName = correctRecordName;
- memberName = new DefaultMemberName(wrongNamespace, "aMember",
memberTypeName);
+ fieldName = new DefaultMemberName(wrongNamespace, "aMember",
fieldTypeName);
try {
create();
fail("Should have detected namespace mismatch.");
@@ -134,8 +134,8 @@ public final strictfp class DefaultRecordTypeTest extends
TestCase {
/*
* MemberName type validation.
*/
- final DefaultTypeName otherType = new
DefaultTypeName(memberTypeName.scope(), "Real");
- memberName = new DefaultMemberName(correctMemberNamespace, "aMember",
otherType);
+ final DefaultTypeName otherType = new
DefaultTypeName(fieldTypeName.scope(), "Real");
+ fieldName = new DefaultMemberName(correctMemberNamespace, "aMember",
otherType);
try {
create();
fail("Should have detected type mismatch.");