You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2013/04/18 23:49:52 UTC
svn commit: r1469590 - in /sis/branches/JDK7/sis-metadata/src:
main/java/org/apache/sis/metadata/ test/java/org/apache/sis/metadata/
Author: desruisseaux
Date: Thu Apr 18 21:49:52 2013
New Revision: 1469590
URL: http://svn.apache.org/r1469590
Log:
Added MetadataStandard.asNameMap and asTypeMap methods.
Added:
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java (with props)
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeMap.java (with props)
Modified:
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyMap.java
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ValueMap.java
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java?rev=1469590&r1=1469589&r2=1469590&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/InformationMap.java Thu Apr 18 21:49:52 2013
@@ -38,19 +38,11 @@ final class InformationMap extends Prope
/**
* Creates an information map for the specified accessor.
*
- * @param accessor The accessor to use for the metadata.
- * @param keyNames Determines the string representation of keys in the map.
+ * @param accessor The accessor to use for the metadata.
+ * @param keyPolicy Determines the string representation of keys in the map.
*/
- InformationMap(final PropertyAccessor accessor, final KeyNamePolicy keyNames) {
- super(accessor, keyNames);
- }
-
- /**
- * Returns {@code true} if this map contains a mapping for the specified key.
- */
- @Override
- public boolean containsKey(final Object key) {
- return get(key) != null;
+ InformationMap(final PropertyAccessor accessor, final KeyNamePolicy keyPolicy) {
+ super(accessor, keyPolicy);
}
/**
@@ -71,13 +63,6 @@ final class InformationMap extends Prope
@Override
final Iterator<Map.Entry<String,ExtendedElementInformation>> iterator() {
return new Iter() {
- private int index;
-
- @Override
- public boolean hasNext() {
- return index < accessor.count();
- }
-
@Override
public Map.Entry<String,ExtendedElementInformation> next() {
final ExtendedElementInformation value = accessor.information(index);
@@ -85,8 +70,7 @@ final class InformationMap extends Prope
// PropertyAccessor.information(int) never return null if the index is valid.
throw new NoSuchElementException();
}
- index++;
- return new SimpleImmutableEntry<>(accessor.name(index, keyPolicy), value);
+ return new SimpleImmutableEntry<>(accessor.name(index++, keyPolicy), value);
}
};
}
Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java?rev=1469590&r1=1469589&r2=1469590&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/MetadataStandard.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -423,8 +423,87 @@ public class MetadataStandard {
}
/**
- * Returns information about a metadata type as {@link Map}. The returned map contains information
- * inferred from the ISO names, the {@link org.opengis.annotation.Obligation} enumeration and the
+ * Returns the names of all properties defined in the given metadata type.
+ * The property names appears both as keys and as values, but may be written differently.
+ * The names may be {@linkplain KeyNamePolicy#UML_IDENTIFIER standard identifiers} (e.g.
+ * as defined by ISO 19115), {@linkplain KeyNamePolicy#JAVABEANS_PROPERTY JavaBeans names},
+ * {@linkplain KeyNamePolicy#METHOD_NAME method names} or {@linkplain KeyNamePolicy#SENTENCE
+ * sentences} (usually in English).
+ *
+ * <p><b>Example:</b> The {@code value} in the following code is
+ * <code>"alternateTitle<u>s</u>"</code> (note the plural):</p>
+ *
+ * {@preformat java
+ * MetadataStandard standard = MetadataStandard.ISO_19115;
+ * Map<String, String> names = standard.asNameMap(Citation.class, UML_IDENTIFIER, JAVABEANS_PROPERTY);
+ * String value = names.get("alternateTitle"); // alternateTitles
+ * }
+ *
+ * The {@code keyPolicy} argument specify only the string representation of keys returned by the iterators.
+ * No matter the key name policy, the {@code key} argument given to any {@link Map} method can be any of the
+ * above-cited forms of property names.
+ *
+ * @param type The interface or implementation class of a metadata.
+ * @param keyPolicy Determines the string representation of map keys.
+ * @param valuePolicy Determines the string representation of map values.
+ * @return The names of all properties defined by the given metadata type.
+ * @throws ClassCastException if the specified interface or implementation class does
+ * not extend or implement a metadata interface of the expected package.
+ */
+ public Map<String,String> asNameMap(Class<?> type, final KeyNamePolicy keyPolicy,
+ final KeyNamePolicy valuePolicy) throws ClassCastException
+ {
+ ensureNonNull("type", type);
+ ensureNonNull("keyPolicy", keyPolicy);
+ ensureNonNull("valuePolicy", valuePolicy);
+ final Class<?> implementation = getImplementation(type);
+ if (implementation != null) {
+ type = implementation;
+ }
+ return new NameMap(getAccessor(type, true), keyPolicy, valuePolicy);
+ }
+
+ /**
+ * Returns the type of all properties, or their declaring type, defined in the given
+ * metadata type. The keys in the returned map are the same than the keys in the above
+ * {@linkplain #asNameMap name map}. The values are determined by the {@code valuePolicy}
+ * argument, which can be {@linkplain TypeValuePolicy#ELEMENT_TYPE element type} or the
+ * {@linkplain TypeValuePolicy#DECLARING_INTERFACE declaring interface} among others.
+ *
+ * <p><b>Example:</b> The {@code value} in the following code is {@code InternationalString.class}:</p>
+ *
+ * {@preformat java
+ * MetadataStandard standard = MetadataStandard.ISO_19115;
+ * Map<String,Class<?>> types = standard.asTypeMap(Citation.class, UML_IDENTIFIER, ELEMENT_TYPE);
+ * Class<?> value = names.get("alternateTitle"); // InternationalString.class
+ * }
+ *
+ * @param type The interface or implementation class of a metadata.
+ * @param keyPolicy Determines the string representation of map keys.
+ * @param valuePolicy Whether the values shall be property types, the element types
+ * (same as property types except for collections) or the declaring interface or class.
+ * @return The types or declaring type of all properties defined in the given metadata type.
+ * @throws ClassCastException if the specified interface or implementation class does
+ * not extend or implement a metadata interface of the expected package.
+ */
+ public Map<String,Class<?>> asTypeMap(Class<?> type, final KeyNamePolicy keyPolicy,
+ final TypeValuePolicy valuePolicy) throws ClassCastException
+ {
+ ensureNonNull("type", type);
+ ensureNonNull("keyPolicy", keyPolicy);
+ ensureNonNull("valuePolicy", valuePolicy);
+ final Class<?> implementation = getImplementation(type);
+ if (implementation != null) {
+ type = implementation;
+ }
+ return new TypeMap(getAccessor(type, true), keyPolicy, valuePolicy);
+ }
+
+ /**
+ * Returns information about all properties defined in the given metadata type.
+ * The keys in the returned map are the same than the keys in the above
+ * {@linkplain #asNameMap name map}. The values contain information inferred from
+ * the ISO names, the {@link org.opengis.annotation.Obligation} enumeration and the
* {@link org.apache.sis.measure.ValueRange} annotations.
*
* <p>In the particular case of Apache SIS implementation, all values in the information map
@@ -452,23 +531,22 @@ public class MetadataStandard {
* <li>{@link org.apache.sis.measure.NumberRange} if the valid values are constrained to some specific range.</li>
* </ul>
*
- * @param type The metadata interface or implementation class.
- * @param keyNames Determines the string representation of map keys.
- * @return The restrictions that are violated by the given metadata instance,
- * or all restrictions if {@code metadata} is a {@link Class}.
+ * @param type The metadata interface or implementation class.
+ * @param keyPolicy Determines the string representation of map keys.
+ * @return Information about all properties defined in the given metadata type.
* @throws ClassCastException if the given type doesn't implement a metadata
* interface of the expected package.
*/
public Map<String,ExtendedElementInformation> asInformationMap(Class<?> type,
- final KeyNamePolicy keyNames) throws ClassCastException
+ final KeyNamePolicy keyPolicy) throws ClassCastException
{
ensureNonNull("type", type);
- ensureNonNull("keyNames", keyNames);
+ ensureNonNull("keyNames", keyPolicy);
final Class<?> implementation = getImplementation(type);
if (implementation != null) {
type = implementation;
}
- return new InformationMap(getAccessor(type, true), keyNames);
+ return new InformationMap(getAccessor(type, true), keyPolicy);
}
/**
Added: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java?rev=1469590&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java (added)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+
+/**
+ * Map of property names for a given implementation class. This map is read-only.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3 (derived from geotk-3.04)
+ * @version 0.3
+ * @module
+ *
+ * @see MetadataStandard#asNameMap(Class, KeyNamePolicy, KeyNamePolicy)
+ */
+final class NameMap extends PropertyMap<String> {
+ /**
+ * Determines the string representation of values in this map.
+ */
+ final KeyNamePolicy valuePolicy;
+
+ /**
+ * Creates a name map for the specified accessor.
+ *
+ * @param accessor The accessor to use for the metadata.
+ * @param keyPolicy Determines the string representation of keys in the map.
+ * @param valuePolicy Determines the string representation of values in this map.
+ */
+ NameMap(final PropertyAccessor accessor, final KeyNamePolicy keyPolicy, final KeyNamePolicy valuePolicy) {
+ super(accessor, keyPolicy);
+ this.valuePolicy = valuePolicy;
+ }
+
+ /**
+ * Returns the value to which the specified key is mapped, or {@code null}
+ * if this map contains no mapping for the key.
+ */
+ @Override
+ public String get(final Object key) {
+ if (key instanceof String) {
+ return accessor.name(accessor.indexOf((String) key, false), valuePolicy);
+ }
+ return null;
+ }
+
+ /**
+ * Returns an iterator over the entries contained in this map.
+ */
+ @Override
+ final Iterator<Map.Entry<String,String>> iterator() {
+ return new Iter() {
+ @Override
+ public Map.Entry<String,String> next() {
+ final String value = accessor.name(index, valuePolicy);
+ if (value == null) {
+ // PropertyAccessor.name(int) never return null if the index is valid.
+ throw new NoSuchElementException();
+ }
+ return new SimpleImmutableEntry<>(accessor.name(index++, keyPolicy), value);
+ }
+ };
+ }
+}
Propchange: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/NameMap.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyMap.java?rev=1469590&r1=1469589&r2=1469590&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyMap.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyMap.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -77,6 +77,17 @@ abstract class PropertyMap<V> extends Ab
}
/**
+ * Returns {@code true} if this map contains a mapping for the specified key.
+ * The default implementation is okay only if all metadata defined by the standard are included
+ * in the map. Subclasses shall override this method if their map contain only a subset of all
+ * possible metadata elements.
+ */
+ @Override
+ public boolean containsKey(final Object key) {
+ return (key instanceof String) && accessor.indexOf((String) key, false) >= 0;
+ }
+
+ /**
* Returns a view of the mappings contained in this map. Subclasses shall override this method
* if they define a different entries set class than the default {@link Entries} inner class.
*/
@@ -106,17 +117,29 @@ abstract class PropertyMap<V> extends Ab
*/
abstract class Iter implements Iterator<Map.Entry<String,V>> {
/**
+ * Index of the next element to return.
+ */
+ int index;
+
+ /**
* Creates a new iterator.
*/
Iter() {
}
/**
+ * Returns {@code true} if there is more elements to return.
+ */
+ @Override
+ public final boolean hasNext() {
+ return index < accessor.count();
+ }
+
+ /**
* Assumes that the underlying map is unmodifiable.
- * Only {@link ValueMap} supports this method.
*/
@Override
- public void remove() {
+ public final void remove() {
throw new UnsupportedOperationException();
}
}
Added: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeMap.java?rev=1469590&view=auto
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeMap.java (added)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeMap.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.metadata;
+
+import java.util.Map;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+
+/**
+ * Map of property valuePolicy for a given implementation class. This map is read-only.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3 (derived from geotk-3.03)
+ * @version 0.3
+ * @module
+ *
+ * @see MetadataStandard#asTypeMap(Class, KeyNamePolicy, TypeValuePolicy)
+ */
+final class TypeMap extends PropertyMap<Class<?>> {
+ /**
+ * The kind of values in this map.
+ */
+ final TypeValuePolicy valuePolicy;
+
+ /**
+ * Creates a type map for the specified accessor.
+ *
+ * @param accessor The accessor to use for the metadata.
+ * @param keyPolicy Determines the string representation of keys in the map..
+ * @param valuePolicy The kind of values in this map.
+ */
+ TypeMap(final PropertyAccessor accessor, final KeyNamePolicy keyPolicy, final TypeValuePolicy valuePolicy) {
+ super(accessor, keyPolicy);
+ this.valuePolicy = valuePolicy;
+ }
+
+ /**
+ * Returns the value to which the specified key is mapped, or {@code null}
+ * if this map contains no mapping for the key.
+ */
+ @Override
+ public Class<?> get(final Object key) {
+ if (key instanceof String) {
+ return accessor.type(accessor.indexOf((String) key, false), valuePolicy);
+ }
+ return null;
+ }
+
+ /**
+ * Returns an iterator over the entries contained in this map.
+ */
+ @Override
+ final Iterator<Map.Entry<String,Class<?>>> iterator() {
+ return new Iter() {
+ @Override
+ public Map.Entry<String,Class<?>> next() {
+ final Class<?> value = accessor.type(index, valuePolicy);
+ if (value == null) {
+ // PropertyAccessor.type(int) never return null if the index is valid.
+ throw new NoSuchElementException();
+ }
+ return new SimpleImmutableEntry<String,Class<?>>(accessor.name(index++, keyPolicy), value);
+ }
+ };
+ }
+}
Propchange: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeMap.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java?rev=1469590&r1=1469589&r2=1469590&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/TypeValuePolicy.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -53,16 +53,16 @@ public enum TypeValuePolicy {
ELEMENT_TYPE,
/**
- * The type of the class that declares the method. A metadata implementation may have
- * different declaring classes for its properties if some of them are declared in parent
- * classes.
+ * The type of the interface that declares the method. For any metadata object, different
+ * properties may have different declaring interfaces if some properties were inherited
+ * from parent interfaces.
*/
- DECLARING_CLASS,
+ DECLARING_INTERFACE,
/**
- * The type of the interface that declares the method. This is the same than
- * {@link #DECLARING_CLASS}, except that the interface from the metadata standard
- * is returned instead than the implementation class.
+ * The type of the class that declares the method. This is similar to
+ * {@link #DECLARING_INTERFACE}, except that the implementation class
+ * from the metadata standard is returned instead than the interface.
*/
- DECLARING_INTERFACE
+ DECLARING_CLASS
}
Modified: sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ValueMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ValueMap.java?rev=1469590&r1=1469589&r2=1469590&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ValueMap.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ValueMap.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -41,7 +41,7 @@ final class ValueMap extends PropertyMap
/**
* The metadata object to wrap.
*/
- private final Object metadata;
+ final Object metadata;
/**
* The behavior of this map toward null or empty values.
@@ -279,7 +279,7 @@ final class ValueMap extends PropertyMap
* @version 0.3
* @module
*/
- private final class Iter extends PropertyMap<Object>.Iter {
+ private final class Iter implements Iterator<Map.Entry<String,Object>> {
/**
* The current and the next property, or {@code null} if the iteration is over.
*/
Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java?rev=1469590&r1=1469589&r2=1469590&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataStandardTest.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -20,7 +20,14 @@ import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.Collection;
+import java.util.Date;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.Identifier;
+import org.opengis.metadata.citation.Series;
import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.citation.CitationDate;
+import org.opengis.metadata.citation.ResponsibleParty;
+import org.opengis.metadata.citation.PresentationForm;
import org.opengis.metadata.quality.Completeness;
import org.opengis.metadata.ExtendedElementInformation;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
@@ -34,6 +41,7 @@ import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.opengis.test.Assert.*;
+import static java.util.AbstractMap.SimpleEntry;
/**
@@ -116,6 +124,80 @@ public final strictfp class MetadataStan
}
/**
+ * Tests the {@link MetadataStandard#asName(Class, KeyNamePolicy, KeyNamePolicy)} implementation.
+ * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
+ *
+ * @see PropertyAccessorTest#testConstructor()
+ */
+ @Test
+ public void testNameMap() {
+ final Map<String,String> map = MetadataStandard.ISO_19115.asNameMap(
+ Citation.class, KeyNamePolicy.UML_IDENTIFIER, KeyNamePolicy.JAVABEANS_PROPERTY);
+ assertArrayEquals(new Object[] {
+ new SimpleEntry<>("title", "title"),
+ new SimpleEntry<>("alternateTitle", "alternateTitles"),
+ new SimpleEntry<>("date", "dates"),
+ new SimpleEntry<>("edition", "edition"),
+ new SimpleEntry<>("editionDate", "editionDate"),
+ new SimpleEntry<>("identifier", "identifiers"),
+ new SimpleEntry<>("citedResponsibleParty", "citedResponsibleParties"),
+ new SimpleEntry<>("presentationForm", "presentationForms"),
+ new SimpleEntry<>("series", "series"),
+ new SimpleEntry<>("otherCitationDetails", "otherCitationDetails"),
+ new SimpleEntry<>("collectiveTitle", "collectiveTitle"),
+ new SimpleEntry<>("ISBN", "ISBN"),
+ new SimpleEntry<>("ISSN", "ISSN")
+ }, map.entrySet().toArray());
+
+ assertEquals("alternateTitles", map.get("alternateTitle"));
+ assertNull("Shall not exists.", map.get("dummy"));
+ }
+
+ /**
+ * Tests the {@link MetadataStandard#asType(Class, KeyNamePolicy, TypeValuePolicy)} implementation.
+ * The properties used in this test are listed in {@link PropertyAccessorTest#testConstructor()}.
+ *
+ * @see PropertyAccessorTest#testConstructor()
+ */
+ @Test
+ public void testTypeMap() {
+ final Map<String,Class<?>> map = MetadataStandard.ISO_19115.asTypeMap(
+ Citation.class, KeyNamePolicy.UML_IDENTIFIER, TypeValuePolicy.ELEMENT_TYPE);
+ assertArrayEquals(new Object[] {
+ new SimpleEntry<>("title", InternationalString.class),
+ new SimpleEntry<>("alternateTitle", InternationalString.class),
+ new SimpleEntry<>("date", CitationDate.class),
+ new SimpleEntry<>("edition", InternationalString.class),
+ new SimpleEntry<>("editionDate", Date.class),
+ new SimpleEntry<>("identifier", Identifier.class),
+ new SimpleEntry<>("citedResponsibleParty", ResponsibleParty.class),
+ new SimpleEntry<>("presentationForm", PresentationForm.class),
+ new SimpleEntry<>("series", Series.class),
+ new SimpleEntry<>("otherCitationDetails", InternationalString.class),
+ new SimpleEntry<>("collectiveTitle", InternationalString.class),
+ new SimpleEntry<>("ISBN", String.class),
+ new SimpleEntry<>("ISSN", String.class)
+ }, map.entrySet().toArray());
+
+ assertEquals(InternationalString.class, map.get("alternateTitle"));
+ assertNull("Shall not exists.", map.get("dummy"));
+ }
+
+ /**
+ * Tests the {@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)} implementation.
+ * Note: this test duplicates {@link PropertyInformationTest}, but is done here again as an
+ * integration test.
+ */
+ @Test
+ public void testInformationMap() {
+ final Map<String,ExtendedElementInformation> map = MetadataStandard.ISO_19115.asInformationMap(
+ Citation.class, KeyNamePolicy.JAVABEANS_PROPERTY);
+ PropertyInformationTest.validateTitle(map.get("title"));
+ PropertyInformationTest.validatePresentationForm(map.get("presentationForms"));
+ assertNull("Shall not exists.", map.get("dummy"));
+ }
+
+ /**
* Tests the {@link MetadataStandard#asValueMap(Object, KeyNamePolicy, ValueExistencePolicy)} implementation.
* Note: this test duplicates {@link ValueMapTest}, but is done here again as an integration test.
*/
@@ -153,19 +235,6 @@ public final strictfp class MetadataStan
}
/**
- * Tests the {@link MetadataStandard#asInformationMap(Class, KeyNamePolicy)} implementation.
- * Note: this test duplicates {@link PropertyInformationTest}, but is done here again as an
- * integration test.
- */
- @Test
- public void testInformationMap() {
- final Map<String,ExtendedElementInformation> map = MetadataStandard.ISO_19115.asInformationMap(
- Citation.class, KeyNamePolicy.JAVABEANS_PROPERTY);
- PropertyInformationTest.validateTitle(map.get("title"));
- PropertyInformationTest.validatePresentationForm(map.get("presentationForms"));
- }
-
- /**
* Tests {@link MetadataStandard#hashCode(Object)} using {@link HashSet} as the reference
* implementation for computing hash code values. The hash code is defined as the sum of
* hash code values of all non-empty properties, plus the hash code of the interface.
Modified: sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java?rev=1469590&r1=1469589&r2=1469590&view=diff
==============================================================================
--- sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java [UTF-8] Thu Apr 18 21:49:52 2013
@@ -143,6 +143,11 @@ public final strictfp class PropertyAcce
* Tests the constructor with the {@link DefaultCitation} implementation.
* The order of properties shall be the order declared in the {@code XmlType.propOrder} annotation.
* This test may need to be updated if a future GeoAPI release modifies the {@link Citation} interface.
+ * Other tests that depends on {@link Citation} property order are {@link MetadataStandardTest#testNameMap()}
+ * and {@link MetadataStandardTest#testTypeMap()}</p>
+ *
+ * @see MetadataStandardTest#testNameMap()
+ * @see MetadataStandardTest#testTypeMap()
*/
@Test
public void testConstructor() {