sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1791896 - in /sis/branches/JDK8: core/sis-feature/src/main/java/org/apache/sis/feature/builder/ core/sis-utility/src/main/java/org/apache/sis/util/iso/ storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/
Date Wed, 19 Apr 2017 10:09:04 GMT
Author: desruisseaux
Date: Wed Apr 19 10:09:04 2017
New Revision: 1791896

URL: http://svn.apache.org/viewvc?rev=1791896&view=rev
Log:
Replace FeatureTypeBuilder.setDefaultScope(String) by setNameSpace(CharSequence). This allows less verbose GPX FeatureType.

Modified:
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java
    sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.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/DefaultLocalName.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Tags.java
    sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AssociationRoleBuilder.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -130,32 +130,52 @@ public final class AssociationRoleBuilde
     }
 
     /**
-     * Sets the {@code FeatureAssociationRole} name as a simple string with the default scope.
-     * The default scope is the value specified by the last call to
-     * {@link FeatureTypeBuilder#setDefaultScope(String)}.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if no default scope
-     * has been specified, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
+     * Sets the {@code FeatureAssociationRole} name as a simple string (local name).
+     * The namespace will be the value specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)},
+     * but that namespace will not be visible in the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toString()
+     * string representation} unless the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toFullyQualifiedName()
+     * fully qualified name} is requested.
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} instance from
+     * the given {@code CharSequence}, then delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public AssociationRoleBuilder setName(final String localPart) {
+    public AssociationRoleBuilder setName(final CharSequence localPart) {
         super.setName(localPart);
         return this;
     }
 
     /**
      * Sets the {@code FeatureAssociationRole} name as a string in the given scope.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if the given scope is
-     * {@code null} or empty, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
-     * If a {@linkplain FeatureTypeBuilder#setDefaultScope(String) default scope} has been specified, then the
-     * {@code scope} argument overrides it.
+     * The {@code components} array must contain at least one element.
+     * The last component (the {@linkplain org.apache.sis.util.iso.DefaultScopedName#tip() tip}) will be sufficient
+     * in many cases for calls to the {@link org.apache.sis.feature.AbstractFeature#getProperty(String)} method.
+     * The other elements before the last one are optional and can be used for resolving ambiguity.
+     * They will be visible as the name {@linkplain org.apache.sis.util.iso.DefaultScopedName#path() path}.
+     *
+     * <div class="note"><b>Example:</b>
+     * a call to {@code setName("A", "B", "C")} will create a "A:B:C" name.
+     * An association built with this name can be obtained from a feature by a call to {@code feature.getProperty("C")}
+     * if there is no ambiguity, or otherwise by a call to {@code feature.getProperty("B:C")} (if non-ambiguous) or
+     * {@code feature.getProperty("A:B:C")}.</div>
+     *
+     * In addition to the path specified by the {@code components} array, the name may also contain
+     * a namespace specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)}.
+     * But contrarily to the specified components, the namespace will not be visible in the name
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toString() string representation} unless the
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toFullyQualifiedName() fully qualified name} is requested.
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} or {@link org.opengis.util.ScopedName}
+     * instance depending on whether the {@code names} array contains exactly 1 element or more than 1 element, then
+     * delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public AssociationRoleBuilder setName(final String scope, final String localPart) {
-        super.setName(scope, localPart);
+    public AssociationRoleBuilder setName(final CharSequence... components) {
+        super.setName(components);
         return this;
     }
 

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/AttributeTypeBuilder.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -185,32 +185,52 @@ public final class AttributeTypeBuilder<
     }
 
     /**
-     * Sets the {@code AttributeType} name as a simple string with the default scope.
-     * The default scope is the value specified by the last call to
-     * {@link FeatureTypeBuilder#setDefaultScope(String)}.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if no default scope
-     * has been specified, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
+     * Sets the {@code AttributeType} name as a simple string (local name).
+     * The namespace will be the value specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)},
+     * but that namespace will not be visible in the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toString()
+     * string representation} unless the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toFullyQualifiedName()
+     * fully qualified name} is requested.
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} instance from
+     * the given {@code CharSequence}, then delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public AttributeTypeBuilder<V> setName(final String localPart) {
+    public AttributeTypeBuilder<V> setName(final CharSequence localPart) {
         super.setName(localPart);
         return this;
     }
 
     /**
      * Sets the {@code AttributeType} name as a string in the given scope.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if the given scope is
-     * {@code null} or empty, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
-     * If a {@linkplain FeatureTypeBuilder#setDefaultScope(String) default scope} has been specified, then the
-     * {@code scope} argument overrides it.
+     * The {@code components} array must contain at least one element.
+     * The last component (the {@linkplain org.apache.sis.util.iso.DefaultScopedName#tip() tip}) will be sufficient
+     * in many cases for calls to the {@link org.apache.sis.feature.AbstractFeature#getProperty(String)} method.
+     * The other elements before the last one are optional and can be used for resolving ambiguity.
+     * They will be visible as the name {@linkplain org.apache.sis.util.iso.DefaultScopedName#path() path}.
+     *
+     * <div class="note"><b>Example:</b>
+     * a call to {@code setName("A", "B", "C")} will create a "A:B:C" name.
+     * An attribute built with this name can be obtained from a feature by a call to {@code feature.getProperty("C")}
+     * if there is no ambiguity, or otherwise by a call to {@code feature.getProperty("B:C")} (if non-ambiguous) or
+     * {@code feature.getProperty("A:B:C")}.</div>
+     *
+     * In addition to the path specified by the {@code components} array, the name may also contain
+     * a namespace specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)}.
+     * But contrarily to the specified components, the namespace will not be visible in the name
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toString() string representation} unless the
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toFullyQualifiedName() fully qualified name} is requested.
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} or {@link org.opengis.util.ScopedName}
+     * instance depending on whether the {@code names} array contains exactly 1 element or more than 1 element, then
+     * delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public AttributeTypeBuilder<V> setName(final String scope, final String localPart) {
-        super.setName(scope, localPart);
+    public AttributeTypeBuilder<V> setName(final CharSequence... components) {
+        super.setName(components);
         return this;
     }
 

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/CharacteristicTypeBuilder.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -146,42 +146,66 @@ public final class CharacteristicTypeBui
     }
 
     /**
-     * Sets the characteristic name as a simple string with the default scope.
-     * The default scope is the value specified by the last call to
-     * {@link FeatureTypeBuilder#setDefaultScope(String)}.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if no default scope
-     * has been specified, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
+     * Sets the characteristic name as a simple string (local name).
+     * The namespace will be the value specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)},
+     * but that namespace will not be visible in the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toString()
+     * string representation} unless the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toFullyQualifiedName()
+     * fully qualified name} is requested.
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} instance from
+     * the given {@code CharSequence}, then delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public CharacteristicTypeBuilder<V> setName(final String localPart) {
+    public CharacteristicTypeBuilder<V> setName(final CharSequence localPart) {
         super.setName(localPart);
         return this;
     }
 
     /**
      * Sets the characteristic name as a string in the given scope.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if the given scope is
-     * {@code null} or empty, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
-     * If a {@linkplain FeatureTypeBuilder#setDefaultScope(String) default scope} has been specified, then the
-     * {@code scope} argument overrides it.
+     * The {@code components} array must contain at least one element.
+     * The last component (the {@linkplain org.apache.sis.util.iso.DefaultScopedName#tip() tip}) will be sufficient
+     * in many cases for getting values from the {@linkplain org.apache.sis.feature.AbstractAttribute#characteristics()
+     * characteristics} map. The other elements before the last one are optional and can be used for resolving ambiguity.
+     * They will be visible as the name {@linkplain org.apache.sis.util.iso.DefaultScopedName#path() path}.
+     *
+     * <p>In addition to the path specified by the {@code components} array, the name may also contain
+     * a namespace specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)}.
+     * But contrarily to the specified components, the namespace will not be visible in the name
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toString() string representation} unless the
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toFullyQualifiedName() fully qualified name}
+     * is requested.</p>
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} or {@link org.opengis.util.ScopedName}
+     * instance depending on whether the {@code names} array contains exactly 1 element or more than 1 element, then
+     * delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public CharacteristicTypeBuilder<V> setName(final String scope, final String localPart) {
-        super.setName(scope, localPart);
+    public CharacteristicTypeBuilder<V> setName(final CharSequence... components) {
+        super.setName(components);
         return this;
     }
 
     /**
-     * Delegates the creation of a new name to the enclosing builder.
+     * Creates a local name in the {@linkplain FeatureTypeBuilder#setNameSpace feature namespace}.
+     */
+    @Override
+    final GenericName createLocalName(final CharSequence name) {
+        ensureAlive(owner);
+        return owner.createLocalName(name);
+    }
+
+    /**
+     * Creates a generic name in the {@linkplain FeatureTypeBuilder#setNameSpace feature namespace}.
      */
     @Override
