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 2014/05/28 12:33:45 UTC

svn commit: r1597967 - in /sis/branches/JDK8: core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/ core/sis-referencing/src/main/java/org/apache/sis/referencing/ core/sis-utility/src/main/java/org/apache/sis/internal/system/ core/sis-utility/sr...

Author: desruisseaux
Date: Wed May 28 10:33:45 2014
New Revision: 1597967

URL: http://svn.apache.org/r1597967
Log:
Move toGenericNames to DefaultNameFactory, nail down tests to SIS name factory, and add javadoc.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java
    sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
    sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java [UTF-8] Wed May 28 10:33:45 2014
@@ -65,13 +65,11 @@ public final strictfp class CustomMetada
          * A trivial metadata implementation which return the method name
          * for every attribute of type String.
          */
-        final InvocationHandler handler = new InvocationHandler() {
-            @Override public Object invoke(Object proxy, Method method, Object[] args) {
-                if (method.getReturnType() == String.class) {
-                    return method.getName();
-                }
-                return null;
+        final InvocationHandler handler = (Object proxy, Method method, Object[] args) -> {
+            if (method.getReturnType() == String.class) {
+                return method.getName();
             }
+            return null;
         };
         Metadata data = (Metadata) Proxy.newProxyInstance(getClass().getClassLoader(),
                     new Class<?>[] { Metadata.class }, handler);
@@ -101,13 +99,13 @@ public final strictfp class CustomMetada
             @Override public InternationalString getAbstract() {
                 Map<Locale, String> names = new HashMap<>();
                 names.put(Locale.ENGLISH, "Description");
-                return DefaultFactories.NAMES.createInternationalString(names);
+                return DefaultFactories.SIS_NAMES.createInternationalString(names);
             }
 
             @Override public InternationalString getEnvironmentDescription() {
                 Map<Locale, String> names = new HashMap<>();
                 names.put(Locale.ENGLISH, "Environment");
-                return DefaultFactories.NAMES.createInternationalString(names);
+                return DefaultFactories.SIS_NAMES.createInternationalString(names);
             }
 
             @Override public InternationalString                   getSupplementalInformation()    {return null;}

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/AbstractIdentifiedObject.java [UTF-8] Wed May 28 10:33:45 2014
@@ -43,6 +43,7 @@ import org.apache.sis.internal.jaxb.refe
 import org.apache.sis.internal.util.Numerics;
 import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.internal.referencing.WKTUtilities;
+import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.ElementKind;
@@ -312,11 +313,18 @@ public class AbstractIdentifiedObject ex
         // "alias": CharSequence, CharSequence[], GenericName or GenericName[]
         // -------------------------------------------------------------------
         value = properties.get(ALIAS_KEY);
+        final GenericName[] names;
         try {
-            alias = immutableSet(true, org.apache.sis.util.iso.Names.toGenericNames(value));
+            /*
+             * Note: DefaultFactories.SIS_NAMES is guarantee to be a DefaultNameFactory class, not a sub-class.
+             * However for the purpose of this method, any sub-class would be okay. We should revisit this code
+             * with this flexibility in mind when we will use dependency injection.
+             */
+            names = DefaultFactories.SIS_NAMES.toGenericNames(value);
         } catch (ClassCastException e) {
             throw (IllegalArgumentException) illegalPropertyType(properties, ALIAS_KEY, value).initCause(e);
         }
+        alias = immutableSet(true, names);
 
         // -----------------------------------------------------------
         // "identifiers": ReferenceIdentifier or ReferenceIdentifier[]

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] Wed May 28 10:33:45 2014
@@ -29,7 +29,7 @@ import org.apache.sis.util.iso.DefaultNa
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.5
  * @module
  */
 public final class DefaultFactories extends SystemListener {
@@ -37,8 +37,11 @@ public final class DefaultFactories exte
      * A name factory which is guaranteed to be an instance of SIS {@link DefaultNameFactory}.
      * We use this factory when we need to ensure that the created names are instances of the
      * SIS {@link org.apache.sis.util.iso.AbstractName} implementation.
+     *
+     * <p>Note that this need to be the exact SIS class, not a user-provided subclass,
+     * otherwise we could not guarantee the above-cited requirement.</p>
      */
-    public static final NameFactory SIS_NAMES = new DefaultNameFactory();
+    public static final DefaultNameFactory SIS_NAMES = new DefaultNameFactory();
 
     /**
      * The factory to use for creating names, not necessarily SIS instances.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] Wed May 28 10:33:45 2014
@@ -36,14 +36,14 @@ import java.util.Objects;
 
 /**
  * Base class for sequence of identifiers rooted within the context of a {@linkplain DefaultNameSpace namespace}.
- * Names shall be <em>immutable</em> and thread-safe. A name may be:
+ * Names shall be <em>immutable</em> and thread-safe. A name can be local to a namespace.
+ * See the {@linkplain org.apache.sis.util.iso package javadoc} for an illustration of name anatomy.
  *
- * <ul>
- *   <li>{@linkplain #toFullyQualifiedName() fully qualified} (e.g. {@code "org.apache.sis.util.iso"}), or</li>
- *   <li>relative to a {@linkplain #scope() scope} (e.g. {@code "util.iso"} in the {@code "org.apache.sis"} namespace).</li>
- * </ul>
- *
- * See the {@linkplain org.apache.sis.util.iso package javadoc} for an illustration.
+ * <p>The easiest way to create a name is to use the {@link Names#createLocalName(CharSequence, CharSequence)}
+ * convenience static method. That method supports the common case where the name is made only of a
+ * (<var>namespace</var>, <var>local part</var>) pair of strings. However generic names can be more fine grained.
+ * For example the above-cited strings can both be split in finer components.
+ * For finer grain control, use {@link DefaultNameFactory} instead of {@link Names}.</p>
  *
  * {@section <code>Comparable</code> ordering}
  * This class has a natural ordering that is inconsistent with {@link #equals(Object)}.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameFactory.java [UTF-8] Wed May 28 10:33:45 2014
@@ -21,6 +21,8 @@ import java.util.List;
 import java.util.Arrays;
 import java.util.Locale;
 import java.util.ArrayList;
+import java.util.Collection;
+import org.opengis.metadata.Identifier;
 import org.opengis.util.TypeName;
 import org.opengis.util.NameSpace;
 import org.opengis.util.LocalName;
@@ -58,6 +60,7 @@ import static org.apache.sis.util.iso.De
  *
  * <ul>
  *   <li>{@link #parseGenericName(NameSpace, CharSequence)}</li>
+ *   <li>{@link #toGenericNames(Object)}</li>
  * </ul>
  *
  * {@section Thread safety}
@@ -67,7 +70,7 @@ import static org.apache.sis.util.iso.De
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.5
  * @module
  */
 public class DefaultNameFactory extends AbstractFactory implements NameFactory {
@@ -283,4 +286,90 @@ public class DefaultNameFactory extends 
         }
         return createGenericName(scope, names.toArray(new String[names.size()]));
     }
+
+    /**
+     * Converts the given value to an array of generic names. If the given value is an instance of
+     * {@link GenericName}, {@link String} or any other type enumerated below, then it is converted
+     * and returned in an array of length 1. If the given value is an array or a collection, then an
+     * array of same length is returned where each element has been converted.
+     *
+     * <p>Allowed types or element types are:</p>
+     * <ul>
+     *   <li>{@link GenericName}, to be casted and returned as-is.</li>
+     *   <li>{@link CharSequence} (usually a {@link String} or an {@link InternationalString}),
+     *       to be parsed as a generic name using the {@link DefaultNameSpace#DEFAULT_SEPARATOR ':'} separator.</li>
+     *   <li>{@link Identifier}, its {@linkplain Identifier#getCode() code} to be parsed as a generic name
+     *       using the {@link DefaultNameSpace#DEFAULT_SEPARATOR ':'} separator.</li>
+     * </ul>
+     *
+     * If {@code value} is an array or a collection containing {@code null} elements,
+     * then the corresponding element in the returned array will also be {@code null}.
+     *
+     * @param  value The object to cast into an array of generic names, or {@code null}.
+     * @return The generic names, or {@code null} if the given {@code value} was null.
+     *         Note that it may be the {@code value} reference itself casted to {@code GenericName[]}.
+     * @throws ClassCastException if {@code value} can't be casted.
+     *
+     * @since 0.5
+     */
+    public GenericName[] toGenericNames(Object value) throws ClassCastException {
+        if (value == null) {
+            return null;
+        }
+        GenericName name = toGenericName(value);
+        if (name != null) {
+            return new GenericName[] {
+                name
+            };
+        }
+        /*
+         * Above code checked for a singleton. Now check for a collection or an array.
+         */
+        final Object[] values;
+        if (value instanceof Object[]) {
+            values = (Object[]) value;
+            if (values instanceof GenericName[]) {
+                return (GenericName[]) values;
+            }
+        } else if (value instanceof Collection<?>) {
+            values = ((Collection<?>) value).toArray();
+        } else {
+            throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_2,
+                    "value", value.getClass()));
+        }
+        final GenericName[] names = new GenericName[values.length];
+        for (int i=0; i<values.length; i++) {
+            value = values[i];
+            if (value != null) {
+                name = toGenericName(value);
+                if (name == null) {
+                    throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_2,
+                            "value[" + i + ']', value.getClass()));
+                }
+                names[i] = name;
+            }
+        }
+        return names;
+    }
+
+    /**
+     * Creates a generic name from the given value. The value may be an instance of
+     * {@link GenericName}, {@link Identifier} or {@link CharSequence}. If the given
+     * object is not recognized, then this method returns {@code null}.
+     *
+     * @param  value The object to convert.
+     * @return The converted object, or {@code null} if {@code value} is not convertible.
+     */
+    private GenericName toGenericName(final Object value) {
+        if (value instanceof GenericName) {
+            return (GenericName) value;
+        }
+        if (value instanceof Identifier) {
+            return parseGenericName(null, ((Identifier) value).getCode());
+        }
+        if (value instanceof CharSequence) {
+            return parseGenericName(null, (CharSequence) value);
+        }
+        return null;
+    }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Names.java [UTF-8] Wed May 28 10:33:45 2014
@@ -16,26 +16,42 @@
  */
 package org.apache.sis.util.iso;
 
