Author: desruisseaux
Date: Thu Jun 27 10:56:36 2013
New Revision: 1497295
URL: http://svn.apache.org/r1497295
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
- copied unchanged from r1497293, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
- copied unchanged from r1497293, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
- copied unchanged from r1497293, sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/mock/
- copied from r1497293, sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/mock/
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
- copied unchanged from r1497293, sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/iso/NameMarshallingTest.java
Removed:
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/LocalNameAdapter.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ScopedNameAdapter.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/xml/ReferenceResolverMock.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java
sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java
sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1496965-1497293
Modified: sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -92,8 +92,8 @@
// Java types, primitive types and basic OGC types handling
@XmlJavaTypeAdapter(UnitAdapter.class),
- @XmlJavaTypeAdapter(LocalNameAdapter.class),
@XmlJavaTypeAdapter(InternationalStringAdapter.class),
+ @XmlJavaTypeAdapter(GO_LocalName.class),
@XmlJavaTypeAdapter(GO_DateTime.class),
@XmlJavaTypeAdapter(GO_Decimal.class), @XmlJavaTypeAdapter(type=double.class, value=GO_Decimal.class),
@XmlJavaTypeAdapter(GO_Integer.class), @XmlJavaTypeAdapter(type=int.class, value=GO_Integer.class)
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -16,19 +16,8 @@
*/
package org.apache.sis.internal.jaxb.gco;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.adapters.XmlAdapter;
-
-import org.opengis.util.TypeName;
-import org.opengis.util.LocalName;
-import org.opengis.util.MemberName;
import org.opengis.util.GenericName;
-
import org.apache.sis.util.iso.AbstractName;
-import org.apache.sis.util.iso.DefaultTypeName;
-import org.apache.sis.util.iso.DefaultMemberName;
-import org.apache.sis.util.iso.DefaultScopedName;
-import org.apache.sis.util.resources.Errors;
/**
@@ -50,12 +39,7 @@ import org.apache.sis.util.resources.Err
* @version 0.3
* @module
*/
-public final class GO_GenericName extends XmlAdapter {
- /**
- * The generic name to be marshalled.
- */
- private AbstractName name;
-
+public final class GO_GenericName extends NameAdapter {
/**
* Empty constructor for JAXB only.
*/
@@ -65,128 +49,8 @@ public final class GO_GenericName extend
/**
* Wraps a name at marshalling-time.
*/
- private GO_GenericName(final AbstractName name) {
- this.name = name;
- }
-
- /**
- * Ensures that the {@linkplain #name} is not already defined.
- *
- * @throws IllegalStateException If a name is already defined.
- */
- private void ensureUndefined() throws IllegalStateException {
- if (name != null) {
- throw new IllegalStateException(Errors.format(Errors.Keys.ValueAlreadyDefined_1, "name"));
- }
- }
-
- /**
- * Returns the {@code LocalName} generated from the metadata value.
- * The local name is returned only if it is not a {@link TypeName} or a {@link MemberName}
- * (otherwise, the corresponding {@code getXXX()} method needs to be invoked instead.
- *
- * @return The current local name, or {@code null} if none.
- *
- * @see #getTypeName()
- * @see #getMemberName()
- */
- @XmlElement(name = "LocalName")
- public String getLocalName() {
- final Object name = this.name;
- return (name instanceof LocalName) && !(name instanceof TypeName)
- && !(name instanceof MemberName) ? name.toString() : null;
- }
-
- /**
- * Sets the value for the {@code LocalName}.
- * This method is called at unmarshalling-time by JAXB.
- *
- * @param name The new name.
- * @throws IllegalStateException If a name is already defined.
- */
- public void setLocalName(final String name) throws IllegalStateException {
- ensureUndefined();
- if (name == null) {
- this.name = null;
- } else {
- /*
- * Following cast should be safe because the getNameFactory() method asked specifically
- * for a DefaultNameFactory instance, which is known to create AbstractName instances.
- */
- this.name = (AbstractName) LocalNameAdapter.getNameFactory().createLocalName(null, name);
- }
- }
-
- /**
- * Returns the {@code ScopedName} generated from the metadata value.
- * This method is called at marshalling-time by JAXB.
- *
- * @return The current name, or {@code null} if none.
- */
- @XmlElement(name = "ScopedName")
- public DefaultScopedName getScopedName() {
- final Object name = this.name;
- return (name instanceof DefaultScopedName) ? (DefaultScopedName) name : null;
- }
-
- /**
- * Sets the value for the {@code ScopedName}.
- * This method is called at unmarshalling-time by JAXB.
- *
- * @param name The new name.
- * @throws IllegalStateException If a name is already defined.
- */
- public void setScopedName(final DefaultScopedName name) throws IllegalStateException {
- ensureUndefined();
- this.name = name;
- }
-
- /**
- * Returns the {@code TypeName} generated from the metadata value.
- * This method is called at marshalling-time by JAXB.
- *
- * @return The current name, or {@code null} if none.
- */
- @XmlElement(name = "TypeName")
- public DefaultTypeName getTypeName() {
- final Object name = this.name;
- return (name instanceof DefaultTypeName) ? (DefaultTypeName) name : null;
- }
-
- /**
- * Sets the value for the {@code TypeName}.
- * This method is called at unmarshalling-time by JAXB.
- *
- * @param name The new name.
- * @throws IllegalStateException If a name is already defined.
- */
- public void setTypeName(final DefaultTypeName name) throws IllegalStateException {
- ensureUndefined();
- this.name = name;
- }
-
- /**
- * Returns the {@code MemberName} generated from the metadata value.
- * This method is called at marshalling-time by JAXB.
- *
- * @return The current name, or {@code null} if none.
- */
- @XmlElement(name = "MemberName")
- public DefaultMemberName getMemberName() {
- final Object name = this.name;
- return (name instanceof MemberName) ? (DefaultMemberName) name : null;
- }
-
- /**
- * Sets the value for the {@code MemberName}.
- * This method is called at unmarshalling-time by JAXB.
- *
- * @param name The new name.
- * @throws IllegalStateException If a name is already defined.
- */
- public void setMemberName(final DefaultMemberName name) throws IllegalStateException {
- ensureUndefined();
- this.name = name;
+ private GO_GenericName(final AbstractName value) {
+ name = value;
}
/**
@@ -198,20 +62,7 @@ public final class GO_GenericName extend
*/
@Override
public GO_GenericName marshal(final GenericName value) {
- if (value == null) {
- return null;
- }
- final AbstractName name;
- if (value instanceof AbstractName) {
- name = (AbstractName) value;
- } else {
- /*
- * Following cast should be safe because the getNameFactory() method asked specifically
- * for a DefaultNameFactory instance, which is known to create AbstractName instances.
- */
- name = (AbstractName) ScopedNameAdapter.wrap(value, LocalNameAdapter.getNameFactory());
- }
- return new GO_GenericName(name);
+ return (value != null) ? new GO_GenericName(AbstractName.castOrCopy(value)) : null;
}
/**
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -34,9 +34,18 @@ import org.apache.sis.util.iso.DefaultNa
*/
public final class DefaultFactories extends SystemListener {
/**
- * The factory to use for creating names.
+ * 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.
*/
- public static final NameFactory NAMES = new DefaultNameFactory();
+ public static final NameFactory SIS_NAMES = new DefaultNameFactory();
+
+ /**
+ * The factory to use for creating names, not necessarily SIS instances.
+ * This is fixed to {@link #SIS_NAMES} for now, but will probably be fetched in a more
+ * dynamic way later.
+ */
+ public static final NameFactory NAMES = SIS_NAMES;
/**
* Cache of factories which are found by {@code META-INF/services}.
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -402,7 +402,7 @@ pathTree: for (int j=0; ; j++) {
directory.setValue(NAME, parenthesis(resources.getString(homeKey)));
}
CharSequence title = entry.getValue();
- if (title == null) {
+ if (title == null || title.length() == 0) {
title = parenthesis(resources.getString(entry.getKey().isDirectory() ?
Vocabulary.Keys.Directory : Vocabulary.Keys.Untitled).toLowerCase(locale));
}
@@ -488,6 +488,11 @@ pathTree: for (int j=0; ; j++) {
if (title == null) {
title = concatenate(attributes.getValue(Attributes.Name.SPECIFICATION_TITLE),
attributes.getValue(Attributes.Name.SPECIFICATION_VERSION), false);
+ if (title == null) {
+ // We really need a non-null value in order to protect this code
+ // against infinite recursivity.
+ title = "";
+ }
}
entry.setValue(title);
files = classpath(attributes.getValue(Attributes.Name.CLASS_PATH),
@@ -511,7 +516,7 @@ pathTree: for (int j=0; ; j++) {
}
/**
- * Puts the given file in the given map. IF a value was already associated to the given file,
+ * Puts the given file in the given map. If a value was already associated to the given file,
* then that value is preserved.
*
* @param files The map in which to add the file, or {@code null} if not yet created.
@@ -596,9 +601,10 @@ pathTree: for (int j=0; ; j++) {
* Concatenates the given strings in the format "main (complement)".
* Any of the given strings can be null.
*
- * @param main The main string to show first.
- * @param complement The string to show after the main one.
- * @param parenthesis {@code true} for writing the complement between parenthesis.
+ * @param main The main string to show first, or {@code null}.
+ * @param complement The string to show after the main one, or {@code null}.
+ * @param parenthesis {@code true} for writing the complement between parenthesis, or {@code null}.
+ * @return The concatenated string, or {@code null} if all components are null.
*/
private static CharSequence concatenate(final CharSequence main, final CharSequence complement, final boolean parenthesis) {
if (main != null && main.length() != 0) {
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -19,6 +19,7 @@ package org.apache.sis.util.iso;
import java.util.List;
import java.util.Locale;
import java.util.Iterator;
+import java.util.ConcurrentModificationException;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlType;
import org.opengis.util.NameSpace;
@@ -26,6 +27,7 @@ import org.opengis.util.LocalName;
import org.opengis.util.ScopedName;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
+import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.Immutable;
@@ -89,6 +91,51 @@ public abstract class AbstractName imple
}
/**
+ * Returns a SIS name implementation with the values of the given arbitrary implementation.
+ * This method performs the first applicable actions in the following choices:
+ *
+ *
+ * - If the given object is {@code null}, then this method returns {@code null}.
+ * - Otherwise if the given object is already an instance of {@code AbstractName},
+ * then it is returned unchanged.
+ * - Otherwise if the given object is an instance of {@link LocalName}, then this
+ * method delegates to {@link DefaultLocalName#castOrCopy(LocalName)}.
+ * - Otherwise a new instance of an {@code AbstractName} subclass is created using the
+ * {@link DefaultNameFactory#createGenericName(NameSpace, CharSequence[])} method.
+ *
+ *
+ * @param object The object to get as a SIS implementation, or {@code null} if none.
+ * @return A SIS implementation containing the values of the given object (may be the
+ * given object itself), or {@code null} if the argument was null.
+ */
+ public static AbstractName castOrCopy(final GenericName object) {
+ if (object == null || object instanceof AbstractName) {
+ return (AbstractName) object;
+ }
+ if (object instanceof LocalName) {
+ return DefaultLocalName.castOrCopy((LocalName) object);
+ }
+ /*
+ * Recreates a new name for the given name in order to get
+ * a SIS implementation from an arbitrary implementation.
+ */
+ final List extends LocalName> parsedNames = object.getParsedNames();
+ final CharSequence[] names = new CharSequence[parsedNames.size()];
+ int i=0;
+ for (final LocalName component : parsedNames) {
+ names[i++] = component.toInternationalString();
+ }
+ if (i != names.length) {
+ throw new ConcurrentModificationException(Errors.format(Errors.Keys.UnexpectedChange_1, "parsedNames"));
+ }
+ /*
+ * Following cast should be safe because the SIS_NAMES factory is fixed to a
+ * DefaultNameFactory instance, which is known to create AbstractName instances.
+ */
+ return (AbstractName) DefaultFactories.SIS_NAMES.createGenericName(object.scope(), names);
+ }
+
+ /**
* Returns the scope (name space) in which this name is local. For example if a
* {@linkplain #toFullyQualifiedName() fully qualified name} is {@code "org.opengis.util.Record"}
* and if this instance is the {@code "util.Record"} part, then its scope is
@@ -98,6 +145,8 @@ public abstract class AbstractName imple
* no scope. If this method is invoked on such name, then the SIS implementation returns a
* global scope instance (i.e. an instance for which {@link DefaultNameSpace#isGlobal()}
* returns {@code true}) which is unique and named {@code "global"}.
+ *
+ * @return The scope of this name.
*/
@Override
public abstract NameSpace scope();
@@ -105,6 +154,8 @@ public abstract class AbstractName imple
/**
* Indicates the number of levels specified by this name. The default implementation returns
* the size of the list returned by the {@link #getParsedNames()} method.
+ *
+ * @return The depth of this name.
*/
@Override
public int depth() {
@@ -124,6 +175,9 @@ public abstract class AbstractName imple
* Returns the sequence of {@linkplain DefaultLocalName local names} making this generic name.
* The length of this sequence is the {@linkplain #depth() depth}. It does not include the
* {@linkplain #scope() scope}.
+ *
+ * @return The local names making this generic name, without the {@linkplain #scope() scope}.
+ * Shall never be {@code null} neither empty.
*/
@Override
public abstract List extends LocalName> getParsedNames();
@@ -132,9 +186,10 @@ public abstract class AbstractName imple
* Returns the first element in the sequence of {@linkplain #getParsedNames() parsed names}.
* For any {@code LocalName}, this is always {@code this}.
*
- * Example:
- * If {@code this} name is {@code "org.opengis.util.Record"} (no matter its
- * {@linkplain #scope() scope}), then this method returns {@code "org"}.
+ * {@example If this
name is "org.opengis.util.Record"
+ * (no matter its scope, then this method returns "org"
.}
+ *
+ * @return The first element in the list of {@linkplain #getParsedNames() parsed names}.
*/
@Override
public LocalName head() {
@@ -145,9 +200,10 @@ public abstract class AbstractName imple
* Returns the last element in the sequence of {@linkplain #getParsedNames() parsed names}.
* For any {@code LocalName}, this is always {@code this}.
*
- * Example:
- * If {@code this} name is {@code "org.opengis.util.Record"} (no matter its
- * {@linkplain #scope() scope}), then this method returns {@code "Record"}.
+ * {@example If this
name is "org.opengis.util.Record"
+ * (no matter its scope, then this method returns "Record"
.}
+ *
+ * @return The last element in the list of {@linkplain #getParsedNames() parsed names}.
*/
@Override
public LocalName tip() {
@@ -159,6 +215,8 @@ public abstract class AbstractName imple
* Returns a view of this name as a fully-qualified name. The {@linkplain #scope() scope}
* of a fully qualified name is {@linkplain DefaultNameSpace#isGlobal() global}.
* If the scope of this name is already global, then this method returns {@code this}.
+ *
+ * @return The fully-qualified name (never {@code null}).
*/
@Override
public synchronized GenericName toFullyQualifiedName() {
@@ -181,6 +239,9 @@ public abstract class AbstractName imple
* {@code this} name is {@code "util.Record"} and the given {@code scope} argument is
* {@code "org.opengis"}, then {@code this.push(scope)} shall return
* {@code "org.opengis.util.Record"}.
+ *
+ * @param scope The name to use as prefix.
+ * @return A concatenation of the given scope with this name.
*/
@Override
public ScopedName push(final GenericName scope) {
@@ -219,6 +280,8 @@ public abstract class AbstractName imple
* {@linkplain #tip()}.toString()
is guaranteed to not contain
* any scope.
*
+ *
+ * @return A local-independent string representation of this name.
*/
@Override
public synchronized String toString() {
@@ -246,6 +309,8 @@ public abstract class AbstractName imple
* has been localized in the {@linkplain InternationalString#toString(Locale) specified locale}.
* If no international string is available, then this method returns an implementation mapping
* to {@link #toString()} for all locales.
+ *
+ * @return A localizable string representation of this name.
*/
@Override
public synchronized InternationalString toInternationalString() {
@@ -282,7 +347,7 @@ public abstract class AbstractName imple
* @param asString The string representation of the enclosing abstract name.
* @param parsedNames The value returned by {@link AbstractName#getParsedNames()}.
*/
- public International(final String asString, final List extends LocalName> parsedNames) {
+ International(final String asString, final List extends LocalName> parsedNames) {
super(asString);
this.parsedNames = parsedNames;
}
@@ -318,6 +383,14 @@ public abstract class AbstractName imple
}
return false;
}
+
+ /**
+ * Returns a hash code value for this international text.
+ */
+ @Override
+ public int hashCode() {
+ return parsedNames.hashCode() ^ (int) serialVersionUID;
+ }
}
/**
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -25,11 +25,14 @@ import javax.xml.bind.annotation.XmlRoot
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opengis.util.NameSpace;
import org.opengis.util.LocalName;
+import org.opengis.util.TypeName;
+import org.opengis.util.MemberName;
import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.util.Immutable;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
// Related to JDK7
@@ -72,6 +75,12 @@ public class DefaultLocalName extends Ab
/**
* The name, either as a {@link String} or an {@link InternationalString}.
+ *
+ * {@section Note on JAXB annotation}
+ * The {@link XmlElement} annotation applied here is appropriate for subclasses only ({@link DefaultTypeName}
+ * and {@link DefaultMemberName}). It is not appropriate when (un)marshalling directly this
+ * {@code DefaultLocalName} class. In this later case, we will rather rely on the {@link String} conversion
+ * performed by {@link org.apache.sis.internal.jaxb.gco.GO_GenericName}.
*/
@XmlJavaTypeAdapter(CharSequenceAdapter.class)
@XmlElement(name = "aName", namespace = Namespaces.GCO)
@@ -132,6 +141,45 @@ public class DefaultLocalName extends Ab
}
/**
+ * Returns a SIS local name implementation with the values of the given arbitrary implementation.
+ * This method performs the first applicable actions in the following choices:
+ *
+ *
+ * - If the given object is {@code null}, then this method returns {@code null}.
+ * - Otherwise if the given object is already an instance of {@code DefaultLocalName},
+ * then it is returned unchanged.
+ * - Otherwise a new {@code DefaultLocalName} instance is created using the
+ * {@link DefaultNameFactory#createLocalName(NameSpace, CharSequence)} method,
+ * or the {@code createTypeName} or {@code createMemberName} variants if the
+ * given object implements the corresponding interface.
+ *
+ *
+ * @param object The object to get as a SIS implementation, or {@code null} if none.
+ * @return A SIS implementation containing the values of the given object (may be the
+ * given object itself), or {@code null} if the argument was null.
+ */
+ public static DefaultLocalName castOrCopy(final LocalName object) {
+ if (object == null || object instanceof DefaultLocalName) {
+ return (DefaultLocalName) object;
+ }
+ final NameSpace scope = object.scope();
+ final InternationalString name = object.toInternationalString();
+ final LocalName result;
+ if (object instanceof MemberName) {
+ result = DefaultFactories.SIS_NAMES.createMemberName(scope, name, ((MemberName) object).getAttributeType());
+ } else if (object instanceof TypeName) {
+ result = DefaultFactories.SIS_NAMES.createTypeName(scope, name);
+ } else {
+ result = DefaultFactories.SIS_NAMES.createLocalName(scope, name);
+ }
+ /*
+ * Following cast should be safe because the SIS_NAMES factory is fixed to a
+ * DefaultNameFactory instance, which is known to create AbstractName instances.
+ */
+ return (DefaultLocalName) result;
+ }
+
+ /**
* Returns the scope (name space) in which this name is local. This method returns a
* non-null value in all cases, even when the scope given to the constructor was null.
*/
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultMemberName.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -76,6 +76,8 @@ public class DefaultMemberName extends D
/**
* Returns the type of the data associated with the record member.
+ *
+ * @return The type of the data associated with the record member.
*/
@Override
public TypeName getAttributeType() {
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultScopedName.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -19,7 +19,6 @@ package org.apache.sis.util.iso;
import java.util.List;
import java.util.Iterator;
import java.util.ConcurrentModificationException;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.util.NameSpace;
import org.opengis.util.LocalName;
@@ -32,7 +31,6 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.internal.util.UnmodifiableArrayList;
-
/**
* A composite of a {@linkplain DefaultNameSpace name space} (as a {@linkplain DefaultLocalName local name})
* and a {@linkplain AbstractName generic name} valid in that name space.
@@ -247,8 +245,10 @@ public class DefaultScopedName extends A
}
/**
- * Returns every elements of the {@linkplain #getParsedNames() parsed names list}
+ * Returns every elements in the sequence of {@linkplain #getParsedNames() parsed names}
* except for the {@linkplain #head() head}.
+ *
+ * @return All elements except the first one in the in the list of {@linkplain #getParsedNames() parsed names}.
*/
@Override
public synchronized GenericName tail() {
@@ -265,8 +265,10 @@ public class DefaultScopedName extends A
}
/**
- * Returns every element of the {@linkplain #getParsedNames() parsed names list}
+ * Returns every element in the sequence of {@linkplain #getParsedNames() parsed names}
* except for the {@linkplain #tip() tip}.
+ *
+ * @return All elements except the last one in the in the list of {@linkplain #getParsedNames() parsed names}.
*/
@Override
public synchronized GenericName path() {
@@ -286,7 +288,6 @@ public class DefaultScopedName extends A
* Returns the sequence of local name for this generic name.
*/
@Override
- @XmlElement(name = "parsedName", required = true)
public List extends LocalName> getParsedNames() {
return parsedNames;
}
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -132,9 +132,7 @@
})
@XmlAccessorType(XmlAccessType.NONE)
@XmlJavaTypeAdapters({
- @XmlJavaTypeAdapter(GO_GenericName.class),
- @XmlJavaTypeAdapter(LocalNameAdapter.class),
- @XmlJavaTypeAdapter(ScopedNameAdapter.class)
+ @XmlJavaTypeAdapter(GO_GenericName.class)
})
package org.apache.sis.util.iso;
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gco/PropertyTypeTest.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -20,7 +20,7 @@ import java.util.UUID;
import org.apache.sis.util.iso.SimpleInternationalString;
import org.apache.sis.xml.XLink;
import org.apache.sis.xml.IdentifierSpace;
-import org.apache.sis.xml.ReferenceResolverMock;
+import org.apache.sis.test.mock.ReferenceResolverMock;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.XMLTestCase;
import org.junit.Test;
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1497295&r1=1497294&r2=1497295&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Thu Jun 27 10:56:36 2013
@@ -118,7 +118,8 @@ import org.junit.BeforeClass;
org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class,
org.apache.sis.internal.jaxb.gco.StringAdapterTest.class,
org.apache.sis.internal.jaxb.gco.MeasureTest.class,
- org.apache.sis.internal.jaxb.gco.PropertyTypeTest.class
+ org.apache.sis.internal.jaxb.gco.PropertyTypeTest.class,
+ org.apache.sis.util.iso.NameMarshallingTest.class
})
public final strictfp class UtilityTestSuite extends TestSuite {
/**