-    final GenericName name(final String scope, final String localPart) {
+    final GenericName createGenericName(final CharSequence... names) {
         ensureAlive(owner);
-        return owner.name(scope, localPart);
+        return owner.createGenericName(names);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/FeatureTypeBuilder.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Locale;
 import java.util.Set;
 import java.util.Objects;
+import org.opengis.util.NameSpace;
 import org.opengis.util.GenericName;
 import org.opengis.util.NameFactory;
 import org.opengis.util.FactoryException;
@@ -90,12 +91,12 @@ public class FeatureTypeBuilder extends
     private boolean isAbstract;
 
     /**
-     * The default scope to use when {@link #name(String, String)} is invoked with a null scope.
+     * The namespace to use when a {@link #setName(CharSequence)} method is invoked.
      *
-     * @see #getDefaultScope()
-     * @see #setDefaultScope(String)
+     * @see #getNameSpace()
+     * @see #setNameSpace(CharSequence)
      */
-    private String defaultScope;
+    private NameSpace namespace;
 
     /**
      * The default minimum number of property values.
@@ -318,6 +319,42 @@ public class FeatureTypeBuilder extends
     }
 
     /**
+     * Returns the namespace of the names created by {@code setName(CharSequence...)} method calls.
+     * A {@code null} value means that the names are in the
+     * {@linkplain org.apache.sis.util.iso.DefaultNameSpace#isGlobal() global namespace}.
+     *
+     * @return the namespace to use when {@link #setName(CharSequence)} is invoked, or {@code null} if none.
+     */
+    public CharSequence getNameSpace() {
+        return (namespace != null) ? namespace.name().toString() : null;
+    }
+
+    /**
+     * Sets the namespace of the next names to be created by {@code setName(CharSequence...)} method calls.
+     * This method applies only to the next calls to {@link #setName(CharSequence)} or
+     * {@link #setName(CharSequence...)} methods; the result of all previous calls stay unmodified.
+     *
+     * <p>There is different conventions about the use of name spaces. ISO 19109 suggests that the namespace of all
+     * {@code AttributeType} names is the name of the enclosing {@code FeatureType}, but this is not mandatory.
+     * Users who want to apply this convention can invoke {@code setNameSpace(featureName)} after
+     * <code>{@linkplain #setName(CharSequence) FeatureTypeBuilder.setName}(featureName)</code> but before
+     * <code>{@linkplain AttributeTypeBuilder#setName(CharSequence) AttributeTypeBuilder.setName}(attributeName)</code>.</p>
+     *
+     * @param  ns  the new namespace, or {@code null} if none.
+     * @return {@code this} for allowing method calls chaining.
+     */
+    public FeatureTypeBuilder setNameSpace(final CharSequence ns) {
+        if (ns != null && ns.length() != 0) {
+            namespace = nameFactory.createNameSpace(nameFactory.createLocalName(null, ns), null);
+        } else {
+            namespace = null;
+        }
+        // No need to clear the cache because this change affects
+        // only the next names to be created, not the existing ones.
+        return this;
+    }
+
+    /**
      * Sets the {@code FeatureType} name as a generic name.
      * If another name was defined before this method call, that previous value will be discarded.
      *
@@ -334,83 +371,58 @@ public class FeatureTypeBuilder extends
     }
 
     /**
-     * Sets the {@code FeatureType} name as a simple string with the default scope.
-     * The default scope is the value specified by the last call to {@link #setDefaultScope(String)}.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if no default scope
-     * has been specified, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
+     * Sets the {@code FeatureType} name as a simple string.
+     * The namespace will be the value specified by the last call to {@link #setNameSpace(CharSequence)},
+     * but that namespace will not be visible in the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toString()
+     * string representation} unless the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toFullyQualifiedName()
+     * fully qualified name} is requested.
      *
-     * <p>This convenience method creates a {@link GenericName} instance,
-     * then delegates to {@link #setName(GenericName)}.</p>
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} instance from
+     * the given {@code CharSequence}, then delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public FeatureTypeBuilder setName(final String localPart) {
+    public FeatureTypeBuilder setName(final CharSequence localPart) {
         super.setName(localPart);
         return this;
     }
 
     /**
      * Sets the {@code FeatureType} name as a string in the given scope.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if the given scope is
-     * {@code null} or empty, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
-     * If a {@linkplain #setDefaultScope(String) default scope} has been specified, then the
-     * {@code scope} argument overrides it.
-     *
-     * <p>This convenience method creates a {@link GenericName} instance,
-     * then delegates to {@link #setName(GenericName)}.</p>
+     * The {@code components} array must contain at least one element.
+     * In addition to the path specified by the {@code components} array, the name may also contain
+     * a namespace specified by the last call to {@link #setNameSpace(CharSequence)}.
+     * But contrarily to the specified components, the namespace will not be visible in the name
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toString() string representation} unless the
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toFullyQualifiedName() fully qualified name} is requested.
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} or {@link org.opengis.util.ScopedName}
+     * instance depending on whether the {@code names} array contains exactly 1 element or more than 1 element, then
+     * delegates to {@link #setName(GenericName)}.</p>
      *
      * @return {@code this} for allowing method calls chaining.
      */
     @Override
-    public FeatureTypeBuilder setName(final String scope, final String localPart) {
-        super.setName(scope, localPart);
+    public FeatureTypeBuilder setName(final CharSequence... components) {
+        super.setName(components);
         return this;
     }
 
     /**
-     * Invoked by {@link TypeBuilder} for creating new {@code LocalName} or {@code GenericName} instances.
+     * Creates a local name in the {@linkplain #setNameSpace feature namespace}.
      */
     @Override
-    final GenericName name(String scope, final String localPart) {
-        if (scope == null) {
-            scope = getDefaultScope();
-        }
-        if (scope == null || scope.isEmpty()) {
-            return nameFactory.createLocalName(null, localPart);
-        } else {
-            return nameFactory.createGenericName(null, scope, localPart);
-        }
+    final GenericName createLocalName(final CharSequence name) {
+        return nameFactory.createLocalName(namespace, name);
     }
 
     /**
-     * Returns the scope of the names created by {@code setName(String)} method calls.
-     *
-     * @return the scope to use by default when {@link #setName(String)} is invoked.
+     * Creates a generic name in the {@linkplain #setNameSpace feature namespace}.
      */
-    public String getDefaultScope() {
-        return defaultScope;
-    }
-
-    /**
-     * Sets the scope of the next names created by {@code setName(String)} method calls.
-     * This method applies only to the next calls to {@code setName(String)};
-     * the result of all previous calls stay unmodified.
-     *
-     * <p>There is different conventions about the use of name scopes. ISO 19109 suggests that the scope of all
-     * {@code AttributeType} names is the name of the enclosing {@code FeatureType}, but this is not mandatory.
-     * Users who want to apply this convention can invoke {@code setDefaultScope(featureName)} after
-     * <code>{@linkplain #setName(String) FeatureTypeBuilder.setName}(featureName)</code> but before
-     * <code>{@linkplain AttributeTypeBuilder#setName(String) AttributeTypeBuilder.setName}(attributeName)</code>.</p>
-     *
-     * @param  scope  the new default scope, or {@code null} if none.
-     * @return {@code this} for allowing method calls chaining.
-     */
-    public FeatureTypeBuilder setDefaultScope(final String scope) {
-        defaultScope = scope;
-        // No need to clear the cache because this change affects
-        // only the next names to be created, not the existing ones.
-        return this;
+    @Override
+    final GenericName createGenericName(final CharSequence... names) {
+        return nameFactory.createGenericName(namespace, names);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/PropertyTypeBuilder.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -186,12 +186,21 @@ public abstract class PropertyTypeBuilde
     }
 
     /**
-     * Delegates the creation of a new name to the enclosing builder.
+     * Creates a local name in the {@linkplain FeatureTypeBuilder#setNameSpace feature namespace}.
      */
     @Override
-    final GenericName name(final String scope, final String localPart) {
+    final GenericName createLocalName(final CharSequence name) {
         ensureAlive(owner);
-        return owner.name(scope, localPart);
+        return owner.createLocalName(name);
+    }
+
+    /**
+     * Creates a generic name in the {@linkplain FeatureTypeBuilder#setNameSpace feature namespace}.
+     */
+    @Override
+    final GenericName createGenericName(final CharSequence... names) {
+        ensureAlive(owner);
+        return owner.createGenericName(names);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/builder/TypeBuilder.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -23,6 +23,7 @@ import java.util.Locale;
 import java.util.Objects;
 import org.opengis.util.ScopedName;
 import org.opengis.util.GenericName;
+import org.opengis.util.InternationalString;
 import org.apache.sis.internal.feature.Resources;
 import org.apache.sis.feature.AbstractIdentifiedType;
 import org.apache.sis.util.resources.Vocabulary;
@@ -52,9 +53,12 @@ import org.opengis.feature.PropertyNotFo
  * <div class="section">Default namespace</div>
  * In many cases, the names of all {@code AttributeType}s and {@code AssociationRole}s to create
  * within a {@code FeatureType} share the same namespace.
- * For making name creations more convenient, a default namespace can be
- * {@linkplain FeatureTypeBuilder#setDefaultScope specified once} and applied automatically
- * to all names created by the {@link #setName(String)} method.
+ * For making name creations more convenient, the namespace can be
+ * {@linkplain FeatureTypeBuilder#setNameSpace specified once} and applied automatically
+ * to all names created by the {@link #setName(CharSequence)} method.
+ * Note that namespaces will not be visible in the name {@linkplain org.apache.sis.util.iso.DefaultLocalName#toString()
+ * string representation} unless the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toFullyQualifiedName() fully
+ * qualified name} is requested.
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -126,7 +130,7 @@ public abstract class TypeBuilder implem
                             name = buffer.appendCodePoint(lc).append(name, n, length).toString();
                         }
                     }
-                    identification.put(AbstractIdentifiedType.NAME_KEY, name(null, name));
+                    identification.put(AbstractIdentifiedType.NAME_KEY, createLocalName(name));
                 }
             }
         }
@@ -139,14 +143,14 @@ public abstract class TypeBuilder implem
     abstract void clearCache();
 
     /**
-     * Creates a generic name from the given scope and local part.
-     * An empty scope means no scope. A {@code null} scope means the
-     * {@linkplain FeatureTypeBuilder#setDefaultScope(String) default scope}.
-     *
-     * @param scope      the scope of the name to create, or {@code null} if the name is local.
-     * @param localPart  the local part of the generic name (can not be {@code null}).
+     * Creates a local name in the {@linkplain FeatureTypeBuilder#setNameSpace feature namespace}.
+     */
+    abstract GenericName createLocalName(final CharSequence name);
+
+    /**
+     * Creates a generic name in the {@linkplain FeatureTypeBuilder#setNameSpace feature namespace}.
      */
-    abstract GenericName name(String scope, String localPart);
+    abstract GenericName createGenericName(final CharSequence... names);
 
     /**
      * Returns the name of the {@code IdentifiedType} to create, or {@code null} if undefined.
@@ -155,8 +159,9 @@ public abstract class TypeBuilder implem
      *
      * @return the name of the {@code IdentifiedType} to create (may be a default name or {@code null}).
      *
-     * @see AbstractIdentifiedType#getName()
      * @see #setName(GenericName)
+     * @see AbstractIdentifiedType#getName()
+     * @see FeatureTypeBuilder#getNameSpace()
      */
     public GenericName getName() {
         return (GenericName) identification().get(AbstractIdentifiedType.NAME_KEY);
@@ -190,7 +195,7 @@ public abstract class TypeBuilder implem
      * @return {@code this} for allowing method calls chaining.
      *
      * @see #getName()
-     * @see #setName(String)
+     * @see #setName(CharSequence)
      * @see AbstractIdentifiedType#NAME_KEY
      */
     public TypeBuilder setName(final GenericName name) {
@@ -202,48 +207,64 @@ public abstract class TypeBuilder implem
     }
 
     /**
-     * Sets the {@code IdentifiedType} name as a simple string with the default scope.
-     * The default scope is the value specified by the last call to {@link FeatureTypeBuilder#setDefaultScope(String)}.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if no default scope
-     * has been specified, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
+     * Sets the {@code IdentifiedType} name as a simple string (local name).
+     * The namespace will be the value specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)},
+     * but that namespace will not be visible in the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toString()
+     * string representation} unless the {@linkplain org.apache.sis.util.iso.DefaultLocalName#toFullyQualifiedName()
+     * fully qualified name} is requested.
      *
-     * <p>This convenience method creates a {@link GenericName} instance,
-     * then delegates to {@link #setName(GenericName)}.</p>
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} instance from
+     * the given {@code CharSequence}, then delegates to {@link #setName(GenericName)}.</p>
      *
-     * @param  localPart  the local part of the generic name (can not be {@code null}).
+     * @param  localPart  the local part of the generic name as a {@link String} or {@link InternationalString}.
      * @return {@code this} for allowing method calls chaining.
      *
      * @see #getName()
-     * @see #setName(String, String)
+     * @see #setName(CharSequence...)
+     * @see FeatureTypeBuilder#getNameSpace()
      */
-    public TypeBuilder setName(final String localPart) {
+    public TypeBuilder setName(final CharSequence localPart) {
         ensureNonEmpty("localPart", localPart);
-        return setName(name(null, localPart));
+        return setName(createLocalName(localPart));
     }
 
     /**
      * Sets the {@code IdentifiedType} name as a string in the given scope.
-     * The name will be a {@linkplain org.apache.sis.util.iso.DefaultLocalName local name} if the given scope is
-     * {@code null} or empty, or a {@linkplain org.apache.sis.util.iso.DefaultScopedName scoped name} otherwise.
-     * If a {@linkplain FeatureTypeBuilder#setDefaultScope(String) default scope} has been specified, then the
-     * {@code scope} argument overrides it.
+     * The {@code components} array must contain at least one element.
+     * The last component (the {@linkplain org.apache.sis.util.iso.DefaultScopedName#tip() tip}) will be sufficient
+     * in many cases for calls to the {@link org.apache.sis.feature.AbstractFeature#getProperty(String)} method.
+     * The other elements before the last one are optional and can be used for resolving ambiguity.
+     * They will be visible as the name {@linkplain org.apache.sis.util.iso.DefaultScopedName#path() path}.
+     *
+     * <div class="note"><b>Example:</b>
+     * a call to {@code setName("A", "B", "C")} will create a "A:B:C" name.
+     * A property built with this name can be obtained from a feature by a call to {@code feature.getProperty("C")}
+     * if there is no ambiguity, or otherwise by a call to {@code feature.getProperty("B:C")} (if non-ambiguous) or
+     * {@code feature.getProperty("A:B:C")}.</div>
+     *
+     * In addition to the path specified by the {@code components} array, the name may also contain
+     * a namespace specified by the last call to {@link FeatureTypeBuilder#setNameSpace(CharSequence)}.
+     * But contrarily to the specified components, the namespace will not be visible in the name
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toString() string representation} unless the
+     * {@linkplain org.apache.sis.util.iso.DefaultScopedName#toFullyQualifiedName() fully qualified name} is requested.
+     *
+     * <p>This convenience method creates a {@link org.opengis.util.LocalName} or {@link org.opengis.util.ScopedName}
+     * instance depending on whether the {@code names} array contains exactly 1 element or more than 1 element, then
+     * delegates to {@link #setName(GenericName)}.</p>
      *
-     * <p>This convenience method creates a {@link GenericName} instance,
-     * then delegates to {@link #setName(GenericName)}.</p>
-     *
-     * @param  scope      the scope of the name to create, or {@code null} if the name is local.
-     * @param  localPart  the local part of the generic name (can not be {@code null}).
+     * @param  components  the name components as an array of {@link String} or {@link InternationalString} instances.
      * @return {@code this} for allowing method calls chaining.
      *
      * @see #getName()
-     * @see #setName(String)
+     * @see #setName(CharSequence)
+     * @see FeatureTypeBuilder#getNameSpace()
      */
-    public TypeBuilder setName(String scope, final String localPart) {
-        ensureNonEmpty("localPart", localPart);
-        if (scope == null) {
-            scope = "";                                 // For preventing the use of default scope.
+    public TypeBuilder setName(final CharSequence... components) {
+        ensureNonNull("components", components);
+        if (components.length == 0) {
+            throw new IllegalArgumentException(errors().getString(Errors.Keys.EmptyArgument_1, "components"));
         }
-        return setName(name(scope, localPart));
+        return setName(createGenericName(components));
     }
 
     /**
@@ -469,7 +490,7 @@ public abstract class TypeBuilder implem
      * @throws NullArgumentException if {@code text} is null.
      * @throws IllegalArgumentException if {@code text} is empty.
      */
-    final void ensureNonEmpty(final String name, final String text) {
+    final void ensureNonEmpty(final String name, final CharSequence text) {
         if (text == null) {
             throw new NullArgumentException(errors().getString(Errors.Keys.NullArgument_1, name));
         }

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=1791896&r1=1791895&r2=1791896&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 Apr 19 10:09:04 2017
@@ -341,7 +341,7 @@ public abstract class AbstractName imple
 
     /**
      * An international string built from a snapshot of {@link GenericName}.
-     * This class is immutable is the list given to the constructor is immutable.
+     * This class is immutable if the list given to the constructor is immutable.
      *
      * @author  Martin Desruisseaux (IRD, Geomatys)
      * @version 0.3

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -113,7 +113,7 @@ public class DefaultLocalName extends Ab
     protected DefaultLocalName(NameSpace scope, final CharSequence name) {
         ArgumentChecks.ensureNonNull("name", name);
         if (scope == GlobalNameSpace.GLOBAL) {
-            scope = null; // Handled specially by scope().
+            scope = null;                                       // Handled specially by scope().
         }
         this.scope = scope;
         if (name instanceof InternationalString) {
@@ -323,7 +323,7 @@ public class DefaultLocalName extends Ab
      */
     private Object readResolve() throws ObjectStreamException {
         final DefaultNameSpace ns;
-        if (scope == null) { // Not a bug: readResolve() is intentionally private.
+        if (scope == null) {                    // Not a bug: readResolve() is intentionally private.
             ns = GlobalNameSpace.GLOBAL;
         } else if (scope instanceof DefaultNameSpace) {
             ns = (DefaultNameSpace) scope;

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Reader.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -108,7 +108,7 @@ final class Reader extends StaxStreamRea
      * Returns {@code true} if the given namespace is a GPX namespace or is null.
      */
     private static boolean isGPX(final String ns) {
-        return (ns == null) || ns.startsWith(Tags.NAMESPACE + "/GPX/");
+        return (ns == null) || ns.startsWith(Tags.NAMESPACE);
     }
 
     /**

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Tags.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Tags.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Tags.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Tags.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -33,17 +33,22 @@ final class Tags extends Static {
     /**
      * GPX scope name used for feature type names.
      */
-    static final String NAMESPACE = "http://www.topografix.com";
+    static final String PREFIX = "gpx";
+
+    /**
+     * GPX XML namespace (common root to all versions).
+     */
+    static final String NAMESPACE = "http://www.topografix.com/GPX/";
 
     /**
      * GPX 1.0 XML namespace (v1.0).
      */
-    static final String NAMESPACE_V10 = "http://www.topografix.com/GPX/1/0";
+    static final String NAMESPACE_V10 = NAMESPACE + "1/0";
 
     /**
      * GPX 1.1 XML namespace (v1.1).
      */
-    static final String NAMESPACE_V11 = "http://www.topografix.com/GPX/1/1";
+    static final String NAMESPACE_V11 = NAMESPACE + "1/1";
 
     /** Main GPX XML tags.              */  static final String GPX             = "gpx";
     /** A tag used a bit everywhere.    */  static final String NAME            = "name";

Modified: sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java?rev=1791896&r1=1791895&r2=1791896&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java [UTF-8] Wed Apr 19 10:09:04 2017
@@ -116,7 +116,7 @@ final class Types extends Static {
          * This parent has a single property, "sis:identifier" of type Integer,
          * which is not part of GPX specification.
          *
-         * http://www.topografix.com/GPX/GPXEntity
+         * GPXEntity
          * ┌────────────────┬─────────┬─────────────┐
          * │ Name           │ Type    │ Cardinality │
          * ├────────────────┼─────────┼─────────────┤
@@ -124,11 +124,11 @@ final class Types extends Static {
          * └────────────────┴─────────┴─────────────┘
          */
         FeatureTypeBuilder builder = new FeatureTypeBuilder(null, factory, locale);
-        builder.setDefaultScope(Tags.NAMESPACE).setName("GPXEntity").setAbstract(true);
+        builder.setNameSpace(Tags.PREFIX).setName("GPXEntity").setAbstract(true);
         builder.addAttribute(Integer.class).setName(AttributeConvention.IDENTIFIER_PROPERTY);
         final FeatureType parent = builder.build();
         /*
-         * http://www.topografix.com/GPX/WayPoint ⇾ GPXEntity
+         * WayPoint ⇾ GPXEntity
          * ┌──────────────────┬────────────────┬────────────────────────┬─────────────┐
          * │ Name             │ Type           │ XML type               │ Cardinality │
          * ├──────────────────┼────────────────┼────────────────────────┼─────────────┤
@@ -156,7 +156,7 @@ final class Types extends Static {
          * └──────────────────┴────────────────┴────────────────────────┴─────────────┘
          */
         builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setDefaultScope(Tags.NAMESPACE).setName("WayPoint");
+        builder.setNameSpace(Tags.PREFIX).setName("WayPoint");
         builder.addAttribute(Point.class).setName(geomName)
                 .setCRS(CommonCRS.WGS84.normalizedGeographic())
                 .addRole(AttributeRole.DEFAULT_GEOMETRY);
@@ -181,7 +181,7 @@ final class Types extends Static {
         builder.addAttribute(Integer       .class).setName(Tags.DGPS_ID);
         wayPoint = builder.build();
         /*
-         * http://www.topografix.com/GPX/Route ⇾ GPXEntity
+         * Route ⇾ GPXEntity
          * ┌────────────────┬────────────────┬────────────────────────┬─────────────┐
          * │ Name           │ Type           │ XML type               │ Cardinality │
          * ├────────────────┼────────────────┼────────────────────────┼─────────────┤
@@ -200,7 +200,7 @@ final class Types extends Static {
          */
         GroupAsPolylineOperation groupOp = new GroupPointsAsPolylineOperation(geomInfo, Tags.ROUTE_POINTS);
         builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setDefaultScope(Tags.NAMESPACE).setName("Route");
+        builder.setNameSpace(Tags.PREFIX).setName("Route");
         builder.addProperty(groupOp);
         builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
         builder.setDefaultCardinality(0, 1);
@@ -214,7 +214,7 @@ final class Types extends Static {
         builder.addAssociation(wayPoint).setName(Tags.ROUTE_POINTS).setMaximumOccurs(Integer.MAX_VALUE);
         route = builder.build();
         /*
-         * http://www.topografix.com/GPX/TrackSegment ⇾ GPXEntity
+         * TrackSegment ⇾ GPXEntity
          * ┌────────────────┬──────────┬─────────────┬─────────────┐
          * │ Name           │ Type     │ XML type    │ Cardinality │
          * ├────────────────┼──────────┼─────────────┼─────────────┤
@@ -226,14 +226,14 @@ final class Types extends Static {
          */
         groupOp = new GroupPointsAsPolylineOperation(geomInfo, Tags.TRACK_POINTS);
         builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setDefaultScope(Tags.NAMESPACE).setName("TrackSegment");
+        builder.setNameSpace(Tags.PREFIX).setName("TrackSegment");
         builder.addProperty(groupOp);
         builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
         builder.setDefaultCardinality(0, 1);
         builder.addAssociation(wayPoint).setName(Tags.TRACK_POINTS).setMaximumOccurs(Integer.MAX_VALUE);
         trackSegment = builder.build();
         /*
-         * http://www.topografix.com/GPX/Track ⇾ GPXEntity
+         * Track ⇾ GPXEntity
          * ┌────────────────┬────────────────┬────────────────────────┬─────────────┐
          * │ Name           │ Type           │ XML type               │ Cardinality │
          * ├────────────────┼────────────────┼────────────────────────┼─────────────┤
@@ -252,7 +252,7 @@ final class Types extends Static {
          */
         groupOp = new GroupAsPolylineOperation(geomInfo, Tags.TRACK_SEGMENTS);
         builder = new FeatureTypeBuilder(null, factory, locale).setSuperTypes(parent);
-        builder.setDefaultScope(Tags.NAMESPACE).setName("Track");
+        builder.setNameSpace(Tags.PREFIX).setName("Track");
         builder.addProperty(groupOp);
         builder.addProperty(FeatureOperations.envelope(envpInfo, null, groupOp));
         builder.setDefaultCardinality(0, 1);



Mime
View raw message