You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2013/02/01 20:31:20 UTC
svn commit: r1441594 [1/2] - in /sis/branches/JDK6: ./
ide-project/NetBeans/nbproject/
sis-metadata/src/main/java/org/apache/sis/metadata/
sis-referencing/src/main/java/org/apache/sis/geometry/
sis-utility/src/main/java/org/apache/sis/internal/jaxb/ si...
Author: desruisseaux
Date: Fri Feb 1 19:31:18 2013
New Revision: 1441594
URL: http://svn.apache.org/viewvc?rev=1441594&view=rev
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
- copied, changed from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Shutdown.java
- copied unchanged from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/Shutdown.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/SystemListener.java
- copied unchanged from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SystemListener.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
- copied, changed from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java
- copied, changed from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java
- copied unchanged from r1441586, sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/ArraysExtTest.java
Removed:
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/UUIDs.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Arrays.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifierAlreadyBoundException.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/ArraysTest.java
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties
sis/branches/JDK6/pom.xml
sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DelayedExecutor.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/SupervisorMBean.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Threads.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Units.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/package-info.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/KeyConstants.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifierMap.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/IdentifierSpace.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/NilObjectHandler.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/ReferenceResolver.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XML.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCasesTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/LocalesTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/xml/NilReasonTest.java
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1429660-1441586
Modified: sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties (original)
+++ sis/branches/JDK6/ide-project/NetBeans/nbproject/project.properties Fri Feb 1 19:31:18 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/JDK6/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/pom.xml?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/pom.xml (original)
+++ sis/branches/JDK6/pom.xml Fri Feb 1 19:31:18 2013
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
- <version>12</version>
+ <version>13</version>
</parent>
@@ -347,12 +347,12 @@ Apache SIS is a toolkit for describing l
</archive>
</configuration>
<executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<!-- Package as OSGi bundle -->
Modified: sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java (original)
+++ sis/branches/JDK6/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java Fri Feb 1 19:31:18 2013
@@ -27,8 +27,8 @@ import org.apache.sis.util.collection.Ch
import org.apache.sis.util.collection.CheckedArrayList;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-import static org.apache.sis.util.collection.Collections.isNullOrEmpty;
-import static org.apache.sis.util.collection.Collections.hashMapCapacity;
+import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
+import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
/**
Modified: sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java (original)
+++ sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java Fri Feb 1 19:31:18 2013
@@ -29,12 +29,12 @@ import org.opengis.referencing.crs.Coord
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.cs.CoordinateSystem;
import org.opengis.referencing.cs.RangeMeaning;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
import static java.lang.Double.doubleToLongBits;
-import static org.apache.sis.util.Arrays.resize;
import static org.apache.sis.util.StringBuilders.trimFractionalPart;
import static org.apache.sis.util.ArgumentChecks.ensureDimensionMatches;
@@ -342,7 +342,7 @@ parse: while (i < length) {
c = Character.codePointAt(wkt, i);
}
}
- return resize(ordinates, dimension);
+ return ArraysExt.resize(ordinates, dimension);
}
/**
Modified: sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java (original)
+++ sis/branches/JDK6/sis-referencing/src/main/java/org/apache/sis/geometry/ArrayEnvelope.java Fri Feb 1 19:31:18 2013
@@ -31,11 +31,11 @@ import org.opengis.metadata.extent.Geogr
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.util.FactoryException;
-import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.referencing.CRS;
-import static org.apache.sis.util.Arrays.resize;
import static org.apache.sis.util.ArgumentChecks.*;
import static org.apache.sis.math.MathFunctions.isNegative;
import static org.apache.sis.internal.referencing.Utilities.isPoleToPole;
@@ -280,7 +280,7 @@ scanNumber: while ((i += Character.charC
}
if (levelParenth != 0) fail(wkt, ')');
if (levelBracket != 0) fail(wkt, ']');
- ordinates = resize(minimum, maxDimension << 1);
+ ordinates = ArraysExt.resize(minimum, maxDimension << 1);
System.arraycopy(maximum, 0, ordinates, maxDimension, maxDimension);
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java Fri Feb 1 19:31:18 2013
@@ -30,9 +30,8 @@ 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;
+import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
// Related to JDK7
import org.apache.sis.internal.util.Objects;
@@ -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/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapWithSpecialCases.java Fri Feb 1 19:31:18 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 org.apache.sis.internal.util.Obje
*
* <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);
}
}
}
Copied: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java (from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java?p2=sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java&p1=sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java&r1=1441586&r2=1441594&rev=1441594&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java Fri Feb 1 19:31:18 2013
@@ -71,7 +71,7 @@ public abstract class TypeRegistration {
* 1) It would cache the RegsterableTypes instances, which are not needed after this method call.
* 2) The ClassLoader between different invocations may be different in an OSGi context.
*/
- final ArrayList<Class<?>> types = new ArrayList<>();
+ final ArrayList<Class<?>> types = new ArrayList<Class<?>>();
for (final TypeRegistration t : ServiceLoader.load(TypeRegistration.class)) {
t.getTypes(types);
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java Fri Feb 1 19:31:18 2013
@@ -99,6 +99,18 @@ abstract class DaemonThread extends Thre
public abstract void run();
/**
+ * Returns {@code true} if this thread seems to be blocked for a time long enough for suspecting
+ * a problem. The default implementation always returns {@code false}. Subclasses are encouraged
+ * to provide some problem detection mechanism here if they can. For example if the head of a
+ * queue seems to be never removed, then maybe the process consuming that queue is blocked.
+ *
+ * @return {@code true} if this thread seems to be stalled.
+ */
+ protected boolean isStalled() {
+ return false;
+ }
+
+ /**
* Returns {@code true} if this daemon thread shall terminate.
* This happen at shutdown time.
*
@@ -137,26 +149,24 @@ abstract class DaemonThread extends Thre
}
/**
- * Returns the names of dead threads, or {@code null} if none. The returned list should
- * always be null. A non-empty list would be a symptom for a severe problem, probably
+ * Returns the list of stalled or dead threads, or {@code null} if none. The returned list
+ * should always be null. A non-empty list would be a symptom for a severe problem, probably
* requiring an application reboot.
*
* <p><strong>This method is for internal use by Apache SIS only.</strong>
* Users should never invoke this method explicitely.</p>
*
* @param thread The first thread in the chain of threads to verify.
- * @return The name of dead threads, or {@code null} if none.
- *
- * @see Threads#listDeadThreads()
+ * @return The list of stalled or dead threads, or {@code null} if none.
*/
- static List<String> listDeadThreads(DaemonThread thread) {
- List<String> list = null;
+ static List<Thread> listStalledThreads(DaemonThread thread) {
+ List<Thread> list = null;
while (thread != null) {
- if (!thread.isAlive()) {
+ if (!thread.isAlive() || thread.isStalled()) {
if (list == null) {
- list = new ArrayList<String>();
+ list = new ArrayList<Thread>();
}
- list.add(thread.getName());
+ list.add(thread);
}
thread = thread.previous;
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DelayedExecutor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DelayedExecutor.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DelayedExecutor.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/DelayedExecutor.java Fri Feb 1 19:31:18 2013
@@ -16,6 +16,7 @@
*/
package org.apache.sis.internal.util;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.BlockingQueue;
import org.apache.sis.util.logging.Logging;
@@ -182,4 +183,28 @@ public final class DelayedExecutor exten
}
// Do not log anything at this point, since the loggers may be shutdown now.
}
+
+ /**
+ * Returns {@code true} if this thread seems to be stalled. This method checks the head
+ * of the queue. If the delay for that head has expired and the head is not removed in
+ * the next 5 seconds, then we will presume that the thread is stalled or dead.
+ */
+ @Override
+ protected boolean isStalled() {
+ final DelayedRunnable waiting = QUEUE.peek();
+ if (waiting != null && waiting.getDelay(TimeUnit.NANOSECONDS) <= 0) try {
+ for (int i=0; i<50; i++) {
+ if (!isAlive()) break;
+ Thread.sleep(100);
+ if (QUEUE.peek() != waiting) {
+ return false;
+ }
+ }
+ return true;
+ } catch (InterruptedException e) {
+ // Someone doesn't want to let us wait. Since we didn't had the time to
+ // determine if the thread is stalled, conservatively return 'false'.
+ }
+ return false;
+ }
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/OSGiActivator.java Fri Feb 1 19:31:18 2013
@@ -19,6 +19,8 @@ package org.apache.sis.internal.util;
import javax.management.JMException;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
/**
@@ -30,7 +32,7 @@ import org.osgi.framework.BundleActivato
* @version 0.3
* @module
*/
-public final class OSGiActivator implements BundleActivator {
+public final class OSGiActivator implements BundleActivator, BundleListener {
/**
* Creates a new bundle activator.
*/
@@ -44,6 +46,7 @@ public final class OSGiActivator impleme
*/
@Override
public void start(final BundleContext context) {
+ context.addBundleListener(this);
}
/**
@@ -51,15 +54,27 @@ public final class OSGiActivator impleme
* This method shutdowns the {@code sis-utility} threads.
*
* @param context The execution context of the bundle being stopped.
- * @throws InterruptedException If an other thread invoked {@link #interrupt()} while
- * we were waiting for the {@code sis-utility} threads to die.
* @throws JMException If an error occurred during unregistration of the supervisor MBean.
*/
@Override
- public void stop(final BundleContext context) throws InterruptedException, JMException {
- Threads.shutdown(4000);
- if (Supervisor.ENABLED) {
- Supervisor.unregister();
+ public void stop(final BundleContext context) throws JMException {
+ context.removeBundleListener(this);
+ Shutdown.stop(getClass());
+ }
+
+ /**
+ * Invoked when an other module has been installed or un-installed.
+ * This method notifies the Apache SIS library that the classpath may have changed.
+ *
+ * @param event The event that describe the life-cycle change.
+ */
+ @Override
+ public void bundleChanged(final BundleEvent event) {
+ switch (event.getType()) {
+ case BundleEvent.STARTED:
+ case BundleEvent.STOPPED: {
+ SystemListener.fireClasspathChanged();
+ }
}
}
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java Fri Feb 1 19:31:18 2013
@@ -199,13 +199,21 @@ public final class Supervisor extends St
* {@inheritDoc}
*/
@Override
- public List<String> warnings() {
- final List<String> warnings = Threads.listDeadThreads();
- if (warnings != null) {
- final Errors resources = Errors.getResources(locale);
- for (int i=warnings.size(); --i>=0;) {
- warnings.set(i, resources.getString(Errors.Keys.DeadThread_1, warnings.get(i)));
- }
+ public String[] warnings() {
+ final DaemonThread lastCreatedDaemon;
+ synchronized (Threads.class) {
+ lastCreatedDaemon = Threads.lastCreatedDaemon;
+ }
+ final List<Thread> threads = DaemonThread.listStalledThreads(lastCreatedDaemon);
+ if (threads == null) {
+ return null;
+ }
+ final String[] warnings = new String[threads.size()];
+ final Errors resources = Errors.getResources(locale);
+ for (int i=0; i<warnings.length; i++) {
+ final Thread thread = threads.get(i);
+ warnings[i] = resources.getString(thread.isAlive() ?
+ Errors.Keys.StalledThread_1 : Errors.Keys.DeadThread_1, thread.getName());
}
return warnings;
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/SupervisorMBean.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/SupervisorMBean.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/SupervisorMBean.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/SupervisorMBean.java Fri Feb 1 19:31:18 2013
@@ -16,7 +16,6 @@
*/
package org.apache.sis.internal.util;
-import java.util.List;
import org.apache.sis.util.collection.TreeTable;
@@ -46,5 +45,5 @@ public interface SupervisorMBean {
*
* @return A description of a problems in the library, or {@code null} if none.
*/
- List<String> warnings();
+ String[] warnings();
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Threads.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Threads.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Threads.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Threads.java Fri Feb 1 19:31:18 2013
@@ -16,7 +16,6 @@
*/
package org.apache.sis.internal.util;
-import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ExecutorService;
import org.apache.sis.util.Static;
@@ -131,15 +130,4 @@ final class Threads extends Static {
}
DaemonThread.killAll(lastCreatedDaemon, stopWaitingAt);
}
-
- /**
- * Returns the names of dead threads, or {@code null} if none. The returned list should
- * always be null. A non-empty list would be a symptom for a severe problem, probably
- * requiring an application reboot.
- *
- * @return The name of dead threads, or {@code null} if none.
- */
- static synchronized List<String> listDeadThreads() {
- return DaemonThread.listDeadThreads(lastCreatedDaemon);
- }
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java Fri Feb 1 19:31:18 2013
@@ -21,13 +21,13 @@ import java.util.Arrays;
import java.util.List;
import java.io.Flushable;
import java.io.IOException;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Decorator;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.util.X364;
-import static org.apache.sis.util.Arrays.EMPTY_INT;
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
// Related to JK7
@@ -172,7 +172,7 @@ public class TableAppender extends Appen
* Maximum width for each columns. This array length must
* be equal to the number of columns in this table.
*/
- private int[] maximalColumnWidths = EMPTY_INT;
+ private int[] maximalColumnWidths = ArraysExt.EMPTY_INT;
/**
* The line separator. We will use the first line separator found in the
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java Fri Feb 1 19:31:18 2013
@@ -18,6 +18,7 @@ package org.apache.sis.math;
import java.util.Arrays;
import org.apache.sis.util.Static;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Workaround;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
@@ -26,9 +27,6 @@ import static java.lang.Float.intBitsToF
import static java.lang.Float.floatToRawIntBits;
import static java.lang.Double.longBitsToDouble;
import static java.lang.Double.doubleToRawLongBits;
-import static org.apache.sis.util.Arrays.resize;
-import static org.apache.sis.util.Arrays.isSorted;
-import static org.apache.sis.util.Arrays.EMPTY_INT;
import static org.apache.sis.internal.util.Utilities.SIGN_BIT_MASK;
@@ -727,7 +725,7 @@ testNextNumber: while (true) { /
*/
public static int[] divisors(int number) {
if (number == 0) {
- return EMPTY_INT;
+ return ArraysExt.EMPTY_INT;
}
number = Math.abs(number);
int[] divisors = new int[16];
@@ -788,8 +786,8 @@ testNextNumber: while (true) { /
}
}
}
- divisors = resize(divisors, count);
- assert isSorted(divisors, true);
+ divisors = ArraysExt.resize(divisors, count);
+ assert ArraysExt.isSorted(divisors, true);
return divisors;
}
@@ -801,7 +799,7 @@ testNextNumber: while (true) { /
*/
public static int[] commonDivisors(final int... numbers) {
if (numbers.length == 0) {
- return EMPTY_INT;
+ return ArraysExt.EMPTY_INT;
}
/*
* Get the smallest value. We will compute the divisors only for this value,
@@ -831,6 +829,6 @@ testNextNumber: while (true) { /
}
}
}
- return resize(divisors, count);
+ return ArraysExt.resize(divisors, count);
}
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java Fri Feb 1 19:31:18 2013
@@ -26,11 +26,10 @@ import java.util.Set;
import java.text.Format;
import java.text.AttributedCharacterIterator;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.collection.CollectionsExt;
import org.apache.sis.internal.util.SurjectiveConverter;
import org.apache.sis.internal.simple.SimpleCharacterIterator;
-import static org.apache.sis.util.collection.Collections.derivedMap;
-
/**
* The attributed character iterator to be returned by {@link Format}
@@ -397,7 +396,7 @@ final class FormattedCharacterIterator e
@Override
public Map<Attribute, Object> getAttributes() {
final int index = getIndex();
- return derivedMap(attributes, new Filter(attributes, index), new Selector(index));
+ return CollectionsExt.derivedMap(attributes, new Filter(attributes, index), new Selector(index));
}
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Units.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Units.java Fri Feb 1 19:31:18 2013
@@ -31,7 +31,7 @@ import javax.measure.quantity.Quantity;
import javax.measure.converter.UnitConverter;
import org.apache.sis.util.Static;
import org.apache.sis.util.Workaround;
-import org.apache.sis.util.Arrays;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Exceptions;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
@@ -448,7 +448,7 @@ public final class Units extends Static
s = Math.max(uom.lastIndexOf(' '), uom.lastIndexOf('_'));
if (s >= 1) {
final String suffix = (String) trimWhitespaces(uom, s+1, length);
- if (Arrays.containsIgnoreCase(DEGREE_SUFFIXES, suffix) || (isTemperature = isCelsius(suffix))) {
+ if (ArraysExt.containsIgnoreCase(DEGREE_SUFFIXES, suffix) || (isTemperature = isCelsius(suffix))) {
prefix = (String) trimWhitespaces(uom, 0, s); // Remove the suffix only if we recognized it.
}
}
Copied: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java (from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java?p2=sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java&p1=sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java&r1=1441586&r2=1441594&rev=1441594&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java Fri Feb 1 19:31:18 2013
@@ -21,7 +21,7 @@ import java.util.Comparator;
import java.lang.reflect.Array;
// Related to JDK7
-import java.util.Objects;
+import org.apache.sis.internal.util.Objects;
/**
@@ -1802,7 +1802,6 @@ public final class ArraysExt extends Sta
* @see #append(Object[], Object)
* @see #unionOfSorted(int[], int[])
*/
- @SafeVarargs
public static <T> T[] concatenate(final T[]... arrays) {
T[] result = null;
if (arrays != null) {
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java Fri Feb 1 19:31:18 2013
@@ -16,12 +16,10 @@
*/
package org.apache.sis.util;
+import java.util.Arrays;
import java.nio.CharBuffer;
import static java.lang.Character.*;
-import static java.util.Arrays.fill;
-import static java.util.Arrays.copyOf;
-import static org.apache.sis.util.Arrays.resize;
import static org.apache.sis.util.StringBuilders.replace;
// Related to JDK7
@@ -105,7 +103,7 @@ public final class CharSequences extends
// this strategy and build the char[] array on the fly.
final int last = SPACES.length - 1;
final char[] spaces = new char[last+1];
- fill(spaces, ' ');
+ Arrays.fill(spaces, ' ');
SPACES[last] = new String(spaces).intern();
}
@@ -172,7 +170,7 @@ public final class CharSequences extends
@Override public String toString() {
final char[] array = new char[length];
- fill(array, ' ');
+ Arrays.fill(array, ' ');
return new String(array);
}
};
@@ -655,7 +653,7 @@ search: for (; fromIndex <= toIndex;
final CharSequence item = trimWhitespaces(text, last, i);
if (!excludeEmpty || item.length() != 0) {
if (count == strings.length) {
- strings = copyOf(strings, count << 1);
+ strings = Arrays.copyOf(strings, count << 1);
}
strings[count++] = item;
}
@@ -665,11 +663,11 @@ search: for (; fromIndex <= toIndex;
final CharSequence item = trimWhitespaces(text, last, length);
if (!excludeEmpty || item.length() != 0) {
if (count == strings.length) {
- strings = copyOf(strings, count + 1);
+ strings = Arrays.copyOf(strings, count + 1);
}
strings[count++] = item;
}
- return resize(strings, count);
+ return ArraysExt.resize(strings, count);
}
/**
@@ -751,7 +749,7 @@ search: for (; fromIndex <= toIndex;
}
}
if (count >= splitted.length) {
- splitted = copyOf(splitted, count*2);
+ splitted = Arrays.copyOf(splitted, count*2);
}
splitted[count++] = text.subSequence(last, splitAt);
last = splitAt + skip;
@@ -760,10 +758,10 @@ search: for (; fromIndex <= toIndex;
* Add the remaining string and we are done.
*/
if (count >= splitted.length) {
- splitted = copyOf(splitted, count+1);
+ splitted = Arrays.copyOf(splitted, count+1);
}
splitted[count++] = text.subSequence(last, text.length());
- return resize(splitted, count);
+ return ArraysExt.resize(splitted, count);
}
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java Fri Feb 1 19:31:18 2013
@@ -17,6 +17,7 @@
package org.apache.sis.util;
import java.util.Set;
+import java.util.Arrays;
import java.util.Iterator;
import java.util.Collection;
import java.util.Collections;
@@ -28,10 +29,7 @@ import java.lang.reflect.WildcardType;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
-import static java.util.Arrays.copyOf;
-import static org.apache.sis.util.Arrays.resize;
-import static org.apache.sis.util.Arrays.contains;
-import static org.apache.sis.util.collection.Collections.hashMapCapacity;
+import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
/**
@@ -377,14 +375,14 @@ next: for (final Class<?> candidat
types = candidates;
}
if (count >= types.length) {
- types = copyOf(types, types.length + candidates.length);
+ types = Arrays.copyOf(types, types.length + candidates.length);
}
types[count++] = candidate;
}
}
type = type.getSuperclass();
}
- return (Class[]) resize(types, count);
+ return (Class[]) ArraysExt.resize(types, count);
}
/**
@@ -669,6 +667,6 @@ cmp: for (final Class<?> c : c1) {
method.getParameterTypes().length == 0 &&
!method.isSynthetic() &&
!method.isAnnotationPresent(Deprecated.class) &&
- !contains(EXCLUDES, method.getName());
+ !ArraysExt.contains(EXCLUDES, method.getName());
}
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Locales.java Fri Feb 1 19:31:18 2013
@@ -28,9 +28,8 @@ import java.lang.reflect.Modifier;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.resources.Errors;
-import static org.apache.sis.util.Arrays.resize;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
-import static org.apache.sis.util.collection.Collections.hashMapCapacity;
+import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
/**
@@ -141,7 +140,7 @@ public final class Locales extends Stati
locales[count++] = unique(locale);
}
}
- locales = resize(locales, count);
+ locales = ArraysExt.resize(locales, count);
return locales;
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java Fri Feb 1 19:31:18 2013
@@ -28,9 +28,7 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import org.apache.sis.util.resources.Errors;
-
-import static org.apache.sis.util.collection.Collections.emptyQueue;
-import static org.apache.sis.util.collection.Collections.emptySortedSet;
+import org.apache.sis.util.collection.CollectionsExt;
/**
@@ -642,8 +640,8 @@ public final class Numbers extends Stati
} else if (type != null && type != Object.class) {
if (type == Map .class) return (T) Collections.EMPTY_MAP;
if (type == List .class) return (T) Collections.EMPTY_LIST;
- if (type == Queue .class) return (T) emptyQueue();
- if (type == SortedSet.class) return (T) emptySortedSet();
+ if (type == Queue .class) return (T) CollectionsExt.emptyQueue();
+ if (type == SortedSet.class) return (T) CollectionsExt.emptySortedSet();
if (type.isAssignableFrom(Set.class)) {
return (T) Collections.EMPTY_SET;
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java Fri Feb 1 19:31:18 2013
@@ -18,6 +18,7 @@ package org.apache.sis.util;
import java.util.Map;
import java.util.Set;
+import org.apache.sis.util.collection.CollectionsExt;
/**
@@ -53,7 +54,7 @@ public final class ObjectConverters exte
* by invoking the {@link ObjectConverter#convert(Object)} method on the given converter.
*
* <p>This convenience method delegates to
- * {@link org.apache.sis.util.collection.Collections#derivedSet Collections.derivedSet(â¦)}.
+ * {@link CollectionsExt#derivedSet CollectionsExt.derivedSet(â¦)}.
* See the javadoc of the above method for more information.
*
* @param <S> The type of elements in the storage (original) set.
@@ -64,10 +65,10 @@ public final class ObjectConverters exte
* @return A view over the {@code storage} set containing all elements converted by the given
* converter, or {@code null} if {@code storage} was null.
*
- * @see org.apache.sis.util.collection.Collections#derivedSet(Set, ObjectConverter)
+ * @see CollectionsExt#derivedSet(Set, ObjectConverter)
*/
public static <S,E> Set<E> derivedSet(final Set<S> storage, final ObjectConverter<S,E> converter) {
- return org.apache.sis.util.collection.Collections.derivedSet(storage, converter);
+ return CollectionsExt.derivedSet(storage, converter);
}
/**
@@ -76,7 +77,7 @@ public final class ObjectConverters exte
* by invoking the {@link ObjectConverter#convert(Object)} method on the given converters.
*
* <p>This convenience method delegates to
- * {@link org.apache.sis.util.collection.Collections#derivedMap Collections.derivedMap(â¦)}.
+ * {@link CollectionsExt#derivedMap CollectionsExt.derivedMap(â¦)}.
* See the javadoc of the above method for more information.
*
* @param <SK> The type of keys in the storage map.
@@ -89,13 +90,13 @@ public final class ObjectConverters exte
* @return A view over the {@code storage} map containing all entries converted by the given
* converters, or {@code null} if {@code storage} was null.
*
- * @see org.apache.sis.util.collection.Collections#derivedMap(Map, ObjectConverter, ObjectConverter)
+ * @see CollectionsExt#derivedMap(Map, ObjectConverter, ObjectConverter)
*/
public static <SK,SV,K,V> Map<K,V> derivedMap(final Map<SK,SV> storage,
final ObjectConverter<SK,K> keyConverter,
final ObjectConverter<SV,V> valueConverter)
{
- return org.apache.sis.util.collection.Collections.derivedMap(storage, keyConverter, valueConverter);
+ return CollectionsExt.derivedMap(storage, keyConverter, valueConverter);
}
/**
@@ -104,7 +105,7 @@ public final class ObjectConverters exte
* invoking the {@link ObjectConverter#convert(Object)} method on the given converter.
*
* <p>This convenience method delegates to
- * {@link org.apache.sis.util.collection.Collections#derivedMap Collections.derivedMap(â¦)}.
+ * {@link CollectionsExt#derivedMap CollectionsExt.derivedMap(â¦)}.
* See the javadoc of the above method for more information.
*
* @param <SK> The type of keys in the storage map.
@@ -116,15 +117,14 @@ public final class ObjectConverters exte
* @return A view over the {@code storage} map containing all entries with the keys converted
* by the given converter, or {@code null} if {@code storage} was null.
*
- * @see org.apache.sis.util.collection.Collections#derivedMap(Map, ObjectConverter, ObjectConverter)
+ * @see CollectionsExt#derivedMap(Map, ObjectConverter, ObjectConverter)
*/
public static <SK,K,V> Map<K,V> derivedKeys(final Map<SK,V> storage,
final ObjectConverter<SK,K> keyConverter,
final Class<V> valueType)
{
ArgumentChecks.ensureNonNull("valueType", valueType);
- return org.apache.sis.util.collection.Collections.derivedMap(storage,
- keyConverter, IdentityConverter.create(valueType));
+ return CollectionsExt.derivedMap(storage, keyConverter, IdentityConverter.create(valueType));
}
/**
@@ -133,7 +133,7 @@ public final class ObjectConverters exte
* invoking the {@link ObjectConverter#convert(Object)} method on the given converter.
*
* <p>This convenience method delegates to
- * {@link org.apache.sis.util.collection.Collections#derivedMap Collections.derivedMap(â¦)}.
+ * {@link CollectionsExt#derivedMap CollectionsExt.derivedMap(â¦)}.
* See the javadoc of the above method for more information.
*
* @param <K> The type of keys in the storage and derived map.
@@ -145,14 +145,13 @@ public final class ObjectConverters exte
* @return A view over the {@code storage} map containing all entries with the values converted
* by the given converter, or {@code null} if {@code storage} was null.
*
- * @see org.apache.sis.util.collection.Collections#derivedMap(Map, ObjectConverter, ObjectConverter)
+ * @see CollectionsExt#derivedMap(Map, ObjectConverter, ObjectConverter)
*/
public static <K,SV,V> Map<K,V> derivedValues(final Map<K,SV> storage,
final Class<K> keyType,
final ObjectConverter<SV,V> valueConverter)
{
ArgumentChecks.ensureNonNull("keyType", keyType);
- return org.apache.sis.util.collection.Collections.derivedMap(storage,
- IdentityConverter.create(keyType), valueConverter);
+ return CollectionsExt.derivedMap(storage, IdentityConverter.create(keyType), valueConverter);
}
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Static.java Fri Feb 1 19:31:18 2013
@@ -42,9 +42,9 @@ package org.apache.sis.util;
* and test if a unit is angular, linear or temporal.</td></tr>
*
* <tr><th colspan="2" class="hsep">Structures (trees, collections, arrays, parameters)</th></tr>
- * <tr><td>{@link org.apache.sis.util.collection.Collections}</td>
+ * <tr><td>{@link org.apache.sis.util.collection.CollectionsExt}</td>
* <td>Additions to the JDK {@link java.util.Collections} methods.</td></tr>
- * <tr><td>{@link Arrays}</td>
+ * <tr><td>{@link ArraysExt}</td>
* <td>Insert or remove elements in the middle of arrays.</td></tr>
*
* <tr><th colspan="2" class="hsep">Input / Output (including CRS, XML, images)</th></tr>
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java Fri Feb 1 19:31:18 2013
@@ -299,16 +299,15 @@ public final class Utilities extends Sta
* <ul>
* <li>If the supplied object is {@code null}, then this method returns 0.</li>
* <li>Otherwise if the object is an array of objects, then
- * {@link java.util.Arrays#deepHashCode(Object[])} is invoked.</li>
+ * {@link Arrays#deepHashCode(Object[])} is invoked.</li>
* <li>Otherwise if the object is an array of primitive type, then the corresponding
- * {@link java.util.Arrays#hashCode(double[]) Arrays.hashCode(...)} method is invoked.</li>
+ * {@link Arrays#hashCode(double[]) Arrays.hashCode(...)} method is invoked.</li>
* <li>Otherwise {@link Object#hashCode()} is invoked.</li>
* </ul>
*
* This method should be invoked <strong>only</strong> if the object type is declared
* exactly as {@code Object}, not as some subtype like {@code Object[]}, {@code String} or
- * {@code float[]}. In the later cases, use the appropriate {@link java.util.Arrays} method
- * instead.
+ * {@code float[]}. In the later cases, use the appropriate {@link Arrays} method instead.
*
* @param object The object to compute hash code. May be {@code null}.
* @return The hash code of the given object.
@@ -335,16 +334,15 @@ public final class Utilities extends Sta
*
* <ul>
* <li>If the object is an array of objects, then
- * {@link java.util.Arrays#deepToString(Object[])} is invoked.</li>
+ * {@link Arrays#deepToString(Object[])} is invoked.</li>
* <li>Otherwise if the object is an array of primitive type, then the corresponding
- * {@link java.util.Arrays#toString(double[]) Arrays.toString(...)} method is invoked.</li>
+ * {@link Arrays#toString(double[]) Arrays.toString(...)} method is invoked.</li>
* <li>Otherwise {@link String#valueOf(Object)} is invoked.</li>
* </ul>
*
* This method should be invoked <strong>only</strong> if the object type is declared
* exactly as {@code Object}, not as some subtype like {@code Object[]}, {@code Number} or
- * {@code float[]}. In the later cases, use the appropriate {@link java.util.Arrays} method
- * instead.
+ * {@code float[]}. In the later cases, use the appropriate {@link Arrays} method instead.
*
* @param object The object to format as a string. May be {@code null}.
* @return A string representation of the given object.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java Fri Feb 1 19:31:18 2013
@@ -207,7 +207,7 @@ public class Cache<K,V> extends Abstract
public Cache(int initialCapacity, final long costLimit, final boolean soft) {
ArgumentChecks.ensureStrictlyPositive("initialCapacity", initialCapacity);
ArgumentChecks.ensurePositive("costLimit", costLimit);
- initialCapacity = Collections.hashMapCapacity(initialCapacity);
+ initialCapacity = CollectionsExt.hashMapCapacity(initialCapacity);
this.map = new ConcurrentHashMap<K,Object>(initialCapacity);
this.costs = new LinkedHashMap<K,Integer>((int) Math.min(initialCapacity, costLimit), 0.75f, true);
this.costLimit = costLimit;
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java Fri Feb 1 19:31:18 2013
@@ -31,12 +31,12 @@ import static org.apache.sis.util.Argume
/**
- * A {@linkplain java.util.Collections#checkedList(List, Class) checked} and
- * {@linkplain java.util.Collections#synchronizedList(List) synchronized} {@link ArrayList}.
+ * A {@linkplain Collections#checkedList(List, Class) checked} and
+ * {@linkplain Collections#synchronizedList(List) synchronized} {@link ArrayList}.
* The type checks are performed at run-time in addition to the compile-time checks.
*
* <p>Using this class is similar to wrapping an {@link ArrayList} using the methods provided
- * in the standard {@link java.util.Collections} class, except for the following advantages:</p>
+ * in the standard {@link Collections} class, except for the following advantages:</p>
*
* <ul>
* <li>Avoid the two levels of indirection (for type check and synchronization).</li>
@@ -61,8 +61,8 @@ import static org.apache.sis.util.Argume
* @version 0.3
* @module
*
- * @see java.util.Collections#checkedList(List, Class)
- * @see java.util.Collections#synchronizedList(List)
+ * @see Collections#checkedList(List, Class)
+ * @see Collections#synchronizedList(List)
*/
@ThreadSafe
public class CheckedArrayList<E> extends ArrayList<E> implements CheckedContainer<E>, Cloneable {
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java Fri Feb 1 19:31:18 2013
@@ -31,12 +31,12 @@ import static org.apache.sis.util.Argume
/**
- * A {@linkplain java.util.Collections#checkedMap(Map, Class, Class) checked} and
- * {@linkplain java.util.Collections#synchronizedMap(Map) synchronized} {@link LinkedHashMap}.
+ * A {@linkplain Collections#checkedMap(Map, Class, Class) checked} and
+ * {@linkplain Collections#synchronizedMap(Map) synchronized} {@link LinkedHashMap}.
* The type checks are performed at run-time in addition to the compile-time checks.
*
* <p>Using this class is similar to wrapping a {@link LinkedHashMap} using the methods provided
- * in the standard {@link java.util.Collections} class, except for the following advantages:</p>
+ * in the standard {@link Collections} class, except for the following advantages:</p>
*
* <ul>
* <li>Avoid the two levels of indirection (for type check and synchronization).</li>
@@ -61,8 +61,8 @@ import static org.apache.sis.util.Argume
* @version 0.3
* @module
*
- * @see java.util.Collections#checkedMap(Map, Class, Class)
- * @see java.util.Collections#synchronizedMap(Map)
+ * @see Collections#checkedMap(Map, Class, Class)
+ * @see Collections#synchronizedMap(Map)
*/
@ThreadSafe
public class CheckedHashMap<K,V> extends LinkedHashMap<K,V> implements Cloneable {
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java Fri Feb 1 19:31:18 2013
@@ -30,12 +30,12 @@ import static org.apache.sis.util.Argume
/**
- * A {@linkplain java.util.Collections#checkedSet(Set, Class) checked} and
- * {@linkplain java.util.Collections#synchronizedSet(Set) synchronized} {@link LinkedHashSet}.
+ * A {@linkplain Collections#checkedSet(Set, Class) checked} and
+ * {@linkplain Collections#synchronizedSet(Set) synchronized} {@link LinkedHashSet}.
* The type checks are performed at run-time in addition to the compile-time checks.
*
* <p>Using this class is similar to wrapping a {@link LinkedHashSet} using the methods provided
- * in the standard {@link java.util.Collections} class, except for the following advantages:</p>
+ * in the standard {@link Collections} class, except for the following advantages:</p>
*
* <ul>
* <li>Avoid the two levels of indirection (for type check and synchronization).</li>
@@ -60,8 +60,8 @@ import static org.apache.sis.util.Argume
* @version 0.3
* @module
*
- * @see java.util.Collections#checkedSet(Set, Class)
- * @see java.util.Collections#synchronizedSet(Set)
+ * @see Collections#checkedSet(Set, Class)
+ * @see Collections#synchronizedSet(Set)
*/
@ThreadSafe
public class CheckedHashSet<E> extends LinkedHashSet<E> implements CheckedContainer<E>, Cloneable {
Copied: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java (from r1441586, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java?p2=sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java&p1=sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java&r1=1441586&r2=1441594&rev=1441594&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java Fri Feb 1 19:31:18 2013
@@ -224,7 +224,6 @@ public final class CollectionsExt extend
*
* @category converter
*/
- @SafeVarargs
public static <E> Set<E> immutableSet(final E... array) {
if (array == null) {
return null;
@@ -232,7 +231,7 @@ public final class CollectionsExt extend
switch (array.length) {
case 0: return Collections.emptySet();
case 1: return Collections.singleton(array[0]);
- default: return Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(array)));
+ default: return Collections.unmodifiableSet(new LinkedHashSet<E>(Arrays.asList(array)));
}
}
@@ -349,23 +348,23 @@ public final class CollectionsExt extend
if (type == TreeSet.class) {
return (Collection<E>) ((TreeSet<E>) collection).clone();
}
- return new TreeSet<>(collection);
+ return new TreeSet<E>(collection);
}
if (type == HashSet.class || type == LinkedHashSet.class) {
return (Collection<E>) ((HashSet<E>) collection).clone();
}
- return new LinkedHashSet<>(collection);
+ return new LinkedHashSet<E>(collection);
}
if (collection instanceof Queue<?>) {
if (type == LinkedList.class) {
return (Collection<E>) ((LinkedList<E>) collection).clone();
}
- return new LinkedList<>(collection);
+ return new LinkedList<E>(collection);
}
if (type == ArrayList.class) {
return (Collection<E>) ((ArrayList<E>) collection).clone();
}
- return new ArrayList<>(collection);
+ return new ArrayList<E>(collection);
}
/**
@@ -401,12 +400,12 @@ public final class CollectionsExt extend
if (type == TreeMap.class) {
return (Map<K,V>) ((TreeMap<K,V>) map).clone();
}
- return new TreeMap<>(map);
+ return new TreeMap<K,V>(map);
}
if (type == HashMap.class || type == LinkedHashMap.class) {
return (Map<K,V>) ((HashMap<K,V>) map).clone();
}
- return new LinkedHashMap<>(map);
+ return new LinkedHashMap<K,V>(map);
}
/**
@@ -446,7 +445,7 @@ public final class CollectionsExt extend
return Arrays.asList((Object[]) value);
}
if (value instanceof Iterable<?>) {
- final List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<Object>();
for (final Object element : (Iterable<?>) value) {
list.add(element);
}
@@ -454,7 +453,7 @@ public final class CollectionsExt extend
}
if (value instanceof Iterator<?>) {
final Iterator<?> it = (Iterator<?>) value;
- final List<Object> list = new ArrayList<>();
+ final List<Object> list = new ArrayList<Object>();
while (it.hasNext()) {
list.add(it.next());
}
@@ -492,7 +491,7 @@ public final class CollectionsExt extend
if (collection instanceof List<?>) {
return (List<T>) collection;
}
- return new ArrayList<>(collection);
+ return new ArrayList<T>(collection);
}
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java Fri Feb 1 19:31:18 2013
@@ -27,8 +27,8 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.internal.util.Cloner;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
-import static org.apache.sis.util.collection.Collections.isNullOrEmpty;
-import static org.apache.sis.util.collection.Collections.hashMapCapacity;
+import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
+import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
// Related to JDK7
import org.apache.sis.internal.util.Objects;
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java Fri Feb 1 19:31:18 2013
@@ -24,11 +24,9 @@ import java.io.File;
import java.text.ParseException;
import org.opengis.util.InternationalString;
import org.apache.sis.util.Static;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.ArgumentChecks;
-import static org.apache.sis.util.Arrays.resize;
-import static org.apache.sis.util.Arrays.insert;
-
/**
* Static methods working on {@link TreeTable} objects and their nodes.
@@ -175,7 +173,7 @@ public final class TreeTables extends St
filtered[count++] = (TableColumn<? super String>) column;
}
}
- filtered = resize(filtered, count);
+ filtered = ArraysExt.resize(filtered, count);
return valuesAsStrings(table.getRoot(), filtered, locale, new HashMap<String,String>());
}
@@ -253,7 +251,7 @@ public final class TreeTables extends St
ArgumentChecks.ensureNonNull("nodes", nodes);
TableColumn<?>[] columns = null; // Default to singleton(NAME).
if (values.length != 0 || nodes != TableColumn.NAME) {
- columns = insert(values, 0, 1);
+ columns = ArraysExt.insert(values, 0, 1);
columns[0] = nodes;
}
final TreeTableFormat format = TreeTableFormat.INSTANCE;
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java Fri Feb 1 19:31:18 2013
@@ -23,12 +23,12 @@ import java.lang.reflect.Array;
import net.jcip.annotations.ThreadSafe;
import org.apache.sis.util.Debug;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.Workaround;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.NullArgumentException;
-import static org.apache.sis.util.Arrays.resize;
import static org.apache.sis.util.collection.WeakEntry.*;
// Related to JDK7
@@ -234,7 +234,7 @@ public class WeakHashSet<E> extends Abst
*/
@Override
public synchronized boolean remove(final Object element) {
- return intern(elementType.cast(element), REMOVE) != null;
+ return intern(element, REMOVE) != null;
}
/**
@@ -242,14 +242,13 @@ public class WeakHashSet<E> extends Abst
* contain any object equals to {@code element}, then this method returns {@code null}.
* Null values are considered never present.
*
- * @param <T> The type of the element to get. Can be {@code null}.
* @param element The element to get.
* @return An element equals to the given one if already presents in the set,
* or {@code null} otherwise.
*
* @see #unique(Object)
*/
- public synchronized <T extends E> T get(final T element) {
+ public synchronized E get(final Object element) {
return intern(element, GET);
}
@@ -289,28 +288,10 @@ public class WeakHashSet<E> extends Abst
* or the given {@code object} otherwise.
*/
public synchronized <T extends E> T unique(final T element) {
- return intern(element, INTERN);
- }
-
- /**
- * Iteratively call {@link #unique(Object)} for an array of objects.
- * This method is equivalents to the following code:
- *
- * {@preformat java
- * for (int i=0; i<elements.length; i++) {
- * elements[i] = unique(elements[i]);
- * }
- * }
- *
- * @param elements
- * On input, the objects to add to this set if not already present. On output,
- * elements that are equal, but where every reference to an instance already
- * presents in this set has been replaced by a reference to the existing instance.
- */
- public synchronized void uniques(final E[] elements) {
- for (int i=0; i<elements.length; i++) {
- elements[i] = intern(elements[i], INTERN);
- }
+ // There is no way to make sure that this operation is really safe.
+ // We have to trust the Object.equals(Object) method to be strict
+ // about the type of compared objects.
+ return (T) intern(element, INTERN);
}
// Arguments for the {@link #intern} method.
@@ -320,23 +301,10 @@ public class WeakHashSet<E> extends Abst
/** The "intern" operation. */ private static final int INTERN = +2;
/**
- * Returns an object equals to {@code obj} if such an object already exist in this
- * {@code WeakHashSet}. Otherwise, add {@code obj} to this {@code WeakHashSet}.
- * This method is equivalents to the following code:
- *
- * {@preformat java
- * if (object!=null) {
- * final Object current = get(object);
- * if (current != null) {
- * return current;
- * } else {
- * add(object);
- * }
- * }
- * return object;
- * }
+ * Implementation of the {@link #add(Object)}, {@link #remove(Object)}, {@link #get(Object)},
+ * {@link #contains(Object)} and {@link #intern(Object)} methods.
*/
- private <T> T intern(final T obj, final int operation) {
+ private E intern(final Object obj, final int operation) {
assert isValid();
if (obj != null) {
/*
@@ -352,10 +320,7 @@ public class WeakHashSet<E> extends Abst
if (operation == REMOVE) {
e.dispose();
}
- // There is no way to make sure that this operation is really safe.
- // We have to trust the Object.equals(Object) method to be strict
- // about the type of compared objects.
- return (T) candidate;
+ return candidate;
}
// Do not remove the null element; lets ReferenceQueue do its job
// (it was a bug to remove element here as an "optimization")
@@ -371,11 +336,15 @@ public class WeakHashSet<E> extends Abst
}
lastTimeNormalCapacity = System.nanoTime();
}
- table[index] = new Entry(elementType.cast(obj), table[index], hash);
+ final E element = elementType.cast(obj);
+ table[index] = new Entry(element, table[index], hash);
+ assert isValid();
+ if (operation == INTERN) {
+ return element;
+ }
}
}
- assert isValid();
- return (operation == INTERN) ? obj : null;
+ return null;
}
/**
@@ -408,7 +377,7 @@ public class WeakHashSet<E> extends Abst
}
}
}
- return resize(elements, index);
+ return ArraysExt.resize(elements, index);
}
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java Fri Feb 1 19:31:18 2013
@@ -27,12 +27,12 @@ import java.lang.ref.WeakReference;
import net.jcip.annotations.ThreadSafe;
import org.apache.sis.util.Debug;
+import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.Utilities;
import org.apache.sis.util.Workaround;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.NullArgumentException;
-import static org.apache.sis.util.Arrays.resize;
import static org.apache.sis.util.collection.WeakEntry.*;
// Related to JDK7
@@ -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);
}
/**
@@ -489,7 +465,7 @@ public class WeakValueHashMap<K,V> exten
}
}
}
- return resize(elements, index);
+ return ArraysExt.resize(elements, index);
}
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java Fri Feb 1 19:31:18 2013
@@ -44,8 +44,8 @@
* a hook for making the collections read-only and allow the caller to specify the synchronization
* lock of his choice.
* </li><li>
- * {@linkplain org.apache.sis.util.collection.Collections#derivedMap Derived Map} and
- * {@linkplain org.apache.sis.util.collection.Collections#derivedSet derived Set} are wrapper collections
+ * {@linkplain org.apache.sis.util.collection.CollectionsExt#derivedMap Derived Map} and
+ * {@linkplain org.apache.sis.util.collection.CollectionsExt#derivedSet derived Set} are wrapper collections
* in which the keys or the values are derived on-the-fly from the content of an other collection.
* The can also be used for creating filtered views.
* </li><li>
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java?rev=1441594&r1=1441593&r2=1441594&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java Fri Feb 1 19:31:18 2013
@@ -31,7 +31,7 @@ import org.opengis.util.InternationalStr
import org.apache.sis.util.Locales;
import org.apache.sis.util.resources.Errors;
-import static org.apache.sis.util.collection.Collections.isNullOrEmpty;
+import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
// Related to JDK7
import org.apache.sis.internal.util.Objects;