-import java.util.Collection;
 import java.util.Collections;
 import org.opengis.util.LocalName;
 import org.opengis.util.GenericName;
 import org.opengis.util.NameSpace;
-import org.opengis.util.NameFactory;
 import org.opengis.util.InternationalString;
-import org.opengis.metadata.Identifier;
 import org.apache.sis.util.Static;
-import org.apache.sis.util.resources.Errors;
 import org.apache.sis.internal.system.DefaultFactories;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 
 
 /**
- * Provides static methods for creating, parsing and formatting {@linkplain AbstractName generic names}.
+ * Static methods for creating, parsing and formatting {@linkplain AbstractName generic names}.
+ * This convenience class does not add new functionality compared to {@link DefaultNameFactory},
+ * but makes some tasks easier by avoiding the need to find a factory, and by creating name and
+ * their namespace in a single step.
  *
- * <p>Those convenience methods delegate their work to a default {@linkplain DefaultNameFactory name factory}.
- * Users can get more control by using the name factory directly.</p>
+ * {@section Relationship with Java Content Repository (JCR) names}
+ * In the Java standard {@link javax.xml.namespace.QName} class and in the Java Content Repository (JCR) specification,
+ * a name is an ordered pair of (<var>Name space</var>, <var>Local part</var>) strings. A JCR name can take two lexical
+ * forms: <cite>expanded form</cite> and <cite>qualified form</cite>. Those names are mapped to generic names as below:
+ *
+ * <blockquote><table class="sis">
+ *   <caption>Equivalence between JCR name and {@code GenericName}</caption>
+ *   <tr>
+ *     <th>JCR name</th>
+ *     <th>GeoAPI equivalence</th>
+ *   </tr><tr>
+ *     <td><pre>ExpandedName  ::= '{' Namespace '}' LocalName</pre></td>
+ *     <td>{@code GenericName} with its {@linkplain AbstractName#scope() scope} set to the JCR namespace.</td>
+ *   </tr><tr>
+ *     <td><pre>QualifiedName ::= [Prefix ':'] LocalName</pre></td>
+ *     <td>{@code ScopedName} in the global namespace, with its {@linkplain DefaultScopedName#head() head} or
+ *         {@linkplain DefaultScopedName#path() path} set to the JCR prefix.</td>
+ *   </tr>
+ * </table></blockquote>
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.5
@@ -109,104 +125,12 @@ public final class Names extends Static 
     }
 
     /**
-     * Converts the given value to an array of generic names. If the given value is an instance of
-     * {@link GenericName}, {@link String} or any other type enumerated below, then it is converted
-     * and returned in an array of length 1. If the given value is an array or a collection, then an
-     * array of same length is returned where each element has been converted.
-     *
-     * <p>Allowed types or element types are:</p>
-     * <ul>
-     *   <li>{@link GenericName}, to be casted and returned as-is.</li>
-     *   <li>{@link CharSequence} (usually a {@link String} or an {@link InternationalString}),
-     *       to be parsed as a generic name using the {@link DefaultNameSpace#DEFAULT_SEPARATOR ':'} separator.</li>
-     *   <li>{@link Identifier}, its {@linkplain Identifier#getCode() code} to be parsed as a generic name
-     *       using the {@link DefaultNameSpace#DEFAULT_SEPARATOR ':'} separator.</li>
-     * </ul>
-     *
-     * If {@code value} is an array or a collection containing {@code null} elements,
-     * then the corresponding element in the returned array will also be {@code null}.
-     *
-     * @param  value The object to cast into an array of generic names, or {@code null}.
-     * @return The generic names, or {@code null} if the given {@code value} was null.
-     *         Note that it may be the {@code value} reference itself casted to {@code GenericName[]}.
-     * @throws ClassCastException if {@code value} can't be casted.
-     */
-    public static GenericName[] toGenericNames(Object value) throws ClassCastException {
-        if (value == null) {
-            return null;
-        }
-        return toGenericNames(value, DefaultFactories.NAMES);
-    }
-
-    /**
-     * Implementation of {@link #toGenericName(Object)} using the given factory.
-     */
-    static GenericName[] toGenericNames(Object value, final NameFactory factory) throws ClassCastException {
-        GenericName name = toGenericName(value, factory);
-        if (name != null) {
-            return new GenericName[] {
-                name
-            };
-        }
-        /*
-         * Above code checked for a singleton. Now check for a collection or an array.
-         */
-        final Object[] values;
-        if (value instanceof Object[]) {
-            values = (Object[]) value;
-            if (values instanceof GenericName[]) {
-                return (GenericName[]) values;
-            }
-        } else if (value instanceof Collection<?>) {
-            values = ((Collection<?>) value).toArray();
-        } else {
-            throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_2,
-                    "value", value.getClass()));
-        }
-        final GenericName[] names = new GenericName[values.length];
-        for (int i=0; i<values.length; i++) {
-            value = values[i];
-            if (value != null) {
-                name = toGenericName(value, factory);
-                if (name == null) {
-                    throw new ClassCastException(Errors.format(Errors.Keys.IllegalArgumentClass_2,
-                            "value[" + i + ']', value.getClass()));
-                }
-                names[i] = name;
-            }
-        }
-        return names;
-    }
-
-    /**
-     * Creates a generic name from the given value. The value may be an instance of
-     * {@link GenericName}, {@link Identifier} or {@link CharSequence}. If the given
-     * object is not recognized, then this method returns {@code null}.
-     *
-     * @param  value The object to convert.
-     * @param  factory The factory to use for creating names.
-     * @return The converted object, or {@code null} if {@code value} is not convertible.
-     */
-    private static GenericName toGenericName(final Object value, final NameFactory factory) {
-        if (value instanceof GenericName) {
-            return (GenericName) value;
-        }
-        if (value instanceof Identifier) {
-            return factory.parseGenericName(null, ((Identifier) value).getCode());
-        }
-        if (value instanceof CharSequence) {
-            return factory.parseGenericName(null, (CharSequence) value);
-        }
-        return null;
-    }
-
-    /**
      * Formats the given name in <cite>expanded form</cite> close to the Java Content Repository (JCR) definition.
      * The expanded form is defined as below:
      *
-     * <blockquote>ExpandedName ::= '{' NameSpace '}' LocalPart
+     * <blockquote><pre> ExpandedName ::= '{' NameSpace '}' LocalPart
      * NameSpace    ::= {@linkplain AbstractName#scope() scope()}.{@linkplain DefaultNameSpace#name() name()}.toString()
-     * LocalPart    ::= name.{@linkplain AbstractName#toString() toString()}</blockquote>
+     * LocalPart    ::= name.{@linkplain AbstractName#toString() toString()}</pre></blockquote>
      *
      * @param  name The generic name to format in expanded form.
      * @return Expanded form of the given generic name.

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java [UTF-8] Wed May 28 10:33:45 2014
@@ -50,8 +50,6 @@ import org.apache.sis.internal.system.De
  * This class provides:
  *
  * <ul>
- *   <li>{@link #toInternationalString(CharSequence)} and {@link #toGenericName(Object, NameFactory)}
- *       for creating name-related objects from various objects.</li>
  *   <li>{@link #getStandardName(Class)}, {@link #getListName(CodeList)} and {@link #getCodeName(CodeList)}
  *       for fetching ISO names if possible.</li>
  *   <li>{@link #getCodeTitle(CodeList)}, {@link #getDescription(CodeList)} and
@@ -62,7 +60,7 @@ import org.apache.sis.internal.system.De
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-3.19)
- * @version 0.4
+ * @version 0.5
  * @module
  */
 public final class Types extends Static {
@@ -89,14 +87,15 @@ public final class Types extends Static 
     /**
      * Returns the ISO name for the given class, or {@code null} if none.
      * This method can be used for GeoAPI interfaces or {@link CodeList}.
-     * Examples:
      *
+     * <div class="note"><b>Examples:</b>
      * <ul>
      *   <li><code>getStandardName({@linkplain org.opengis.metadata.citation.Citation}.class)</code>
      *       (an interface) returns {@code "CI_Citation"}.</li>
      *   <li><code>getStandardName({@linkplain org.opengis.referencing.cs.AxisDirection}.class)</code>
      *       (a code list) returns {@code "CS_AxisDirection"}.</li>
      * </ul>
+     * </div>
      *
      * This method looks for the {@link UML} annotation on the given type. It does not search for
      * parent classes or interfaces if the given type is not directly annotated (i.e. {@code @UML}
@@ -131,13 +130,14 @@ public final class Types extends Static 
      * Returns the ISO classname (if available) or the Java classname (as a fallback)
      * of the given code. This method uses the {@link UML} annotation if it exists, or
      * fallback on the {@linkplain Class#getSimpleName() simple class name} otherwise.
-     * Examples:
      *
+     * <div class="note"><b>Examples:</b>
      * <ul>
      *   <li>{@code getListName(AxisDirection.NORTH)} returns {@code "CS_AxisDirection"}.</li>
      *   <li>{@code getListName(CharacterSet.UTF_8)} returns {@code "MD_CharacterSetCode"}.</li>
      *   <li>{@code getListName(ImagingCondition.BLURRED_IMAGE)} returns {@code "MD_ImagingConditionCode"}.</li>
      * </ul>
+     * </div>
      *
      * @param  code The code for which to get the class name, or {@code null}.
      * @return The ISO (preferred) or Java (fallback) class name, or {@code null} if the given code is null.
@@ -154,13 +154,14 @@ public final class Types extends Static 
     /**
      * Returns the ISO name (if available) or the Java name (as a fallback) of the given code.
      * If the code has no {@link UML} identifier, then the programmatic name is used as a fallback.
-     * Examples:
      *
+     * <div class="note"><b>Examples:</b>
      * <ul>
      *   <li>{@code getCodeName(AxisDirection.NORTH)} returns {@code "north"}.</li>
      *   <li>{@code getCodeName(CharacterSet.UTF_8)} returns {@code "utf8"}.</li>
      *   <li>{@code getCodeName(ImagingCondition.BLURRED_IMAGE)} returns {@code "blurredImage"}.</li>
      * </ul>
+     * </div>
      *
      * @param  code The code for which to get the name, or {@code null}.
      * @return The UML identifiers or programmatic name for the given code,
@@ -187,14 +188,15 @@ public final class Types extends Static 
      *
      * <p>The current heuristic implementation iterates over {@linkplain CodeList#names() all code names},
      * selects the longest one excluding the {@linkplain CodeList#name() field name} if possible, then
-     * {@linkplain CharSequences#camelCaseToSentence(CharSequence) makes a sentence} from that name.
-     * Examples:</p>
+     * {@linkplain CharSequences#camelCaseToSentence(CharSequence) makes a sentence} from that name.</p>
      *
+     * <div class="note"><b>Examples:</b>
      * <ul>
      *   <li>{@code getCodeLabel(AxisDirection.NORTH)} returns {@code "North"}.</li>
      *   <li>{@code getCodeLabel(CharacterSet.UTF_8)} returns {@code "UTF-8"}.</li>
      *   <li>{@code getCodeLabel(ImagingCondition.BLURRED_IMAGE)} returns {@code "Blurred image"}.</li>
      * </ul>
+     * </div>
      *
      * @param  code The code from which to get a title, or {@code null}.
      * @return A unlocalized title for the given code, or {@code null} if the given code is null.
@@ -459,12 +461,13 @@ public final class Types extends Static 
      * Returns the GeoAPI interface for the given ISO name, or {@code null} if none.
      * The identifier argument shall be the value documented in the {@link UML#identifier()}
      * annotation associated with the GeoAPI interface.
-     * Examples:
      *
+     * <div class="note"><b>Examples:</b>
      * <ul>
      *   <li>{@code forStandardName("CI_Citation")}      returns <code>{@linkplain org.opengis.metadata.citation.Citation}.class</code></li>
      *   <li>{@code forStandardName("CS_AxisDirection")} returns <code>{@linkplain org.opengis.referencing.cs.AxisDirection}.class</code></li>
      * </ul>
+     * </div>
      *
      * Only identifiers for the stable part of GeoAPI are recognized. This method does not handle
      * the identifiers for the {@code geoapi-pending} module.
@@ -713,16 +716,16 @@ public final class Types extends Static 
      *         Note that it may be the {@code value} reference itself casted to {@code GenericName[]}.
      * @throws ClassCastException if {@code value} can't be casted.
      *
-     * @deprecated Moved to the {@link Names} class.
+     * @deprecated Moved to {@link DefaultNameFactory#toGenericNames(Object)}.
      */
     @Deprecated
     public static GenericName[] toGenericNames(Object value, NameFactory factory) throws ClassCastException {
         if (value == null) {
             return null;
         }
-        if (factory == null) {
-            factory = DefaultFactories.NAMES;
+        if (!(factory instanceof DefaultNameFactory)) {
+            factory = DefaultFactories.SIS_NAMES;
         }
-       return Names.toGenericNames(value, factory);
+       return ((DefaultNameFactory) factory).toGenericNames(value);
     }
 }

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] Wed May 28 10:33:45 2014
@@ -38,6 +38,12 @@
  *       <li>{@link org.apache.sis.util.iso.DefaultScopedName} for a composite of a <cite>head</cite> name and a <cite>tail</cite> name.</li>
  *     </ul>
  *   </li>
