Author: desruisseaux
Date: Fri Feb 1 19:14:57 2013
New Revision: 1441586
URL: http://svn.apache.org/viewvc?rev=1441586&view=rev
Log:
Renamed Collections to CollectionsExt, for the same reason than the renaming
from Arrays to ArraysExt
(the two classes are often used together, thus causing a risk of confusion).
Added:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java
- copied, changed from r1441581,
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java
Removed:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java
Modified:
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
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/measure/FormattedCharacterIterator.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Locales.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Static.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
Modified:
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
(original)
+++
sis/branches/JDK7/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
Fri Feb 1 19:14:57 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/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=1441586&r1=1441585&r2=1441586&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
Fri Feb 1 19:14:57 2013
@@ -31,7 +31,7 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.xml.IdentifierMap;
import org.apache.sis.xml.IdentifierSpace;
-import static org.apache.sis.util.collection.Collections.hashMapCapacity;
+import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
// Related to JDK7
import java.util.Objects;
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
Fri Feb 1 19:14:57 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/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java
Fri Feb 1 19:14:57 2013
@@ -29,7 +29,7 @@ import java.lang.reflect.WildcardType;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
-import static org.apache.sis.util.collection.Collections.hashMapCapacity;
+import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
/**
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Locales.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Locales.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Locales.java
Fri Feb 1 19:14:57 2013
@@ -29,7 +29,7 @@ import org.apache.sis.util.logging.Loggi
import org.apache.sis.util.resources.Errors;
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;
/**
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
Fri Feb 1 19:14:57 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/JDK7/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
Fri Feb 1 19:14:57 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/JDK7/sis-utility/src/main/java/org/apache/sis/util/Static.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Static.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Static.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Static.java
Fri Feb 1 19:14:57 2013
@@ -42,7 +42,7 @@ 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 ArraysExt}</td>
* <td>Insert or remove elements in the middle of arrays.</td></tr>
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
Fri Feb 1 19:14:57 2013
@@ -205,7 +205,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<>(initialCapacity);
this.costs = new LinkedHashMap<>((int) Math.min(initialCapacity,
costLimit), 0.75f, true);
this.costLimit = costLimit;
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedArrayList.java
Fri Feb 1 19:14:57 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/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashMap.java
Fri Feb 1 19:14:57 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/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CheckedHashSet.java
Fri Feb 1 19:14:57 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/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java
(from r1441581,
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java)
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java?p2=sis/branches/JDK7/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/Collections.java&r1=1441581&r2=1441586&rev=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/CollectionsExt.java
Fri Feb 1 19:14:57 2013
@@ -22,20 +22,11 @@ import org.apache.sis.util.Static;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.ObjectConverter;
-import static java.util.Collections.list;
-import static java.util.Collections.emptySet;
-import static java.util.Collections.emptyMap;
-import static java.util.Collections.emptyList;
-import static java.util.Collections.singleton;
-import static java.util.Collections.singletonMap;
-import static java.util.Collections.singletonList;
-import static java.util.Collections.unmodifiableSet;
-import static java.util.Collections.unmodifiableMap;
-
/**
* Static methods working on {@link Collection} objects.
- * This is an extension to the Java {@link java.util.Collections} utility
class providing:
+ * This is an extension to the standard {@link Collections} utility class.
+ * Some worthy methods are:
*
* <ul>
* <li>Null-safe {@link #isNullOrEmpty(Collection) isNullOrEmpty} method,
@@ -46,7 +37,7 @@ import static java.util.Collections.unmo
* <li>{@link #modifiableCopy(Collection) modifiableCopy} method for taking
a snapshot of an arbitrary
* implementation into an unsynchronized, modifiable, in-memory
object.</li>
* <li>{@link #unmodifiableOrCopy(Set) unmodifiableOrCopy} methods, which
may be slightly more
- * compact than the standard {@link
java.util.Collections#unmodifiableSet(Set)} equivalent
+ * compact than the standard {@link Collections#unmodifiableSet(Set)}
equivalent
* when the unmodifiable collection is not required to be a view over
the original collection.</li>
* </ul>
*
@@ -55,11 +46,11 @@ import static java.util.Collections.unmo
* @version 0.3
* @module
*/
-public final class Collections extends Static {
+public final class CollectionsExt extends Static {
/**
* Do not allow instantiation of this class.
*/
- private Collections() {
+ private CollectionsExt() {
}
/**
@@ -101,8 +92,8 @@ public final class Collections extends S
* @param <E> The type of elements in the empty collection.
* @return An empty collection.
*
- * @see java.util.Collections#emptyList()
- * @see java.util.Collections#emptySet()
+ * @see Collections#emptyList()
+ * @see Collections#emptySet()
*/
@SuppressWarnings({"unchecked","rawtype"})
public static <E> Queue<E> emptyQueue() {
@@ -118,8 +109,8 @@ public final class Collections extends S
* @param <E> The type of elements in the empty collection.
* @return An empty collection.
*
- * @see java.util.Collections#emptyList()
- * @see java.util.Collections#emptySet()
+ * @see Collections#emptyList()
+ * @see Collections#emptySet()
*/
@SuppressWarnings({"unchecked","rawtype"})
public static <E> SortedSet<E> emptySortedSet() {
@@ -229,7 +220,7 @@ public final class Collections extends S
* @param array The array to copy in a set. May be {@code null}.
* @return A set containing the array elements, or {@code null} if the
given array was null.
*
- * @see java.util.Collections#unmodifiableSet(Set)
+ * @see Collections#unmodifiableSet(Set)
*
* @category converter
*/
@@ -239,15 +230,15 @@ public final class Collections extends S
return null;
}
switch (array.length) {
- case 0: return emptySet();
- case 1: return singleton(array[0]);
- default: return unmodifiableSet(new
LinkedHashSet<>(Arrays.asList(array)));
+ case 0: return Collections.emptySet();
+ case 1: return Collections.singleton(array[0]);
+ default: return Collections.unmodifiableSet(new
LinkedHashSet<>(Arrays.asList(array)));
}
}
/**
* Returns a unmodifiable version of the given set.
- * This method is different than the standard {@link
java.util.Collections#unmodifiableSet(Set)}
+ * This method is different than the standard {@link
Collections#unmodifiableSet(Set)}
* in that it tries to returns a more efficient object when there is zero
or one element.
* Such small set occurs frequently in Apache SIS, especially for
* {@link org.apache.sis.referencing.AbstractIdentifiedObject} names or
identifiers.
@@ -255,7 +246,7 @@ public final class Collections extends S
* <p><em>The set returned by this method may or may not be a view of the
given set</em>.
* Consequently this method shall be used <strong>only</strong> if the
given set will
* <strong>not</strong> be modified after this method call. In case of
doubt, use the
- * standard {@link java.util.Collections#unmodifiableSet(Set)} method
instead.</p>
+ * standard {@link Collections#unmodifiableSet(Set)} method instead.</p>
*
* @param <E> The type of elements in the set.
* @param set The set to make unmodifiable, or {@code null}.
@@ -267,15 +258,15 @@ public final class Collections extends S
if (set != null) {
switch (set.size()) {
case 0: {
- set = emptySet();
+ set = Collections.emptySet();
break;
}
case 1: {
- set = singleton(set.iterator().next());
+ set = Collections.singleton(set.iterator().next());
break;
}
default: {
- set = unmodifiableSet(set);
+ set = Collections.unmodifiableSet(set);
break;
}
}
@@ -285,14 +276,14 @@ public final class Collections extends S
/**
* Returns a unmodifiable version of the given map.
- * This method is different than the standard {@link
java.util.Collections#unmodifiableMap(Map)}
+ * This method is different than the standard {@link
Collections#unmodifiableMap(Map)}
* in that it tries to returns a more efficient object when there is zero
or one entry.
* Such small maps occur frequently in Apache SIS.
*
* <p><em>The map returned by this method may or may not be a view of the
given map</em>.
* Consequently this method shall be used <strong>only</strong> if the
given map will
* <strong>not</strong> be modified after this method call. In case of
doubt, use the
- * standard {@link java.util.Collections#unmodifiableMap(Map)} method
instead.</p>
+ * standard {@link Collections#unmodifiableMap(Map)} method instead.</p>
*
* @param <K> The type of keys in the map.
* @param <V> The type of values in the map.
@@ -305,16 +296,16 @@ public final class Collections extends S
if (map != null) {
switch (map.size()) {
case 0: {
- map = emptyMap();
+ map = Collections.emptyMap();
break;
}
case 1: {
final Map.Entry<K,V> entry =
map.entrySet().iterator().next();
- map = singletonMap(entry.getKey(), entry.getValue());
+ map = Collections.singletonMap(entry.getKey(),
entry.getValue());
break;
}
default: {
- map = unmodifiableMap(map);
+ map = Collections.unmodifiableMap(map);
break;
}
}
@@ -422,11 +413,11 @@ public final class Collections extends S
* Returns the given value as a collection. Special cases:
*
* <ul>
- * <li>If the value is null, then this method returns an {@linkplain
java.util.Collections#emptyList() empty list}.</li>
+ * <li>If the value is null, then this method returns an {@linkplain
Collections#emptyList() empty list}.</li>
* <li>If the value is an instance of {@link Collection}, then it is
returned unchanged.</li>
* <li>If the value is an array of objects, then it is returned
{@linkplain Arrays#asList(Object[]) as a list}.</li>
* <li>If the value is an instance of {@link Iterable}, {@link Iterator}
or {@link Enumeration}, copies the values in a new list.</li>
- * <li>Otherwise the value is returned as a {@linkplain
java.util.Collections#singletonList(Object) singleton list}.</li>
+ * <li>Otherwise the value is returned as a {@linkplain
Collections#singletonList(Object) singleton list}.</li>
* </ul>
*
* <p>Note that in the {@link Iterator} and {@link Enumeration} cases, the
given value object
@@ -446,7 +437,7 @@ public final class Collections extends S
*/
public static Collection<?> toCollection(final Object value) {
if (value == null) {
- return emptyList();
+ return Collections.emptyList();
}
if (value instanceof Collection<?>) {
return (Collection<?>) value;
@@ -470,9 +461,9 @@ public final class Collections extends S
return list;
}
if (value instanceof Enumeration<?>) {
- return list((Enumeration<?>) value);
+ return Collections.list((Enumeration<?>) value);
}
- return singletonList(value);
+ return Collections.singletonList(value);
}
/**
@@ -628,7 +619,7 @@ public final class Collections extends S
}
/**
- * Returns a comparator for map entries having comparable {@linkplain
java.util.Map.Entry#getValue() values}.
+ * Returns a comparator for map entries having comparable {@linkplain
Map.Entry#getValue() values}.
* For any pair of entries {@code e1} and {@code e2}, this method performs
the comparison as below:
*
* {@preformat java
@@ -651,12 +642,12 @@ public final class Collections extends S
}
/**
- * Returns the capacity to be given to the {@link
java.util.HashMap#HashMap(int) HashMap}
+ * Returns the capacity to be given to the {@link HashMap#HashMap(int)
HashMap}
* constructor for holding the given number of elements. This method
computes the capacity
* for the default <cite>load factor</cite>, which is 0.75.
*
- * <p>The same calculation can be used for {@link java.util.LinkedHashMap}
and
- * {@link java.util.HashSet} as well, which are built on top of {@code
HashMap}.</p>
+ * <p>The same calculation can be used for {@link LinkedHashMap} and
+ * {@link HashSet} as well, which are built on top of {@code HashMap}.</p>
*
* @param count The number of elements to be put into the hash map or hash
set.
* @return The minimal initial capacity to be given to the hash map
constructor.
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
Fri Feb 1 19:14:57 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 java.util.Objects;
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java
Fri Feb 1 19:14:57 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/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
(original)
+++
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
Fri Feb 1 19:14:57 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 java.util.Objects;
Modified:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
Fri Feb 1 19:14:57 2013
@@ -31,10 +31,9 @@ import javax.xml.bind.annotation.adapter
import org.apache.sis.util.Version;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.collection.CollectionsExt;
import org.apache.sis.internal.jaxb.MarshalContext;
-import static org.apache.sis.util.collection.Collections.unmodifiableOrCopy;
-
/**
* Base class of {@link PooledMarshaller} and {@link PooledUnmarshaller}.
@@ -265,7 +264,7 @@ abstract class Pooled {
copy.put(key, (String) schema);
}
}
- copy = unmodifiableOrCopy(copy);
+ copy = CollectionsExt.unmodifiableOrCopy(copy);
}
schemas = copy;
return;
Modified:
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java?rev=1441586&r1=1441585&r2=1441586&view=diff
==============================================================================
---
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
(original)
+++
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
Fri Feb 1 19:14:57 2013
@@ -39,8 +39,8 @@ import org.junit.runners.model.TestClass
import org.apache.sis.util.ArraysExt;
-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;
/**