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 2016/09/28 09:59:48 UTC
svn commit: r1762629 [10/15] - in /sis/trunk: ./
application/sis-console/src/main/java/org/apache/sis/console/
application/sis-console/src/test/java/org/apache/sis/console/
application/sis-openoffice/src/main/java/org/apache/sis/openoffice/
application...
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -103,8 +103,8 @@ final class ObjectReference {
// Creates an empty instance with the identifiers.
int count = 0;
SpecializedIdentifier<?>[] identifiers = new SpecializedIdentifier<?>[2];
- if (uuid != null) identifiers[count++] = new SpecializedIdentifier<UUID> (IdentifierSpace.UUID, uuid);
- if (xlink != null) identifiers[count++] = new SpecializedIdentifier<XLink>(IdentifierSpace.XLINK, xlink);
+ if (uuid != null) identifiers[count++] = new SpecializedIdentifier<>(IdentifierSpace.UUID, uuid);
+ if (xlink != null) identifiers[count++] = new SpecializedIdentifier<>(IdentifierSpace.XLINK, xlink);
identifiers = ArraysExt.resize(identifiers, count);
metadata = resolver.newIdentifiedObject(context, type, identifiers);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LanguageCode.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -125,7 +125,7 @@ public final class LanguageCode extends
return marshalLocale;
}
}
- return Locale.getDefault();
+ return Locale.getDefault(Locale.Category.DISPLAY);
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -23,7 +23,7 @@ import org.apache.sis.internal.jaxb.Cont
import org.apache.sis.util.Debug;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -20,9 +20,6 @@ import java.util.Locale;
import javax.xml.bind.annotation.XmlElement;
import org.apache.sis.util.Debug;
-// Related to JDK7
-import org.apache.sis.internal.jdk7.JDK7;
-
/**
* A set of strings localized in different languages. This adapter represents the
@@ -127,7 +124,7 @@ final class TextGroup {
@Debug
@Override
public String toString() {
- final String lineSeparator = JDK7.lineSeparator();
+ final String lineSeparator = System.lineSeparator();
final StringBuilder buffer = new StringBuilder(160).append(getClass().getSimpleName()).append(lineSeparator);
if (localized != null) {
int corner = 0;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmx/Anchor.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -24,7 +24,7 @@ import org.opengis.util.InternationalStr
import org.apache.sis.xml.XLink;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jdk8/JDK8.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -29,14 +29,13 @@ import java.util.concurrent.atomic.Atomi
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import javax.xml.bind.DatatypeConverter;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.JDK7;
-import org.apache.sis.internal.jdk7.Objects;
-import org.apache.sis.internal.jdk7.Files;
-import org.apache.sis.internal.jdk7.Path;
-import org.apache.sis.internal.jdk7.StandardCharsets;
+import java.util.Objects;
+import java.nio.file.Files;
+import java.nio.file.Path;
/**
@@ -54,7 +53,7 @@ public final class JDK8 {
* We share a single instance instead than using {@link ThreadLocal} instances
* on the assumption that usages of this calendar will be relatively rare.
*/
- private static final AtomicReference<Calendar> CALENDAR = new AtomicReference<Calendar>();
+ private static final AtomicReference<Calendar> CALENDAR = new AtomicReference<>();
/**
* Do not allow instantiation of this class.
@@ -72,7 +71,7 @@ public final class JDK8 {
* @since 0.7
*/
public static int compareUnsigned(final int x, final int y) {
- return JDK7.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE);
+ return Integer.compare(x + Integer.MIN_VALUE, y + Integer.MIN_VALUE);
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleCitation.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -31,7 +31,7 @@ import org.apache.sis.util.iso.SimpleInt
import org.apache.sis.util.Debug;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifiedObject.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -35,7 +35,7 @@ import org.apache.sis.util.ComparisonMod
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleIdentifier.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -30,7 +30,7 @@ import org.apache.sis.util.Deprecable;
import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DaemonThread.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -165,7 +165,7 @@ abstract class DaemonThread extends Thre
while (thread != null) {
if (!thread.isAlive() || thread.isStalled()) {
if (list == null) {
- list = new ArrayList<Thread>();
+ list = new ArrayList<>();
}
list.add(thread);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -25,10 +25,10 @@ import org.apache.sis.util.logging.Loggi
import org.apache.sis.util.resources.Messages;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Files;
-import org.apache.sis.internal.jdk7.Path;
-import org.apache.sis.internal.jdk7.Paths;
-import org.apache.sis.internal.jdk7.InvalidPathException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.InvalidPathException;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -42,7 +42,7 @@ public final class DefaultFactories exte
/**
* Cache of factories which are found by {@code META-INF/services}.
*/
- private static final Map<Class<?>, Object> FACTORIES = new IdentityHashMap<Class<?>, Object>(4);
+ private static final Map<Class<?>, Object> FACTORIES = new IdentityHashMap<>(4);
static {
SystemListener.add(new DefaultFactories());
}
@@ -205,7 +205,7 @@ public final class DefaultFactories exte
private static ClassLoader getContextClassLoader() throws SecurityException {
final Thread thread = Thread.currentThread();
ClassLoader loader = thread.getContextClassLoader();
- final Set<ClassLoader> parents = new HashSet<ClassLoader>();
+ final Set<ClassLoader> parents = new HashSet<>();
for (ClassLoader c = loader; c != null; c = c.getParent()) {
parents.add(c);
}
@@ -222,7 +222,7 @@ public final class DefaultFactories exte
c = c.getParent();
}
}
- } catch (Exception e) { // This is (SecurityException | ClassNotFoundException) on the JDK7 branch.
+ } catch (SecurityException | ClassNotFoundException e) {
if (!warnings) {
warnings = true;
Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM),
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -73,7 +73,7 @@ public final class DelayedExecutor exten
/**
* List of delayed tasks to execute.
*/
- private static final BlockingQueue<DelayedRunnable> QUEUE = new DelayQueue<DelayedRunnable>();
+ private static final BlockingQueue<DelayedRunnable> QUEUE = new DelayQueue<>();
/**
* Creates the singleton instance of the {@code DelayedExecutor} thread.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -121,7 +121,7 @@ public final class Loggers extends Stati
* @return The effective logging levels of SIS loggers.
*/
public static SortedMap<String,Level> getEffectiveLevels() {
- final SortedMap<String,Level> levels = new TreeMap<String,Level>();
+ final SortedMap<String,Level> levels = new TreeMap<>();
for (final Field field : Loggers.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers()) && field.getType() == String.class) try {
levels.put((String) field.get(null), null);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/OptionalDependency.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -93,7 +93,7 @@ public abstract class OptionalDependency
record.setLoggerName(module);
Logging.log(type, "getInstance", record);
return null;
- } catch (Exception exception) { // (ReflectiveOperationException) on JDK7 branch.
+ } catch (ReflectiveOperationException exception) {
// Should never happen if we didn't broke our helper class.
throw new AssertionError(exception);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -56,7 +56,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 static final ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
+ public static final ReferenceQueue<Object> QUEUE = new ReferenceQueue<>();
/**
* Creates the singleton instance of the {@code ReferenceQueueConsumer} thread.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -68,7 +68,7 @@ public final class Semaphores {
/**
* The flags per running thread.
*/
- private static final ThreadLocal<Semaphores> FLAGS = new ThreadLocal<Semaphores>();
+ private static final ThreadLocal<Semaphores> FLAGS = new ThreadLocal<>();
/**
* The bit flags.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -22,7 +22,7 @@ import java.util.concurrent.Callable;
import org.apache.sis.util.logging.Logging;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
@@ -49,7 +49,7 @@ public final class Shutdown extends Thre
/**
* The resources to dispose. Most recently added resources are last.
*/
- private static final List<Callable<?>> resources = new ArrayList<Callable<?>>();
+ private static final List<Callable<?>> resources = new ArrayList<>();
/**
* Creates the thread to be executed at shutdown time.
@@ -184,6 +184,9 @@ public final class Shutdown extends Thre
while ((i = resources.size()) != 0) try { // In case run() modifies the resources list.
resources.remove(i - 1).call(); // Dispose most recently added resources first.
} catch (Exception e) {
+ if (exception != null) {
+ e.addSuppressed(exception);
+ }
exception = e;
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -193,7 +193,7 @@ public final class Supervisor extends St
*/
private String getDescription(final String resourceKey) {
return ResourceBundle.getBundle("org.apache.sis.internal.system.Descriptions",
- Locale.getDefault(),
+ Locale.getDefault(Locale.Category.DISPLAY),
Supervisor.class.getClassLoader()).getString(resourceKey);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMap.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -27,7 +27,7 @@ import org.apache.sis.io.TableAppender;
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
@@ -119,7 +119,7 @@ public abstract class AbstractMap<K,V> i
* @return the entry at the current iterator position.
*/
protected Entry<K,V> getEntry() {
- return new java.util.AbstractMap.SimpleImmutableEntry<K,V>(getKey(), getValue());
+ return new java.util.AbstractMap.SimpleImmutableEntry<>(getKey(), getValue());
}
/**
@@ -371,7 +371,7 @@ public abstract class AbstractMap<K,V> i
@Override public boolean add(K e) {return AbstractMap.this.addKey(e);}
@Override public Iterator<K> iterator() {
final EntryIterator<K,V> it = entryIterator();
- return (it != null) ? new Keys<K,V>(it) : Collections.<K>emptySet().iterator();
+ return (it != null) ? new Keys<>(it) : Collections.<K>emptyIterator();
}
/** Overridden for the same reason than {@link AbstractMap#equals(Object). */
@@ -418,7 +418,7 @@ public abstract class AbstractMap<K,V> i
@Override public boolean add(V e) {return AbstractMap.this.addValue(e);}
@Override public Iterator<V> iterator() {
final EntryIterator<K,V> it = entryIterator();
- return (it != null) ? new Values<K,V>(it) : Collections.<V>emptySet().iterator();
+ return (it != null) ? new Values<>(it) : Collections.<V>emptyIterator();
}
};
}
@@ -453,7 +453,7 @@ public abstract class AbstractMap<K,V> i
/** Returns an iterator compliant to the Map contract. */
@Override public Iterator<Entry<K,V>> iterator() {
final EntryIterator<K,V> it = entryIterator();
- return (it != null) ? new Entries<K,V>(it) : Collections.<Entry<K,V>>emptySet().iterator();
+ return (it != null) ? new Entries<>(it) : Collections.<Entry<K,V>>emptyIterator();
}
/** Overridden for the same reason than {@link AbstractMap#equals(Object). */
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/AbstractMapEntry.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -22,7 +22,7 @@ import org.apache.sis.util.CharSequences
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -108,7 +108,7 @@ public final class CheckedArrayList<E> e
if (collection instanceof CheckedArrayList<?> && ((CheckedArrayList<?>) collection).type == type) {
return (CheckedArrayList<E>) collection;
} else {
- final CheckedArrayList<E> list = new CheckedArrayList<E>(type, collection.size());
+ final CheckedArrayList<E> list = new CheckedArrayList<>(type, collection.size());
list.addAll((Collection) collection); // addAll will perform the type checks.
return list;
}
@@ -215,7 +215,7 @@ public final class CheckedArrayList<E> e
}
// Not-so-unsafe cast: we verified in the above loop that all elements are instance of E.
// The array itself may not be an instance of E[], but this is not important for Mediator.
- return new Mediator<E>(ArraysExt.resize((E[]) array, count));
+ return new Mediator<>(ArraysExt.resize((E[]) array, count));
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -31,7 +31,7 @@ import org.apache.sis.util.Static;
import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
import org.opengis.referencing.ReferenceIdentifier;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Cloner.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -118,7 +118,9 @@ public class Cloner {
method = null;
type = valueType;
} catch (IllegalAccessException e) {
- // JDK7 branch has the following: e.addSuppressed(security);
+ if (security != null) {
+ e.addSuppressed(security);
+ }
throw fail(e, valueType);
} catch (InvocationTargetException e) {
rethrow(e.getCause());
@@ -180,14 +182,12 @@ public class Cloner {
if (Modifier.isPublic(m.getModifiers())) {
return m.invoke(object, (Object[]) null);
}
- } catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException | IllegalAccessException e) {
/*
* Should never happen because all objects have a clone() method
* and we verified that the method is public.
*/
throw new AssertionError(e);
- } catch (IllegalAccessException e) {
- throw new AssertionError(e);
} catch (InvocationTargetException e) {
rethrow(e.getCause());
throw fail(e, type);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -28,7 +28,6 @@ import org.opengis.parameter.InvalidPara
import static org.apache.sis.util.collection.Containers.hashMapCapacity;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
import org.apache.sis.internal.jdk8.Function;
@@ -136,6 +135,7 @@ public final class CollectionsExt extend
*
* @since 0.6
*/
+ @SafeVarargs
public static <T> Set<T> nonEmptySet(final T... elements) {
final Set<T> asSet = immutableSet(true, elements);
return (asSet != null && asSet.isEmpty()) ? null : asSet;
@@ -234,7 +234,7 @@ public final class CollectionsExt extend
final Class<?> valueType = value.getClass();
if (valueType.isArray()) {
if (type.isAssignableFrom(valueType)) {
- final Set<E> set = new LinkedHashSet<E>(Arrays.asList((E[]) value));
+ final Set<E> set = new LinkedHashSet<>(Arrays.asList((E[]) value));
set.remove(null);
return set.toArray(emptyArray);
}
@@ -266,7 +266,7 @@ public final class CollectionsExt extend
if (Enum.class.isAssignableFrom(type)) {
return EnumSet.noneOf((Class) type);
}
- return new LinkedHashSet<E>(hashMapCapacity(count));
+ return new LinkedHashSet<>(hashMapCapacity(count));
}
/**
@@ -282,6 +282,7 @@ public final class CollectionsExt extend
*
* @see Collections#unmodifiableSet(Set)
*/
+ @SafeVarargs
@SuppressWarnings("fallthrough")
public static <E> Set<E> immutableSet(final boolean excludeNull, final E... array) {
if (array == null) {
@@ -299,7 +300,7 @@ public final class CollectionsExt extend
return Collections.emptySet();
}
default: {
- final Set<E> set = new LinkedHashSet<E>(Arrays.asList(array));
+ final Set<E> set = new LinkedHashSet<>(Arrays.asList(array));
if (excludeNull) {
set.remove(null);
}
@@ -418,7 +419,7 @@ public final class CollectionsExt extend
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();
@@ -429,18 +430,18 @@ public final class CollectionsExt extend
if (collection instanceof CodeListSet<?>) {
return ((CodeListSet) 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);
}
/**
@@ -475,12 +476,12 @@ public final class CollectionsExt extend
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);
}
/**
@@ -561,7 +562,7 @@ public final class CollectionsExt extend
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);
}
@@ -569,7 +570,7 @@ public final class CollectionsExt extend
}
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());
}
@@ -605,7 +606,7 @@ public final class CollectionsExt extend
if (collection instanceof List<?>) {
return (List<T>) collection;
}
- return new ArrayList<T>(collection);
+ return new ArrayList<>(collection);
}
/**
@@ -647,7 +648,7 @@ public final class CollectionsExt extend
return singleton;
}
if (values.size() <= 1) {
- values = new ArrayList<V>(values);
+ values = new ArrayList<>(values);
if (map.put(key, values) != singleton) {
throw new ConcurrentModificationException();
}
@@ -677,7 +678,7 @@ public final class CollectionsExt extend
if (elements == null) {
return Collections.emptyMap();
}
- final Map<String,E> map = new HashMap<String,E>(hashMapCapacity(elements.size()));
+ final Map<String,E> map = new HashMap<>(hashMapCapacity(elements.size()));
Set<String> excludes = null;
for (final E e : elements) {
final String name = nameFunction.apply(e);
@@ -715,7 +716,7 @@ public final class CollectionsExt extend
*/
map.remove(lower);
if (excludes == null) {
- excludes = new HashSet<String>();
+ excludes = new HashSet<>();
}
excludes.add(lower);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/LazySet.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -25,7 +25,7 @@ import org.apache.sis.util.Workaround;
import org.apache.sis.internal.system.DefaultFactories;
// Branch-specific imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Numerics.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -42,7 +42,7 @@ public final class Numerics extends Stat
* Some frequently used {@link Double} values. As of Java 7, those values do not
* seem to be cached by {@link Double#valueOf(double)} like JDK does for integers.
*/
- private static final Map<Object,Object> CACHE = new HashMap<Object,Object>(32);
+ private static final Map<Object,Object> CACHE = new HashMap<>(32);
static {
cache( 0);
cache( 1);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/PatchedUnitFormat.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -63,7 +63,7 @@ public final class PatchedUnitFormat ext
* @param entries The (unit, symbol) pairs.
*/
public static void init(final Object... entries) {
- final Map<Unit<?>,String> symbols = new HashMap<Unit<?>,String>(8);
+ final Map<Unit<?>,String> symbols = new HashMap<>(8);
for (int i=0; i<entries.length; i++) {
final String uom;
if (symbols.put((Unit<?>) entries[i], uom = (String) entries[++i]) != null) {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/StandardDateFormat.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -16,7 +16,6 @@
*/
package org.apache.sis.internal.util;
-import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
@@ -61,10 +60,6 @@ public final class StandardDateFormat ex
/**
* The {@value} timezone ID.
- *
- * The JDK7 branch has a 'X' pattern at the end of this format. But JDK6 does not support that pattern.
- * As a workaround, code using this pattern will append a hard-coded {@code "'Z'"} if the timezone is
- * known to be UTC.
*/
public static final String UTC = "UTC";
@@ -84,7 +79,7 @@ public final class StandardDateFormat ex
* specification. Note that this is different than {@link java.time.LocalDateTime} which parse those numbers as
* fraction digits.
*/
- public static final String TIME_PATTERN = "HH:mm:ss.SSS";
+ public static final String TIME_PATTERN = "HH:mm:ss.SSSX";
/**
* Number of fraction digits in {@link #TIME_PATTERN}.
@@ -129,7 +124,7 @@ public final class StandardDateFormat ex
* @param zone the timezone.
*/
public StandardDateFormat(final Locale locale, final TimeZone zone) {
- super(UTC.equals(zone.getID()) ? PATTERN + "'Z'" : PATTERN, locale);
+ super(PATTERN, locale);
super.setTimeZone(zone);
}
@@ -201,36 +196,6 @@ public final class StandardDateFormat ex
final Date date = super.parse(fix.text, position);
position.setIndex (fix.adjustIndex(position.getIndex()));
position.setErrorIndex(fix.adjustIndex(position.getErrorIndex()));
- if (date != null) {
- /*
- * Following is a workaround specific to the JDK6 branch. Since JDK6 does not understand the 'Z' suffix,
- * we handle it in this method. The Apache SIS branch for JDK7 does not need this hack since JDK7 supports
- * parsing the 'Z' suffix.
- */
- final int p = position.getIndex();
- if (p < text.length() && text.charAt(p) == 'Z') {
- position.setIndex(p + 1);
- final Calendar cal = calendar;
- final int year = cal.get(Calendar.YEAR);
- final int month = cal.get(Calendar.MONTH);
- final int day = cal.get(Calendar.DAY_OF_MONTH);
- final int hour = cal.get(Calendar.HOUR_OF_DAY);
- final int minute = cal.get(Calendar.MINUTE);
- final int second = cal.get(Calendar.SECOND);
- final int millis = cal.get(Calendar.MILLISECOND);
- final TimeZone timezone = cal.getTimeZone();
- final long time;
- try {
- cal.setTimeZone(TimeZone.getTimeZone(UTC));
- cal.set(year, month, day, hour, minute, second);
- cal.set(Calendar.MILLISECOND, millis);
- time = cal.getTimeInMillis();
- } finally {
- cal.setTimeZone(timezone);
- }
- date.setTime(time);
- }
- }
return date;
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/UnmodifiableArrayList.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -24,7 +24,7 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.util.collection.CheckedContainer;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
@@ -116,7 +116,7 @@ public class UnmodifiableArrayList<E> ex
* array was null.
*/
public static <E> UnmodifiableArrayList<E> wrap(final E[] array) { // NOT "E..." - see javadoc.
- return (array != null) ? new UnmodifiableArrayList<E>(array) : null;
+ return (array != null) ? new UnmodifiableArrayList<>(array) : null;
}
/**
@@ -142,9 +142,9 @@ public class UnmodifiableArrayList<E> ex
*/
public static <E> UnmodifiableArrayList<E> wrap(final E[] array, final int lower, final int upper) {
if (lower == 0 && upper == array.length) {
- return new UnmodifiableArrayList<E>(array);
+ return new UnmodifiableArrayList<>(array);
}
- return new UnmodifiableArrayList.SubList<E>(array, lower, upper - lower);
+ return new UnmodifiableArrayList.SubList<>(array, lower, upper - lower);
}
/**
@@ -301,7 +301,7 @@ public class UnmodifiableArrayList<E> ex
throws IndexOutOfBoundsException
{
ArgumentChecks.ensureValidIndexRange(size(), lower, upper);
- return new SubList<E>(array, lower + lower(), upper - lower);
+ return new SubList<>(array, lower + lower(), upper - lower);
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/Appender.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -22,9 +22,6 @@ import org.apache.sis.util.ArgumentCheck
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
-// Related to JDK7
-import org.apache.sis.internal.jdk7.JDK7;
-
/**
* Base class for writing filtered characters to another {@link Appendable}.
@@ -160,11 +157,11 @@ abstract class Appender implements Appen
* @throws IOException If an error occurred while appending the code point.
*/
final void appendCodePoint(final int c) throws IOException {
- if (JDK7.isBmpCodePoint(c)) {
+ if (Character.isBmpCodePoint(c)) {
out.append((char) c);
} else if (Character.isSupplementaryCodePoint(c)) {
- out.append(JDK7.highSurrogate(c))
- .append(JDK7. lowSurrogate(c));
+ out.append(Character.highSurrogate(c))
+ .append(Character. lowSurrogate(c));
} else {
throw new CharConversionException();
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -138,6 +138,34 @@ public abstract class CompoundFormat<T>
}
/**
+ * Returns the locale for the given category. Subclasses may override this method in order to assign
+ * different roles to the different locale categories. A typical (but not mandatory) mapping is:
+ *
+ * <ul>
+ * <li>{@link java.util.Locale.Category#FORMAT} specifies the locale to use for numbers, dates and angles formatting.</li>
+ * <li>{@link java.util.Locale.Category#DISPLAY} specifies the locale to use for {@link org.opengis.util.CodeList} labels
+ * and {@link org.opengis.util.InternationalString} contents.</li>
+ * </ul>
+ *
+ * <div class="note"><b>Example:</b>
+ * The ISO 19162 (<cite>Well Known Text</cite>) standard requires a number format similar to the one defined by
+ * {@code Locale.ROOT} while it allows informative texts (remarks, <i>etc.</i>) to be formatted according the
+ * user's locale. Consequently {@code WKTFormat} fixes (usually) the locale for {@code Category.FORMAT} to
+ * {@code Locale.ROOT} and let {@code Category.DISPLAY} be any locale.</div>
+ *
+ * For subclasses that do not override this method, the default implementation returns {@link #getLocale()}.
+ *
+ * @param category The category for which a locale is desired.
+ * @return The locale for the given category (never {@code null}).
+ *
+ * @since 0.4
+ */
+ public Locale getLocale(final Locale.Category category) {
+ ArgumentChecks.ensureNonNull("category", category);
+ return getLocale();
+ }
+
+ /**
* Returns the timezone used by this format.
*
* @return The timezone used for this format, or UTC for unlocalized format.
@@ -272,7 +300,7 @@ public abstract class CompoundFormat<T>
} while (Character.isSpaceChar(c) || Character.isISOControl(c));
pos.setErrorIndex(i);
}
- throw new LocalizedParseException(getLocale(), getValueType(), text, pos);
+ throw new LocalizedParseException(getLocale(Locale.Category.DISPLAY), getValueType(), text, pos);
}
/**
@@ -352,7 +380,7 @@ public abstract class CompoundFormat<T>
format = createFormat(type);
if (format != null) {
if (formats == null) {
- this.formats = formats = new IdentityHashMap<Class<?>,Format>(4);
+ this.formats = formats = new IdentityHashMap<>(4);
}
formats.put(type, format);
break;
@@ -398,7 +426,7 @@ public abstract class CompoundFormat<T>
* documented in this method javadoc. But actually it is not, since the call to
* DefaultFormat.getInstance(\u2026) will indirectly perform this kind of comparison.
*/
- final Locale locale = getLocale();
+ final Locale locale = getLocale(Locale.Category.FORMAT);
if (Number.class.isAssignableFrom(valueType)) {
if (Locale.ROOT.equals(locale)) {
return DefaultFormat.getInstance(valueType);
@@ -441,7 +469,7 @@ public abstract class CompoundFormat<T>
@SuppressWarnings("unchecked")
final CompoundFormat<T> clone = (CompoundFormat<T>) super.clone();
if (clone.formats != null) {
- clone.formats = new IdentityHashMap<Class<?>,Format>(clone.formats);
+ clone.formats = new IdentityHashMap<>(clone.formats);
for (final Map.Entry<Class<?>,Format> entry : clone.formats.entrySet()) {
entry.setValue((Format) entry.getValue().clone());
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -23,9 +23,6 @@ import org.apache.sis.util.CharSequences
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.internal.util.X364;
-// Related to JK7
-import org.apache.sis.internal.jdk7.JDK7;
-
/**
* An {@link Appendable} which can apply different kinds of reformatting that depend on the
@@ -299,7 +296,7 @@ public class LineAppender extends Append
*/
private void writeLineSeparator() throws IOException {
if (lineSeparator == null) {
- lineSeparator = JDK7.lineSeparator();
+ lineSeparator = System.lineSeparator();
}
out.append(lineSeparator);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -29,9 +29,6 @@ import org.apache.sis.internal.util.X364
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
-// Related to JK7
-import org.apache.sis.internal.jdk7.JDK7;
-
/**
* An {@link Appendable} which formats the text as a table suitable for displaying in devices using
@@ -144,7 +141,7 @@ public class TableAppender extends Appen
* <code>{@linkplain Cell#text} == null</code> means that we need to move
* to the next line.
*/
- private final List<Cell> cells = new ArrayList<Cell>();
+ private final List<Cell> cells = new ArrayList<>();
/**
* Alignment for current and next cells.
@@ -800,7 +797,7 @@ public class TableAppender extends Appen
out.append(isLastColumn ? rightBorder : columnSeparator);
}
if (lineSeparator == null) {
- lineSeparator = JDK7.lineSeparator();
+ lineSeparator = System.lineSeparator();
}
out.append(lineSeparator);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -25,9 +25,6 @@ import org.apache.sis.util.StringBuilder
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
-// Related to JK7
-import org.apache.sis.internal.jdk7.JDK7;
-
/**
* Base class for parser and formatter of tabular data, providing control on line and column separators.
@@ -140,7 +137,7 @@ public abstract class TabularFormat<T> e
beforeFill = "";
fillCharacter = ' ';
columnSeparator = " ";
- lineSeparator = JDK7.lineSeparator();
+ lineSeparator = System.lineSeparator();
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -27,7 +27,7 @@ import static java.lang.Double.isNaN;
import static java.lang.Double.doubleToLongBits;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
import org.apache.sis.internal.jdk8.LongConsumer;
import org.apache.sis.internal.jdk8.DoubleConsumer;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/StatisticsFormat.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -93,7 +93,9 @@ public class StatisticsFormat extends Ta
* @return A statistics format instance for the current default locale.
*/
public static StatisticsFormat getInstance() {
- return getInstance(Locale.getDefault());
+ return new StatisticsFormat(
+ Locale.getDefault(Locale.Category.FORMAT),
+ Locale.getDefault(Locale.Category.DISPLAY), null);
}
/**
@@ -121,6 +123,28 @@ public class StatisticsFormat extends Ta
}
/**
+ * Returns the locale for the given category. This method implements the following mapping:
+ *
+ * <ul>
+ * <li>{@link java.util.Locale.Category#DISPLAY} \u2014 the {@code headerLocale} given at construction time.</li>
+ * <li>{@link java.util.Locale.Category#FORMAT} \u2014 the {@code locale} given at construction time,
+ * used for all values below the header row.</li>
+ * </ul>
+ *
+ * @param category The category for which a locale is desired.
+ * @return The locale for the given category (never {@code null}).
+ *
+ * @since 0.4
+ */
+ @Override
+ public Locale getLocale(final Locale.Category category) {
+ if (category == Locale.Category.DISPLAY) {
+ return headerLocale;
+ }
+ return super.getLocale(category);
+ }
+
+ /**
* Returns the type of objects formatted by this class.
*
* @return {@code Statistics.class}
@@ -233,7 +257,7 @@ public class StatisticsFormat extends Ta
*/
@Override
public void format(Statistics stats, final Appendable toAppendTo) throws IOException {
- final List<Statistics> list = new ArrayList<Statistics>(3);
+ final List<Statistics> list = new ArrayList<>(3);
while (stats != null) {
list.add(stats);
stats = stats.differences();
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -42,7 +42,7 @@ import static org.apache.sis.math.MathFu
import static org.apache.sis.math.DecimalFunctions.fractionDigitsForDelta;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
import org.apache.sis.internal.jdk8.JDK8;
@@ -398,7 +398,7 @@ public class AngleFormat extends Format
* Constructs a new {@code AngleFormat} for the default pattern and the current default locale.
*/
public AngleFormat() {
- this(Locale.getDefault());
+ this(Locale.getDefault(Locale.Category.FORMAT));
}
/**
@@ -429,7 +429,7 @@ public class AngleFormat extends Format
* @throws IllegalArgumentException If the specified pattern is illegal.
*/
public AngleFormat(final String pattern) throws IllegalArgumentException {
- this(pattern, Locale.getDefault());
+ this(pattern, Locale.getDefault(Locale.Category.FORMAT));
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -155,7 +155,7 @@ final class FormattedCharacterIterator e
*/
FormattedCharacterIterator(final CharSequence text) {
super(text);
- attributes = new IdentityHashMap<Attribute,Entry>(8);
+ attributes = new IdentityHashMap<>(8);
}
/**
@@ -314,7 +314,7 @@ final class FormattedCharacterIterator e
* {@code getRunStart(Set)} and {@code getRunLimit(Set)} methods.
*/
private Collection<Entry> entries(final Set<? extends Attribute> requested) {
- final Collection<Entry> entries = new ArrayList<Entry>(requested.size());
+ final Collection<Entry> entries = new ArrayList<>(requested.size());
for (final Attribute r : requested) {
final Entry e = attributes.get(r);
if (e != null) {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -23,7 +23,7 @@ import org.apache.sis.util.Numbers;
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
@@ -84,7 +84,7 @@ public class MeasurementRange<E extends
public static MeasurementRange<Float> create(float minValue, boolean isMinIncluded,
float maxValue, boolean isMaxIncluded, Unit<?> unit)
{
- return unique(new MeasurementRange<Float>(Float.class,
+ return unique(new MeasurementRange<>(Float.class,
valueOf("minValue", minValue, Float.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), isMaxIncluded, unit));
}
@@ -103,7 +103,7 @@ public class MeasurementRange<E extends
public static MeasurementRange<Double> create(double minValue, boolean isMinIncluded,
double maxValue, boolean isMaxIncluded, Unit<?> unit)
{
- return unique(new MeasurementRange<Double>(Double.class,
+ return unique(new MeasurementRange<>(Double.class,
valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), isMaxIncluded, unit));
}
@@ -120,7 +120,7 @@ public class MeasurementRange<E extends
* @since 0.6
*/
public static MeasurementRange<Double> createGreaterThan(final double minValue, final Unit<?> unit) {
- return unique(new MeasurementRange<Double>(Double.class,
+ return unique(new MeasurementRange<>(Double.class,
valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), false, null, false, unit));
}
@@ -225,7 +225,7 @@ public class MeasurementRange<E extends
Range<E> create(final E minValue, final boolean isMinIncluded,
final E maxValue, final boolean isMaxIncluded)
{
- return new MeasurementRange<E>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded, unit);
+ return new MeasurementRange<>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded, unit);
}
/**
@@ -263,7 +263,7 @@ public class MeasurementRange<E extends
if (elementType == type) {
return (MeasurementRange<N>) this;
} else {
- return new MeasurementRange<N>(type, this, unit);
+ return new MeasurementRange<>(type, this, unit);
}
}
@@ -306,7 +306,7 @@ public class MeasurementRange<E extends
throw new IllegalArgumentException(Errors.format(Errors.Keys.IncompatibleUnits_2,
((MeasurementRange<?>) range).unit, unit), e);
}
- return new MeasurementRange<N>(type, range, unit);
+ return new MeasurementRange<>(type, range, unit);
}
/**
@@ -345,12 +345,12 @@ public class MeasurementRange<E extends
minInc &= (minimum == (minimum = Math.floor(minimum)));
maxInc &= (maximum == (maximum = Math.ceil (maximum)));
}
- return new MeasurementRange<N>(type,
+ return new MeasurementRange<>(type,
Numbers.cast(minimum, type), minInc,
Numbers.cast(maximum, type), maxInc, targetUnit);
}
}
- return new MeasurementRange<N>(type, this, targetUnit);
+ return new MeasurementRange<>(type, this, targetUnit);
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/NumberRange.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -98,7 +98,7 @@ public class NumberRange<E extends Numbe
* The pool of ranges created by the {@code create(\u2026)} methods.
*/
@SuppressWarnings("unchecked")
- private static final WeakHashSet<NumberRange<?>> POOL = new WeakHashSet<NumberRange<?>>((Class) NumberRange.class);
+ private static final WeakHashSet<NumberRange<?>> POOL = new WeakHashSet<>((Class) NumberRange.class);
/**
* Returns a unique instance of the given range, except if the range is empty.
@@ -129,7 +129,7 @@ public class NumberRange<E extends Numbe
public static NumberRange<Byte> create(final byte minValue, final boolean isMinIncluded,
final byte maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<Byte>(Byte.class,
+ return unique(new NumberRange<>(Byte.class,
Byte.valueOf(minValue), isMinIncluded,
Byte.valueOf(maxValue), isMaxIncluded));
}
@@ -147,7 +147,7 @@ public class NumberRange<E extends Numbe
public static NumberRange<Short> create(final short minValue, final boolean isMinIncluded,
final short maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<Short>(Short.class,
+ return unique(new NumberRange<>(Short.class,
Short.valueOf(minValue), isMinIncluded,
Short.valueOf(maxValue), isMaxIncluded));
}
@@ -167,7 +167,7 @@ public class NumberRange<E extends Numbe
public static NumberRange<Integer> create(final int minValue, final boolean isMinIncluded,
final int maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<Integer>(Integer.class,
+ return unique(new NumberRange<>(Integer.class,
Integer.valueOf(minValue), isMinIncluded,
Integer.valueOf(maxValue), isMaxIncluded));
}
@@ -185,7 +185,7 @@ public class NumberRange<E extends Numbe
public static NumberRange<Long> create(final long minValue, final boolean isMinIncluded,
final long maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<Long>(Long.class,
+ return unique(new NumberRange<>(Long.class,
Long.valueOf(minValue), isMinIncluded,
Long.valueOf(maxValue), isMaxIncluded));
}
@@ -204,7 +204,7 @@ public class NumberRange<E extends Numbe
public static NumberRange<Float> create(final float minValue, final boolean isMinIncluded,
final float maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<Float>(Float.class,
+ return unique(new NumberRange<>(Float.class,
valueOf("minValue", minValue, Float.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Float.POSITIVE_INFINITY), isMaxIncluded));
}
@@ -234,7 +234,7 @@ public class NumberRange<E extends Numbe
public static NumberRange<Double> create(final double minValue, final boolean isMinIncluded,
final double maxValue, final boolean isMaxIncluded)
{
- return unique(new NumberRange<Double>(Double.class,
+ return unique(new NumberRange<>(Double.class,
valueOf("minValue", minValue, Double.NEGATIVE_INFINITY), isMinIncluded,
valueOf("maxValue", maxValue, Double.POSITIVE_INFINITY), isMaxIncluded));
}
@@ -268,7 +268,7 @@ public class NumberRange<E extends Numbe
* @since 0.5
*/
public static NumberRange<Integer> createLeftBounded(final int minValue, final boolean isMinIncluded) {
- return unique(new NumberRange<Integer>(Integer.class, Integer.valueOf(minValue), isMinIncluded, null, false));
+ return unique(new NumberRange<>(Integer.class, Integer.valueOf(minValue), isMinIncluded, null, false));
}
/**
@@ -324,7 +324,7 @@ public class NumberRange<E extends Numbe
}
// The constructor will ensure that the range element type is a subclass of Number.
// Do not invoke unique(NumberRange) because the returned range is often temporary.
- return new NumberRange<N>(range);
+ return new NumberRange<>(range);
}
/**
@@ -397,7 +397,7 @@ public class NumberRange<E extends Numbe
Range<E> create(final E minValue, final boolean isMinIncluded,
final E maxValue, final boolean isMaxIncluded)
{
- return new NumberRange<E>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
+ return new NumberRange<>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
}
/**
@@ -420,7 +420,7 @@ public class NumberRange<E extends Numbe
if (range.elementType == type) {
return (NumberRange<N>) range;
}
- return new NumberRange<N>(type, range);
+ return new NumberRange<>(type, range);
}
/**
@@ -442,7 +442,7 @@ public class NumberRange<E extends Numbe
if (elementType == type) {
return (NumberRange<N>) this;
}
- return new NumberRange<N>(type, this);
+ return new NumberRange<>(type, this);
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -29,7 +29,7 @@ import org.apache.sis.util.Emptiable;
import org.apache.sis.util.Numbers;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
@@ -174,7 +174,7 @@ public class Range<E extends Comparable<
Range<E> create(final E minValue, final boolean isMinIncluded,
final E maxValue, final boolean isMaxIncluded)
{
- return new Range<E>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
+ return new Range<>(elementType, minValue, isMinIncluded, maxValue, isMaxIncluded);
}
/**
@@ -616,7 +616,6 @@ public class Range<E extends Comparable<
* only one digit. This method assumes that we have verified that the element type
* is an integer type before to invoke this method.
*/
- @SuppressWarnings("unchecked")
private static boolean isCompact(final Comparable<?> value, final boolean ifNull) {
if (value == null) {
return ifNull;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/RangeFormat.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -302,7 +302,7 @@ public class RangeFormat extends Format
* using the {@linkplain Locale#getDefault() default locale}.
*/
public RangeFormat() {
- this(Locale.getDefault());
+ this(Locale.getDefault(Locale.Category.FORMAT));
}
/**
@@ -475,7 +475,7 @@ public class RangeFormat extends Format
*/
private boolean insertSpaceBeforeUnit(final Unit<?> unit) {
if (insertSpaceBeforeUnit == null) {
- insertSpaceBeforeUnit = new HashMap<Unit<?>,Boolean>();
+ insertSpaceBeforeUnit = new HashMap<>();
}
Boolean value = insertSpaceBeforeUnit.get(unit);
if (value == null) {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitsMap.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -58,7 +58,7 @@ final class UnitsMap extends Static {
* avoid loading the {@code SexagesimalConverter} class before needed, since their
* constants appear in this map.
*/
- static final Map<Unit<?>,Integer> EPSG_CODES = new HashMap<Unit<?>,Integer>(20);
+ static final Map<Unit<?>,Integer> EPSG_CODES = new HashMap<>(20);
static {
final byte[] codes = {1, 2, 30, 36, 101, 102, 103, 104, 105, 108, 109, 111, 110, (byte) 201, (byte) 202};
for (final byte c : codes) {
@@ -70,7 +70,7 @@ final class UnitsMap extends Static {
/**
* A few units commonly used in GIS.
*/
- private static final Map<Unit<?>,Unit<?>> COMMONS = new HashMap<Unit<?>,Unit<?>>(48);
+ private static final Map<Unit<?>,Unit<?>> COMMONS = new HashMap<>(48);
static {
COMMONS.put(MILLISECOND, MILLISECOND);
boolean nonSI = false;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -63,7 +63,7 @@ import static org.apache.sis.util.collec
import static org.apache.sis.internal.util.StandardDateFormat.UTC;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Path;
+import java.nio.file.Path;
/**
@@ -184,8 +184,8 @@ public enum About {
if (locale != null) {
formatLocale = locale;
} else {
- locale = Locale.getDefault();
- formatLocale = locale; // On the JDK7 branch, this is not necessarily the same.
+ locale = Locale.getDefault(Locale.Category.DISPLAY);
+ formatLocale = Locale.getDefault(Locale.Category.FORMAT);
}
String userHome = null;
String javaHome = null;
@@ -508,7 +508,7 @@ pathTree: for (int j=0; ; j++) {
* @return The paths, or {@code null} if none.
*/
private static Map<File,CharSequence> classpath(final String paths, final boolean asDirectories) {
- final Map<File,CharSequence> files = new LinkedHashMap<File,CharSequence>();
+ final Map<File,CharSequence> files = new LinkedHashMap<>();
return classpath(paths, null, asDirectories, files) ? files : null;
}
@@ -577,8 +577,7 @@ pathTree: for (int j=0; ; j++) {
}
final File file = entry.getKey();
if (file.isFile() && file.canRead()) {
- try {
- final JarFile jar = new JarFile(file);
+ try (final JarFile jar = new JarFile(file)) {
final Manifest manifest = jar.getManifest();
if (manifest != null) {
final Attributes attributes = manifest.getMainAttributes();
@@ -602,12 +601,11 @@ pathTree: for (int j=0; ; j++) {
}
}
}
- jar.close();
} catch (IOException e) {
if (error == null) {
error = e;
} else {
- // error.addSuppressed(e) on JDK7 branch.
+ error.addSuppressed(e);
}
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -25,6 +25,10 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Modules;
+// Branch-dependent imports
+import java.nio.file.OpenOption;
+import java.nio.file.StandardOpenOption;
+
/**
* Keys in a map of options for configuring various services
@@ -79,7 +83,7 @@ public class OptionKey<T> implements Ser
*
* @since 0.4
*/
- public static final OptionKey<Charset> ENCODING = new OptionKey<Charset>("ENCODING", Charset.class);
+ public static final OptionKey<Charset> ENCODING = new OptionKey<>("ENCODING", Charset.class);
/**
* The encoding of a URL (<strong>not</strong> the encoding of the document content).
@@ -111,7 +115,7 @@ public class OptionKey<T> implements Ser
*
* @see java.net.URLDecoder
*/
- public static final OptionKey<String> URL_ENCODING = new OptionKey<String>("URL_ENCODING", String.class);
+ public static final OptionKey<String> URL_ENCODING = new OptionKey<>("URL_ENCODING", String.class);
/**
* Whether a storage object (e.g. a {@link org.apache.sis.storage.DataStore}) shall be opened in read,
@@ -120,18 +124,13 @@ public class OptionKey<T> implements Ser
* <table class="sis">
* <caption>Supported open options</caption>
* <tr><th>Value</th> <th>Meaning</th></tr>
- * <tr><td>{@code "READ"}</td> <td>Open for reading data from the storage object.</td></tr>
- * <tr><td>{@code "WRITE"}</td> <td>Open for modifying existing data in the storage object.</td></tr>
- * <tr><td>{@code "APPEND"}</td> <td>Open for appending new data in the storage object.</td></tr>
- * <tr><td>{@code "CREATE"}</td> <td>Creates a new storage object (file or database) if it does not exist.</td></tr>
+ * <tr><td>{@link StandardOpenOption#READ}</td> <td>Open for reading data from the storage object.</td></tr>
+ * <tr><td>{@link StandardOpenOption#WRITE}</td> <td>Open for modifying existing data in the storage object.</td></tr>
+ * <tr><td>{@link StandardOpenOption#APPEND}</td> <td>Open for appending new data in the storage object.</td></tr>
+ * <tr><td>{@link StandardOpenOption#CREATE}</td> <td>Creates a new storage object (file or database) if it does not exist.</td></tr>
* </table>
- *
- * <div class="section">Differences between the JDK6 and JDK7 branches of SIS</div>
- * In the JDK7 branch of SIS, the array type for this key is {@code java.nio.file.OpenOption[]} instead than
- * {@code Object[]} and the constants listed in the above table are {@code java.nio.file.StandardOpenOption}
- * enumeration values.
*/
- public static final OptionKey<Object[]> OPEN_OPTIONS = new OptionKey<Object[]>("OPEN_OPTIONS", Object[].class);
+ public static final OptionKey<OpenOption[]> OPEN_OPTIONS = new OptionKey<>("OPEN_OPTIONS", OpenOption[].class);
/**
* The byte buffer to use for input/output operations. Some {@link org.apache.sis.storage.DataStore}
@@ -145,7 +144,7 @@ public class OptionKey<T> implements Ser
* <li>The same buffer is not used concurrently by two different {@code DataStore} instances.</li>
* </ul>
*/
- public static final OptionKey<ByteBuffer> BYTE_BUFFER = new OptionKey<ByteBuffer>("BYTE_BUFFER", ByteBuffer.class);
+ public static final OptionKey<ByteBuffer> BYTE_BUFFER = new OptionKey<>("BYTE_BUFFER", ByteBuffer.class);
/**
* The name of this key. For {@code OptionKey} instances, it shall be the name of the static constants.
@@ -226,7 +225,7 @@ public class OptionKey<T> implements Ser
public Map<OptionKey<?>,Object> setValueInto(Map<OptionKey<?>,Object> options, final T value) {
if (value != null) {
if (options == null) {
- options = new HashMap<OptionKey<?>,Object>();
+ options = new HashMap<>();
}
options.put(this, value);
} else if (options != null) {
@@ -278,7 +277,7 @@ public class OptionKey<T> implements Ser
private Object readResolve() {
try {
return OptionKey.class.getField(name).get(null);
- } catch (Exception e) { // (ReflectiveOperationException) on JDK7 branch.
+ } catch (ReflectiveOperationException e) {
/*
* This may happen if we are deserializing a stream produced by a more recent SIS library
* than the one running in this JVM. This class should be robust to this situation, since
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -21,7 +21,7 @@ import java.util.Comparator;
import java.lang.reflect.Array;
// Branch-dependent imports
-import org.apache.sis.internal.jdk7.Objects;
+import java.util.Objects;
/**
@@ -2024,6 +2024,7 @@ 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/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -23,10 +23,6 @@ import org.opengis.referencing.Identifie
import static java.lang.Character.*;
-// Related to JDK7
-import static org.apache.sis.internal.jdk7.JDK7.lowSurrogate;
-import static org.apache.sis.internal.jdk7.JDK7.highSurrogate;
-
/**
* Static methods working with {@link CharSequence} instances. Some methods defined in this
@@ -2083,8 +2079,8 @@ cmp: while (ia < lga) {
((StringBuilder) src).getChars(srcOffset, srcOffset + length, dst, dstOffset);
} else if (src instanceof StringBuffer) {
((StringBuffer) src).getChars(srcOffset, srcOffset + length, dst, dstOffset);
-// } else if (src instanceof CharBuffer) {
-// JDK7 ((CharBuffer) src).subSequence(srcOffset, srcOffset + length).get(dst, dstOffset, length);
+ } else if (src instanceof CharBuffer) {
+ ((CharBuffer) src).subSequence(srcOffset, srcOffset + length).get(dst, dstOffset, length);
} else {
// An other candidate could be javax.swing.text.Segment, but it
// is probably not worth to introduce a Swing dependency for it.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -264,7 +264,7 @@ public final class Classes extends Stati
* @return The set of classes of all objects in the given collection.
*/
private static <T> Set<Class<? extends T>> getClasses(final Iterable<? 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));
}
@@ -329,7 +329,7 @@ public final class Classes extends Stati
final Class<?>[] interfaces = type.getInterfaces();
for (final Class<?> candidate : interfaces) {
if (addTo == null) {
- addTo = new LinkedHashSet<Class<?>>(hashMapCapacity(interfaces.length));
+ addTo = new LinkedHashSet<>(hashMapCapacity(interfaces.length));
}
if (addTo.add(candidate)) {
getInterfaceSet(candidate, addTo);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1762629&r1=1762628&r2=1762629&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] Wed Sep 28 09:59:44 2016
@@ -25,9 +25,6 @@ import org.apache.sis.internal.util.Loca
import org.apache.sis.util.resources.Vocabulary;
import static org.apache.sis.util.CharSequences.trimWhitespaces;
-// Related to JDK7
-import org.apache.sis.internal.jdk7.JDK7;
-
/**
* Static methods working with {@link Exception} instances.
@@ -102,7 +99,7 @@ public final class Exceptions extends St
final Throwable ne;
try {
ne = exception.getClass().getConstructor(String.class).newInstance(message);
- } catch (Exception e) { // Too many exception for listing them all.
+ } catch (ReflectiveOperationException e) {
return exception;
}
ne.setStackTrace(exception.getStackTrace());
@@ -128,8 +125,8 @@ public final class Exceptions extends St
* and no exception provide a message.
*/
public static String formatChainedMessages(final Locale locale, String header, Throwable cause) {
- final List<String> previousLines = new ArrayList<String>();
- final String lineSeparator = JDK7.lineSeparator();
+ final List<String> previousLines = new ArrayList<>();
+ final String lineSeparator = System.lineSeparator();
StringBuilder buffer = null;
Vocabulary resources = null;
while (cause != null) {