+ *   <li>Static utility methods:
+ *     <ul>
+ *       <li>{@link org.apache.sis.util.iso.Types} for working with UML identifiers of GeoAPI types.</li>
+ *       <li>{@link org.apache.sis.util.iso.Names} for simple operations on {@code GenericName}.</li>
+ *     </ul>
+ *   </li>
  * </ul>
  *
  * {@section Anatomy of a name}
@@ -86,25 +92,9 @@
  *   </tr>
  * </table>
  *
- * <div class="note"><b>Comparison with Java Content Repository (JCR) names</b><br>
- * In the Java standard {@link javax.xml.namespace.QName} class and in the Java Content Repository (JCR) specification,
- * a name is an ordered pair of (<var>Name space</var>, <var>Local part</var>) strings. A JCR name can take two lexical
- * forms: <cite>expanded form</cite> and <cite>qualified form</cite>. Those names are defined as:
- *
- * {@preformat text
- *   ExpandedName  ::= '{' Namespace '}' LocalName
- *   QualifiedName ::= [Prefix ':'] LocalName
- * }
- *
- * In GeoAPI equivalence, an <cite>expanded name</cite> can be a {@code GenericName} with a
- * {@linkplain org.apache.sis.util.iso.AbstractName#scope() scope} set to the namespace,
- * while a <cite>qualified name</cite> can be a {@code ScopedName} in the global namespace.
- * In the later case, the prefix may be the name {@linkplain org.apache.sis.util.iso.DefaultScopedName#head() head}
- * or {@linkplain org.apache.sis.util.iso.DefaultScopedName#path() path}.</div>
- *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.5
  * @module
  */
 @XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GCO, xmlns = {

Modified: sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java [UTF-8] Wed May 28 10:33:45 2014
@@ -85,7 +85,7 @@ public final strictfp class NameMarshall
      */
     @Test
     public void testLocalName() throws JAXBException {
-        final NameFactory factory = DefaultFactories.NAMES;
+        final NameFactory factory = DefaultFactories.SIS_NAMES;
         final LocalName name = factory.createLocalName(null, "An ordinary local name");
         assertEquals("An ordinary local name", name.toString());
         final String expected =
@@ -108,7 +108,7 @@ public final strictfp class NameMarshall
     @Test
     @DependsOnMethod("testLocalName")
     public void testLocalNameWithAmp() throws JAXBException {
-        final NameFactory factory = DefaultFactories.NAMES;
+        final NameFactory factory = DefaultFactories.SIS_NAMES;
         final LocalName name = factory.createLocalName(null, "A name with & and > and <.");
         assertEquals("A name with & and > and <.", name.toString());
         final String expected =
@@ -130,7 +130,7 @@ public final strictfp class NameMarshall
      */
     @Test
     public void testTypeName() throws JAXBException {
-        final NameFactory factory = DefaultFactories.NAMES;
+        final NameFactory factory = DefaultFactories.SIS_NAMES;
         final TypeName name = factory.createTypeName(null, "An other local name");
         assertEquals("An other local name", name.toString());
         final String expected =
@@ -156,7 +156,7 @@ public final strictfp class NameMarshall
      */
     @Test
     public void testScopedName() throws JAXBException {
-        final NameFactory factory = DefaultFactories.NAMES;
+        final NameFactory factory = DefaultFactories.SIS_NAMES;
         final GenericName name = factory.createGenericName(null, "myScope","myName");
         assertEquals("myScope:myName", name.toString());
         final String expected =

Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1597967&r1=1597966&r2=1597967&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] Wed May 28 10:33:45 2014
@@ -782,7 +782,7 @@ final class MetadataReader {
         String name = variable.getName();
         if (name != null && !(name = name.trim()).isEmpty()) {
             if (nameFactory == null) {
-                nameFactory = DefaultFactories.forClass(NameFactory.class);
+                nameFactory = DefaultFactories.NAMES; // Real dependency injection to be used in a future version.
             }
             band.setSequenceIdentifier(nameFactory.createMemberName(null, name,
                     nameFactory.createTypeName(null, variable.getDataTypeName())));