Author: desruisseaux
Date: Thu Jan 31 19:47:34 2013
New Revision: 1441165
URL: http://svn.apache.org/viewvc?rev=1441165&view=rev
Log:
Removed the automatic binding of UUIDs (SIS-73).
Removed:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/UUIDs.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifierAlreadyBoundException.java
Modified:
sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
(original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties Thu Jan
31 19:47:34 2013
@@ -40,6 +40,7 @@ test.utility.dir = ${project.root}/s
# Those numbers should match the ones declared in the pom.xml files.
#
geoapi.version = 3.1-M04
+unit-api.version = 0.6.1
jsr275.version = 0.9.3
vecmath.version = 1.5.2
georss.version = 0.9.8
@@ -55,9 +56,10 @@ junit.version = 4.10
# The dependencies are read directy from the local Maven directory.
#
maven.repository = ${user.home}/.m2/repository
-endorsed.classpath =
+endorsed.classpath=
javac.classpath=\
${maven.repository}/org/opengis/geoapi-pending/${geoapi.version}/geoapi-pending-${geoapi.version}.jar:\
+
${maven.repository}/org/unitsofmeasurement/unit-api/${unit-api.version}/unit-api-${unit-api.version}.jar:\
${maven.repository}/javax/measure/jsr-275/${jsr275.version}/jsr-275-${jsr275.version}.jar:\
${maven.repository}/java3d/vecmath/${vecmath.version}/vecmath-${vecmath.version}.jar:\
${maven.repository}/org/geonames/georss-rome/${georss.version}/georss-rome-${georss.version}.jar:\
@@ -126,7 +128,7 @@ build.generated.dir
build.generated.sources.dir = ${build.dir}/generated-sources
build.test.classes.dir = ${build.dir}/test/classes
build.test.results.dir = ${build.dir}/test/results
-build.classes.excludes =
**/*.java,**/*.form,**/*.bak,**/resources/*.properties
+build.classes.excludes =
**/*.java,**/*.form,**/*.bak,**/resources/*.properties,com/sun/xml/**
build.sysclasspath = ignore
dist.dir = dist
dist.jar = ${dist.dir}/SIS.jar
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
Thu Jan 31 19:47:34 2013
@@ -30,7 +30,6 @@ import org.opengis.metadata.citation.Cit
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.xml.IdentifierMap;
import org.apache.sis.xml.IdentifierSpace;
-import org.apache.sis.xml.IdentifierAlreadyBoundException;
import static org.apache.sis.util.collection.Collections.hashMapCapacity;
@@ -250,12 +249,10 @@ public class IdentifierMapAdapter extend
* @param authority The authority for which to set the code.
* @param code The new code for the given authority, or {@code null} for
removing the entry.
* @return The previous code for the given authority, or {@code null} if
none.
- * @throws IdentifierAlreadyBoundException If this map expects unique
identifiers for the
- * given authority, and the given value is already associated to
another object.
*/
@Override
public String put(final Citation authority, final String code)
- throws IdentifierAlreadyBoundException,
UnsupportedOperationException
+ throws UnsupportedOperationException
{
ArgumentChecks.ensureNonNull("authority", authority);
String old = null;
@@ -290,7 +287,7 @@ public class IdentifierMapAdapter extend
*/
@Override
public <T> T putSpecialized(final IdentifierSpace<T> authority, final T
value)
- throws IdentifierAlreadyBoundException,
UnsupportedOperationException
+ throws UnsupportedOperationException
{
ArgumentChecks.ensureNonNull("authority", authority);
T old = null;
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
Thu Jan 31 19:47:34 2013
@@ -18,12 +18,10 @@ package org.apache.sis.internal.jaxb;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.UUID;
import java.util.Collection;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.apache.sis.xml.IdentifierSpace;
-import org.apache.sis.xml.IdentifierAlreadyBoundException;
import org.apache.sis.xml.XLink;
// Related to JDK7
@@ -36,7 +34,6 @@ import java.util.Objects;
*
* <ul>
* <li>{@link IdentifierSpace#HREF}: handled as a shortcut to {@link
XLink#getHRef()}.</li>
- * <li>{@link IdentifierSpace#UUID}: {@code put} operations register the
UUID in a shared map.</li>
* </ul>
*
* See usages of {@link #specialCase(Object)} for identifying the code
locations where a special
@@ -54,19 +51,12 @@ public final class IdentifierMapWithSpec
private static final long serialVersionUID = 5139573827448780289L;
/**
- * The object being referenced by the identifiers, or {@code null} if not
applicable.
- */
- private final Object referent;
-
- /**
* Creates a new map which will be a view over the given identifiers.
*
* @param identifiers The identifiers to wrap in a map view.
- * @param referent The object being referenced by the identifiers.
*/
- public IdentifierMapWithSpecialCases(final Collection<Identifier>
identifiers, final Object referent) {
+ public IdentifierMapWithSpecialCases(final Collection<Identifier>
identifiers) {
super(identifiers);
- this.referent = referent;
}
/**
@@ -78,7 +68,6 @@ public final class IdentifierMapWithSpec
*/
private static int specialCase(final Object authority) {
if (authority == IdentifierSpace.HREF) return
NonMarshalledAuthority.HREF;
- if (authority == IdentifierSpace.UUID) return
NonMarshalledAuthority.UUID;
// A future Apache SIS version may add more special cases here.
return -1;
}
@@ -122,29 +111,6 @@ public final class IdentifierMapWithSpec
}
/**
- * Sets the {@code "gco:uuid"} value, which may be null. This method
stores the UUID-object
- * association in a shared map, if no value existed previously.
- *
- * @param uuid The UUID to assign to the object.
- * @return The previous value, or {@code null} if none.
- * @throws IdentifierAlreadyBoundException If the given identifier is
already associated to another object.
- */
- private UUID setUUID(final UUID uuid) throws
IdentifierAlreadyBoundException {
- if (referent == null) {
- return super.putSpecialized(IdentifierSpace.UUID, uuid);
- }
- if (uuid != null) {
- UUIDs.bind(uuid, referent); // May throws
IdentifierAlreadyBoundException
- }
- // Invoke 'put' only if UUIDs.bind(â¦) has been succesful.
- final UUID old = super.putSpecialized(IdentifierSpace.UUID, uuid);
- if (old != null && !old.equals(uuid)) {
- UUIDs.unbind(old, referent);
- }
- return old;
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -212,7 +178,7 @@ public final class IdentifierMapWithSpec
*/
@Override
public String put(final Citation authority, final String code)
- throws IdentifierAlreadyBoundException,
UnsupportedOperationException
+ throws UnsupportedOperationException
{
final Exception exception;
switch (specialCase(authority)) {
@@ -231,18 +197,6 @@ public final class IdentifierMapWithSpec
id = setHRef(id);
return (id != null) ? id.toString() : old;
}
- case NonMarshalledAuthority.UUID: {
- UUID id = null;
- if (code != null) try {
- id = UUID.fromString(code);
- } catch (IllegalArgumentException e) {
- exception = e;
- break;
- }
- final String old = getUnspecialized(authority);
- id = setUUID(id);
- return (id != null) ? id.toString() : old;
- }
}
SpecializedIdentifier.parseFailure(exception);
return super.put(authority, code);
@@ -254,12 +208,11 @@ public final class IdentifierMapWithSpec
@Override
@SuppressWarnings("unchecked")
public <T> T putSpecialized(final IdentifierSpace<T> authority, final T
value)
- throws IdentifierAlreadyBoundException,
UnsupportedOperationException
+ throws UnsupportedOperationException
{
switch (specialCase(authority)) {
default: return super.putSpecialized(authority, value);
case NonMarshalledAuthority.HREF: return (T) setHRef((URI) value);
- case NonMarshalledAuthority.UUID: return (T) setUUID((UUID) value);
}
}
}
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
Thu Jan 31 19:47:34 2013
@@ -340,12 +340,9 @@ public class WeakValueHashMap<K,V> exten
/**
* Implementation of {@link #put(Object, Object)} and {@link
#remove(Object)} operations
- *
- * @param putIfAbsent If {@code true} and a value is found for the given
key,
- * returns the old value without modifying the map.
*/
@SuppressWarnings("unchecked")
- private synchronized V intern(final Object key, final V value, final
boolean putIfAbsent) {
+ private synchronized V intern(final Object key, final V value) {
assert isValid();
/*
* If 'value' is already contained in this WeakValueHashMap, we need
to clear it.
@@ -357,9 +354,6 @@ public class WeakValueHashMap<K,V> exten
for (Entry e = table[index]; e != null; e = (Entry) e.next) {
if (keyEquals(key, e.key)) {
oldValue = e.get();
- if (putIfAbsent) {
- return oldValue;
- }
e.dispose();
table = this.table; // May have changed.
index = hash % table.length;
@@ -394,25 +388,7 @@ public class WeakValueHashMap<K,V> exten
public V put(final K key, final V value) throws NullArgumentException {
ArgumentChecks.ensureNonNull("key", key);
ArgumentChecks.ensureNonNull("value", value);
- return intern(key, value, false);
- }
-
- /**
- * Associates the specified value with the specified key only if no value
is currently
- * associated to that key. If a value already exists for the given key,
then this method
- * returns the current value without changing the map.
- *
- * @param key key with which the specified value is to be associated.
- * @param value value to be associated with the specified key.
- * @return {@code null} if the given value has been associated to the
given key,
- * or the current (unchanged) value if a mapping already exists
for that key.
- *
- * @throws NullArgumentException if the key or the value is {@code null}.
- */
- public V putIfAbsent(final K key, final V value) throws
NullArgumentException {
- ArgumentChecks.ensureNonNull("key", key);
- ArgumentChecks.ensureNonNull("value", value);
- return intern(key, value, true);
+ return intern(key, value);
}
/**
@@ -424,7 +400,7 @@ public class WeakValueHashMap<K,V> exten
*/
@Override
public V remove(final Object key) {
- return intern(key, null, false);
+ return intern(key, null);
}
/**
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java
Thu Jan 31 19:47:34 2013
@@ -64,10 +64,8 @@ public interface IdentifierMap extends M
* @param value The identifier to be associated with the given namespace.
* @return The previous identifier associated with {@code authority}, or
{@code null}
* if there was no mapping of the specialized type for {@code
authority}.
- * @throws IdentifierAlreadyBoundException If this map expects unique
identifiers for the
- * given authority, and the given value is already associated to
another object.
* @throws UnsupportedOperationException If the identifier map is
unmodifiable.
*/
<T> T putSpecialized(IdentifierSpace<T> authority, T value)
- throws IdentifierAlreadyBoundException,
UnsupportedOperationException;
+ throws UnsupportedOperationException;
}
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
Thu Jan 31 19:47:34 2013
@@ -72,7 +72,7 @@ final class NilObjectHandler implements
asList.add(identifier);
}
}
- attribute = new IdentifierMapWithSpecialCases(asList, null);
+ attribute = new IdentifierMapWithSpecialCases(asList);
}
/**
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
Thu Jan 31 19:47:34 2013
@@ -21,7 +21,6 @@ import java.lang.reflect.Proxy;
import org.opengis.metadata.Identifier;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.LenientComparable;
-import org.apache.sis.internal.jaxb.UUIDs;
import org.apache.sis.internal.jaxb.gmx.Anchor;
import static org.apache.sis.util.ArgumentChecks.*;
@@ -91,9 +90,7 @@ public class ReferenceResolver {
/**
* Returns an object of the given type for the given {@code uuid}
attribute, or {@code null}
- * if none. The default implementation looks in an internal map for
previously unmarshalled
- * object having the given UUID. If no existing instance is found, then
this method returns
- * {@code null}.
+ * if none. The default implementation returns {@code null} in all cases.
*
* @param <T> The compile-time type of the {@code type} argument.
* @param context Context (GML version, locale, <i>etc.</i>) of the
(un)marshalling process.
@@ -106,8 +103,7 @@ public class ReferenceResolver {
public <T> T resolve(final MarshalContext context, final Class<T> type,
final UUID uuid) {
ensureNonNull("type", type);
ensureNonNull("uuid", uuid);
- final Object object = UUIDs.lookup(uuid);
- return type.isInstance(object) ? (T) object : null;
+ return null;
}
/**
Modified:
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java?rev=1441165&r1=1441164&r2=1441165&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
(original)
+++
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
Thu Jan 31 19:47:34 2013
@@ -57,7 +57,7 @@ public final strictfp class IdentifierMa
*/
@Override
IdentifierMapAdapter create(final Collection<Identifier> identifiers) {
- return new IdentifierMapWithSpecialCases(identifiers, null);
+ return new IdentifierMapWithSpecialCases(identifiers);
}
/**
@@ -110,25 +110,19 @@ public final strictfp class IdentifierMa
}
/**
- * Tests the binding of UUID.
+ * Tests with UUIDs.
*/
@Test
public void testUUIDs() {
- final String object = "IdentifiedObject";
final List<Identifier> identifiers = new ArrayList<>();
- final IdentifierMap map = new
IdentifierMapWithSpecialCases(identifiers, object);
+ final IdentifierMap map = new
IdentifierMapWithSpecialCases(identifiers);
final UUID id1 =
UUID.fromString("434f3107-c6d2-4c8c-bb25-553f68641c5c");
final UUID id2 =
UUID.fromString("42924124-032a-4dfe-b06e-113e3cb81cf0");
// Add first UUID.
- assertNull("Shall not contain UUID before put.", UUIDs.lookup(id1));
assertNull(map.putSpecialized(IdentifierSpace.UUID, id1));
- assertSame("Object sholl be associated to UUID.", object,
UUIDs.lookup(id1));
// Replace UUID by a new one.
- assertNull("Shall not contain UUID before put.", UUIDs.lookup(id2));
assertSame(id1, map.putSpecialized(IdentifierSpace.UUID, id2));
- assertNull("Shall not contain the removed UUID.", UUIDs.lookup(id1));
- assertSame("Object sholl be associated to UUID.", object,
UUIDs.lookup(id2));
}
}