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 2012/10/06 06:37:16 UTC
svn commit: r1394916 - in /sis/branches/JDK7: ide-project/NetBeans/nbproject/
sis-build-helper/src/main/java/org/apache/sis/internal/taglet/
sis-build-helper/src/main/java/org/apache/sis/util/resources/
sis-utility/src/main/java/org/apache/sis/internal...
Author: desruisseaux
Date: Sat Oct 6 04:37:15 2012
New Revision: 1394916
URL: http://svn.apache.org/viewvc?rev=1394916&view=rev
Log:
Leverage JDK7 features (diamond operation, try with resources, multi-catches, suppressed exception, Objects).
Removed:
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/Objects.java
Modified:
sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/ReferenceQueueConsumer.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Arrays.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/Exceptions.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/collection/Collections.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/ResourceInternationalString.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/SimpleInternationalString.java
sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/Types.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/util/ReferenceQueueConsumerTest.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/Assert.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties (original)
+++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties Sat Oct 6 04:37:15 2012
@@ -15,8 +15,8 @@ excludes =
main.class =
manifest.file = manifest.mf
source.encoding = UTF-8
-javac.source = 1.6
-javac.target = 1.6
+javac.source = 1.7
+javac.target = 1.7
platform.active = JDK_1.7
run.jvmargs = -ea
Modified: sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java (original)
+++ sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/internal/taglet/Preformat.java Sat Oct 6 04:37:15 2012
@@ -160,7 +160,7 @@ all: while (tk.hasMoreTokens()) {
* Lists of Java keywords.
*/
private static final Set<String> KEYWORDS =
- Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
+ Collections.unmodifiableSet(new HashSet<>(Arrays.asList(
"abstract", "continue", "for", "new", "switch",
"assert", "default", "goto", "package", "synchronized",
"boolean", "do", "if", "private", "this",
Modified: sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java (original)
+++ sis/branches/JDK7/sis-build-helper/src/main/java/org/apache/sis/util/resources/IndexedResourceCompiler.java Sat Oct 6 04:37:15 2012
@@ -103,13 +103,13 @@ class IndexedResourceCompiler implements
* Integer IDs allocated to resource keys. This map will be shared for all languages
* of a given resource bundle.
*/
- private final Map<Integer,String> allocatedIDs = new HashMap<Integer,String>();
+ private final Map<Integer,String> allocatedIDs = new HashMap<>();
/**
* Resource keys and their localized values. This map will be cleared for each language
* in a resource bundle.
*/
- private final Map<Object,Object> resources = new HashMap<Object,Object>();
+ private final Map<Object,Object> resources = new HashMap<>();
/**
* The resources bundle base classes.
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/DaemonThread.java Sat Oct 6 04:37:15 2012
@@ -150,7 +150,7 @@ abstract class DaemonThread extends Thre
for (DaemonThread thread=first; thread!=null; thread=thread.previous) {
if (!thread.isAlive()) {
if (list == null) {
- list = new ArrayList<String>();
+ list = new ArrayList<>();
}
list.add(thread.getName());
}
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/ReferenceQueueConsumer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/ReferenceQueueConsumer.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/ReferenceQueueConsumer.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/ReferenceQueueConsumer.java Sat Oct 6 04:37:15 2012
@@ -61,7 +61,7 @@ public final class ReferenceQueueConsume
public static final ReferenceQueueConsumer<Object> DEFAULT;
static {
synchronized (Threads.class) {
- Threads.lastCreatedDaemon = DEFAULT = new ReferenceQueueConsumer<Object>(Threads.lastCreatedDaemon);
+ Threads.lastCreatedDaemon = DEFAULT = new ReferenceQueueConsumer<>(Threads.lastCreatedDaemon);
}
// Call to Thread.start() must be outside the constructor
// (Reference: Goetz et al.: "Java Concurrency in Practice").
@@ -73,7 +73,7 @@ public final class ReferenceQueueConsume
* {@link Reference} constructors as documented in the class javadoc. Those {@code Reference}
* sub-classes <strong>must</strong> implement the {@link Disposable} interface.
*/
- public final ReferenceQueue<T> queue = new ReferenceQueue<T>();
+ public final ReferenceQueue<T> queue = new ReferenceQueue<>();
/**
* Constructs a new thread as a daemon thread. This thread will be sleeping most of the time.
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Arrays.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Arrays.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Arrays.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Arrays.java Sat Oct 6 04:37:15 2012
@@ -21,7 +21,7 @@ import java.lang.reflect.Array;
import static java.util.Arrays.copyOf;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
@@ -1801,6 +1801,7 @@ public final class Arrays extends Static
* @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/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=1394916&r1=1394915&r2=1394916&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 Sat Oct 6 04:37:15 2012
@@ -278,7 +278,7 @@ public final class Classes extends Stati
* @return The set of classes of all objects in the given collection.
*/
public static <T> Set<Class<? extends T>> getClasses(final Collection<? extends T> objects) {
- final Set<Class<? extends T>> types = new LinkedHashSet<Class<? extends T>>();
+ final Set<Class<? extends T>> types = new LinkedHashSet<>();
for (final T object : objects) {
types.add(getClass(object));
}
@@ -297,7 +297,7 @@ public final class Classes extends Stati
* interface), or an empty set if none. Callers can freely modify the returned set.
*/
public static Set<Class<?>> getAllInterfaces(Class<?> type) {
- final Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
+ final Set<Class<?>> interfaces = new LinkedHashSet<>();
while (type != null) {
getAllInterfaces(type, interfaces);
type = type.getSuperclass();
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java Sat Oct 6 04:37:15 2012
@@ -104,7 +104,7 @@ public final class Exceptions extends St
String message = cause.getLocalizedMessage();
if (message != null && !(message = message.trim()).isEmpty()) {
if (buffer == null) {
- done = new HashSet<String>();
+ done = new HashSet<>();
buffer = new StringBuilder(128);
lineSeparator = System.getProperty("line.separator", "\n");
if (header != null && !(header = header.trim()).isEmpty()) {
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=1394916&r1=1394915&r2=1394916&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 Sat Oct 6 04:37:15 2012
@@ -57,7 +57,7 @@ public final class Locales extends Stati
private static final Map<Locale,Locale> POOL;
static {
final Locale[] locales = Locale.getAvailableLocales();
- POOL = new HashMap<Locale,Locale>(hashMapCapacity(locales.length));
+ POOL = new HashMap<>(hashMapCapacity(locales.length));
for (final Locale lc : locales) {
POOL.put(lc, lc);
}
@@ -185,7 +185,7 @@ public final class Locales extends Stati
* @return The languages, without country or variant information.
*/
public static Locale[] getLanguages(final Locale... locales) {
- final Set<String> codes = new LinkedHashSet<String>(hashMapCapacity(locales.length));
+ final Set<String> codes = new LinkedHashSet<>(hashMapCapacity(locales.length));
for (final Locale locale : locales) {
codes.add(locale.getLanguage());
}
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=1394916&r1=1394915&r2=1394916&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 Sat Oct 6 04:37:15 2012
@@ -43,7 +43,7 @@ public final class Numbers extends Stati
/**
* Mapping between a primitive type and its wrapper, if any.
*/
- private static final Map<Class<?>,Numbers> MAPPING = new HashMap<Class<?>,Numbers>(16);
+ private static final Map<Class<?>,Numbers> MAPPING = new HashMap<>(16);
static {
new Numbers(BigDecimal.class, true, false, (byte) (DOUBLE+2)); // Undocumented enum.
new Numbers(BigInteger.class, false, true, (byte) (DOUBLE+1)); // Undocumented enum.
Modified: 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/Collections.java?rev=1394916&r1=1394915&r2=1394916&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/Collections.java Sat Oct 6 04:37:15 2012
@@ -180,6 +180,7 @@ public final class Collections extends S
*
* @see java.util.Collections#unmodifiableSet(Set)
*/
+ @SafeVarargs
public static <E> Set<E> immutableSet(final E... array) {
if (array == null) {
return null;
@@ -187,7 +188,7 @@ public final class Collections extends S
switch (array.length) {
case 0: return emptySet();
case 1: return singleton(array[0]);
- default: return unmodifiableSet(new LinkedHashSet<E>(Arrays.asList(array)));
+ default: return unmodifiableSet(new LinkedHashSet<>(Arrays.asList(array)));
}
}
@@ -298,23 +299,23 @@ public final class Collections extends S
if (type == TreeSet.class) {
return (Collection<E>) ((TreeSet<E>) collection).clone();
}
- return new TreeSet<E>(collection);
+ return new TreeSet<>(collection);
}
if (type == HashSet.class || type == LinkedHashSet.class) {
return (Collection<E>) ((HashSet<E>) collection).clone();
}
- return new LinkedHashSet<E>(collection);
+ return new LinkedHashSet<>(collection);
}
if (collection instanceof Queue<?>) {
if (type == LinkedList.class) {
return (Collection<E>) ((LinkedList<E>) collection).clone();
}
- return new LinkedList<E>(collection);
+ return new LinkedList<>(collection);
}
if (type == ArrayList.class) {
return (Collection<E>) ((ArrayList<E>) collection).clone();
}
- return new ArrayList<E>(collection);
+ return new ArrayList<>(collection);
}
/**
@@ -348,12 +349,12 @@ public final class Collections extends S
if (type == TreeMap.class) {
return (Map<K,V>) ((TreeMap<K,V>) map).clone();
}
- return new TreeMap<K,V>(map);
+ return new TreeMap<>(map);
}
if (type == HashMap.class || type == LinkedHashMap.class) {
return (Map<K,V>) ((HashMap<K,V>) map).clone();
}
- return new LinkedHashMap<K,V>(map);
+ return new LinkedHashMap<>(map);
}
/**
@@ -391,7 +392,7 @@ public final class Collections extends S
return Arrays.asList((Object[]) value);
}
if (value instanceof Iterable<?>) {
- final List<Object> list = new ArrayList<Object>();
+ final List<Object> list = new ArrayList<>();
for (final Object element : (Iterable<?>) value) {
list.add(element);
}
@@ -399,7 +400,7 @@ public final class Collections extends S
}
if (value instanceof Iterator<?>) {
final Iterator<?> it = (Iterator<?>) value;
- final List<Object> list = new ArrayList<Object>();
+ final List<Object> list = new ArrayList<>();
while (it.hasNext()) {
list.add(it.next());
}
@@ -435,7 +436,7 @@ public final class Collections extends S
if (collection instanceof List<?>) {
return (List<T>) collection;
}
- return new ArrayList<T>(collection);
+ return new ArrayList<>(collection);
}
/**
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java Sat Oct 6 04:37:15 2012
@@ -32,7 +32,7 @@ import static org.apache.sis.util.Arrays
import static org.apache.sis.util.collection.WeakEntry.*;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java Sat Oct 6 04:37:15 2012
@@ -36,7 +36,7 @@ import static org.apache.sis.util.Arrays
import static org.apache.sis.util.collection.WeakEntry.*;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
@@ -459,7 +459,7 @@ public class WeakValueHashMap<K,V> exten
final Entry[] table = WeakValueHashMap.this.table;
for (int i=0; i<table.length; i++) {
for (Entry el=table[i]; el!=null; el=(Entry) el.next) {
- final Map.Entry<K,V> entry = new SimpleEntry<K,V>(el);
+ final Map.Entry<K,V> entry = new SimpleEntry<>(el);
if (entry.getValue() != null) {
elements[index++] = entry;
}
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerFactory.java Sat Oct 6 04:37:15 2012
@@ -59,7 +59,7 @@ public abstract class LoggerFactory<L> {
*/
protected LoggerFactory(final Class<L> loggerClass) {
this.loggerClass = loggerClass;
- loggers = new WeakValueHashMap<String,Logger>(String.class);
+ loggers = new WeakValueHashMap<>(String.class);
}
/**
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java Sat Oct 6 04:37:15 2012
@@ -360,8 +360,7 @@ public class IndexedResourceBundle exten
name = new StringBuilder(lang + (length-ext))
.append(name, 0, lang).append(name, ext, length).toString();
}
- final DataInputStream input = new DataInputStream(new BufferedInputStream(in));
- try {
+ try (DataInputStream input = new DataInputStream(new BufferedInputStream(in))) {
this.values = values = new String[input.readInt()];
for (int i=0; i<values.length; i++) {
values[i] = input.readUTF();
@@ -369,8 +368,6 @@ public class IndexedResourceBundle exten
values[i] = null;
}
}
- } finally {
- input.close();
}
/*
* Now, logs the message. This message is not localized. Note that
@@ -426,6 +423,7 @@ public class IndexedResourceBundle exten
try {
keyID = (Integer) getKeysClass().getField(key).get(null);
} catch (Exception e) {
+ e.addSuppressed(exception);
Logging.recoverableException(getClass(), "handleGetObject", e);
return null; // This is okay as of 'handleGetObject' contract.
}
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/resources/ResourceInternationalString.java Sat Oct 6 04:37:15 2012
@@ -24,7 +24,7 @@ import org.apache.sis.util.type.Abstract
// Related to JDK7
import org.apache.sis.util.Utilities;
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java Sat Oct 6 04:37:15 2012
@@ -34,7 +34,7 @@ import org.apache.sis.util.resources.Err
import static org.apache.sis.util.collection.Collections.isNullOrEmpty;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
@@ -107,7 +107,7 @@ public class DefaultInternationalString
if (!it.hasNext()) {
localeMap = Collections.singletonMap(entry.getKey(), entry.getValue());
} else {
- localeMap = new LinkedHashMap<Locale,String>(strings);
+ localeMap = new LinkedHashMap<>(strings);
// If HashMap is replaced by an other type, please revisit 'getLocales()'.
}
}
@@ -132,7 +132,7 @@ public class DefaultInternationalString
}
case 1: {
// If HashMap is replaced by an other type, please revisit 'getLocales()'.
- localeMap = new LinkedHashMap<Locale,String>(localeMap);
+ localeMap = new LinkedHashMap<>(localeMap);
localeSet = null;
break;
}
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/ResourceInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/ResourceInternationalString.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/ResourceInternationalString.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/ResourceInternationalString.java Sat Oct 6 04:37:15 2012
@@ -27,7 +27,7 @@ import org.opengis.util.InternationalStr
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/SimpleInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/SimpleInternationalString.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/SimpleInternationalString.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/SimpleInternationalString.java Sat Oct 6 04:37:15 2012
@@ -26,7 +26,7 @@ import org.opengis.util.InternationalStr
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/Types.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/Types.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/Types.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/type/Types.java Sat Oct 6 04:37:15 2012
@@ -114,7 +114,7 @@ public final class Types extends Static
} catch (Exception e) { // Catch IOException and IllegalArgumentException.
throw new BackingStoreException(e);
}
- typeForNames = new HashMap<Object,Object>(props);
+ typeForNames = new HashMap<>(props);
}
final Object value = typeForNames.get(identifier);
if (value == null || value instanceof Class<?>) {
Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/util/ReferenceQueueConsumerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/util/ReferenceQueueConsumerTest.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/util/ReferenceQueueConsumerTest.java (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/internal/util/ReferenceQueueConsumerTest.java Sat Oct 6 04:37:15 2012
@@ -45,7 +45,7 @@ public final strictfp class ReferenceQue
*/
@Test(expected=InterruptedException.class)
public void verifyInterruptAssumption() throws InterruptedException {
- final ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ final ReferenceQueue<Object> queue = new ReferenceQueue<>();
Thread.currentThread().interrupt();
assertNull(queue.remove(1000));
}
Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/Assert.java (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/Assert.java Sat Oct 6 04:37:15 2012
@@ -37,7 +37,7 @@ import org.xml.sax.SAXException;
import org.apache.sis.util.CharSequences;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import java.util.Objects;
/**
@@ -91,7 +91,7 @@ public strictfp class Assert extends org
*/
public static void assertSetEquals(final Set<?> expected, final Set<?> actual) {
if (expected != null && actual != null && !expected.isEmpty()) {
- final Set<Object> r = new LinkedHashSet<Object>(expected);
+ final Set<Object> r = new LinkedHashSet<>(expected);
assertTrue("The two sets are disjoint.", r.removeAll(actual));
assertTrue("The set is missing elements: " + r, r.isEmpty());
assertTrue("The set unexpectedly became empty.", r.addAll(actual));
@@ -110,7 +110,7 @@ public strictfp class Assert extends org
*/
public static void assertMapEquals(final Map<?,?> expected, final Map<?,?> actual) {
if (expected != null && actual != null && !expected.isEmpty()) {
- final Map<Object,Object> r = new LinkedHashMap<Object,Object>(expected);
+ final Map<Object,Object> r = new LinkedHashMap<>(expected);
for (final Map.Entry<?,?> entry : actual.entrySet()) {
final Object key = entry.getKey();
if (!r.containsKey(key)) {
@@ -233,16 +233,12 @@ public strictfp class Assert extends org
final XMLComparator comparator;
try {
comparator = new XMLComparator(expected, actual);
- } catch (IOException e) {
+ } catch (IOException | ParserConfigurationException | SAXException e) {
// We don't throw directly those exceptions since failing to parse the XML file can
// be considered as part of test failures and the JUnit exception for such failures
// is AssertionError. Having no checked exception in "assert" methods allow us to
// declare the checked exceptions only for the library code being tested.
throw new AssertionError(e);
- } catch (ParserConfigurationException e) {
- throw new AssertionError(e);
- } catch (SAXException e) {
- throw new AssertionError(e);
}
comparator.tolerance = tolerance;
comparator.ignoreComments = true;
@@ -357,23 +353,17 @@ public strictfp class Assert extends org
final Object deserialized;
try {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- final ObjectOutputStream out = new ObjectOutputStream(buffer);
- try {
+ try (ObjectOutputStream out = new ObjectOutputStream(buffer)) {
out.writeObject(object);
- } finally {
- out.close();
}
// Now reads the object we just serialized.
final byte[] data = buffer.toByteArray();
- final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
- try {
+ try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data))) {
try {
deserialized = in.readObject();
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
}
- } finally {
- in.close();
}
} catch (IOException e) {
throw new AssertionError(e);
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=1394916&r1=1394915&r2=1394916&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 Sat Oct 6 04:37:15 2012
@@ -131,7 +131,7 @@ public final class TestRunner extends Bl
final TestClass testClass = getTestClass();
final List<FrameworkMethod> depends = testClass.getAnnotatedMethods(DependsOnMethod.class);
if (!isNullOrEmpty(depends)) {
- final Set<String> dependencies = new HashSet<String>(hashMapCapacity(depends.size()));
+ final Set<String> dependencies = new HashSet<>(hashMapCapacity(depends.size()));
for (final FrameworkMethod method : depends) {
for (final String value : method.getAnnotation(DependsOnMethod.class).value()) {
dependencies.add(value);
@@ -206,7 +206,7 @@ public final class TestRunner extends Bl
final DependsOnMethod depend = method.getAnnotation(DependsOnMethod.class);
if (depend != null) {
if (dependencies == null) {
- dependencies = new HashSet<String>();
+ dependencies = new HashSet<>();
}
dependencies.addAll(Arrays.asList(depend.value()));
for (int j=methods.length; --j>i;) {
@@ -310,12 +310,12 @@ public final class TestRunner extends Bl
*/
final void addDependencyFailure(final String methodName) {
if (methodDependencyFailures == null) {
- methodDependencyFailures = new HashSet<String>();
+ methodDependencyFailures = new HashSet<>();
}
methodDependencyFailures.add(methodName);
synchronized (TestRunner.class) {
if (classDependencyFailures == null) {
- classDependencyFailures = new HashSet<Class<?>>();
+ classDependencyFailures = new HashSet<>();
}
classDependencyFailures.add(getTestClass().getJavaClass());
}
Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java Sat Oct 6 04:37:15 2012
@@ -135,8 +135,8 @@ public strictfp class XMLComparator {
ArgumentChecks.ensureNonNull("actual", actual);
expectedDoc = expected;
actualDoc = actual;
- ignoredAttributes = new HashSet<String>();
- ignoredNodes = new HashSet<String>();
+ ignoredAttributes = new HashSet<>();
+ ignoredNodes = new HashSet<>();
}
/**
@@ -173,13 +173,10 @@ public strictfp class XMLComparator {
throws IOException, ParserConfigurationException, SAXException
{
final Document document;
- final InputStream stream = toInputStream(input);
- try {
+ try (InputStream stream = toInputStream(input)) {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
final DocumentBuilder constructeur = factory.newDocumentBuilder();
document = constructeur.parse(stream);
- } finally {
- stream.close();
}
return document;
}
@@ -591,7 +588,7 @@ public strictfp class XMLComparator {
private static List<String> formatHierarchy(final StringBuilder buffer, Node node,
final List<String> expected, final String lineSeparator)
{
- final List<String> hierarchy = new ArrayList<String>();
+ final List<String> hierarchy = new ArrayList<>();
while (node != null) {
hierarchy.add(node.getNodeName());
node = node.getParentNode();
Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakHashSetTest.java Sat Oct 6 04:37:15 2012
@@ -54,8 +54,8 @@ public final strictfp class WeakHashSetT
public void testStrongReferences() {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakHashSet<Integer> weakSet = new WeakHashSet<Integer>(Integer.class);
- final HashSet<Integer> strongSet = new HashSet<Integer>();
+ final WeakHashSet<Integer> weakSet = new WeakHashSet<>(Integer.class);
+ final HashSet<Integer> strongSet = new HashSet<>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer value = random.nextInt(SAMPLE_SIZE);
if (random.nextBoolean()) {
@@ -97,8 +97,8 @@ public final strictfp class WeakHashSetT
public void testWeakReferences() throws InterruptedException {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakHashSet<Integer> weakSet = new WeakHashSet<Integer>(Integer.class);
- final HashSet<Integer> strongSet = new HashSet<Integer>();
+ final WeakHashSet<Integer> weakSet = new WeakHashSet<>(Integer.class);
+ final HashSet<Integer> strongSet = new HashSet<>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer value = new Integer(random.nextInt(SAMPLE_SIZE)); // Really need new instances
if (random.nextBoolean()) {
@@ -176,7 +176,7 @@ public final strictfp class WeakHashSetT
@Test
@DependsOnMethod("testStrongReferences")
public void testWithArrayElements() {
- final WeakHashSet<int[]> weakSet = new WeakHashSet<int[]>(int[].class);
+ final WeakHashSet<int[]> weakSet = new WeakHashSet<>(int[].class);
final int[] array = new int[] {2, 5, 3};
assertTrue (weakSet.add(array));
assertFalse(weakSet.add(array));
Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java?rev=1394916&r1=1394915&r2=1394916&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java (original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/util/collection/WeakValueHashMapTest.java Sat Oct 6 04:37:15 2012
@@ -54,8 +54,8 @@ public final strictfp class WeakValueHas
public void testStrongReferences() {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<Integer,Integer>(Integer.class);
- final HashMap<Integer,Integer> strongMap = new HashMap<Integer,Integer>();
+ final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<>(Integer.class);
+ final HashMap<Integer,Integer> strongMap = new HashMap<>();
for (int i=0; i<SAMPLE_SIZE; i++) {
final Integer key = random.nextInt(SAMPLE_SIZE);
final Integer value = random.nextInt(SAMPLE_SIZE);
@@ -86,8 +86,8 @@ public final strictfp class WeakValueHas
public void testWeakReferences() throws InterruptedException {
final Random random = new Random();
for (int pass=0; pass<NUM_RETRY; pass++) {
- final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<Integer,Integer>(Integer.class);
- final HashMap<Integer,Integer> strongMap = new HashMap<Integer,Integer>();
+ final WeakValueHashMap<Integer,Integer> weakMap = new WeakValueHashMap<>(Integer.class);
+ final HashMap<Integer,Integer> strongMap = new HashMap<>();
for (int i=0; i<SAMPLE_SIZE; i++) {
// We really want new instances here.
final Integer key = new Integer(random.nextInt(SAMPLE_SIZE));
@@ -159,7 +159,7 @@ public final strictfp class WeakValueHas
@Test
@DependsOnMethod("testStrongReferences")
public void testWithArrayKeys() {
- final WeakValueHashMap<int[],Integer> weakMap = new WeakValueHashMap<int[],Integer>(int[].class);
+ final WeakValueHashMap<int[],Integer> weakMap = new WeakValueHashMap<>(int[].class);
final int[] k1 = new int[] {2, 5, 3};
final int[] k2 = new int[] {2, 5, 4};
final Integer v1 = 1;