You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2013/03/18 00:50:04 UTC
svn commit: r1457600 [2/3] - in /sis/branches/JDK6: ./ ide-project/NetBeans/
sis-metadata/src/main/java/org/apache/sis/metadata/
sis-metadata/src/main/java/org/apache/sis/metadata/iso/
sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ si...
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/simple/SimpleReferenceIdentifier.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -27,7 +27,7 @@ import org.apache.sis.util.Classes;
import static org.apache.sis.util.iso.DefaultNameSpace.DEFAULT_SEPARATOR;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -16,6 +16,7 @@
*/
package org.apache.sis.internal.util;
+import org.apache.sis.internal.jdk7.Objects;
import java.util.Collection;
import java.util.Iterator;
import java.util.Locale;
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/Appender.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/Appender.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/Appender.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/Appender.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -24,7 +24,7 @@ import org.apache.sis.util.ArgumentCheck
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
// Related to JDK7
-import org.apache.sis.internal.util.JDK7;
+import org.apache.sis.internal.jdk7.JDK7;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/CompoundFormat.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -387,6 +387,8 @@ public abstract class CompoundFormat<T>
return format;
} else if (valueType == Angle.class) {
return AngleFormat.getInstance(locale);
+ } else if (valueType == Class.class) {
+ return ClassFormat.INSTANCE;
}
return null;
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/DefaultFormat.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -20,8 +20,10 @@ import java.text.Format;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.ParseException;
+import java.io.InvalidObjectException;
import net.jcip.annotations.ThreadSafe;
import org.apache.sis.util.Numbers;
+import org.apache.sis.util.CharSequences;
import org.apache.sis.internal.util.LocalizedParseException;
@@ -45,6 +47,7 @@ final class DefaultFormat extends Format
/**
* The array for storing singleton instances for types {@code byte} to {@code double}.
+ * The value at index 0 is reserved for the generic {@link Number} type.
*/
private static final Format[] INSTANCES = new Format[Numbers.DOUBLE - Numbers.BYTE + 2];
@@ -104,7 +107,8 @@ final class DefaultFormat extends Format
* Parses the given string as a number of the type given at construction time.
*/
@Override
- public Object parseObject(final String source) throws ParseException {
+ public Object parseObject(String source) throws ParseException {
+ source = CharSequences.trimWhitespaces(source);
try {
return valueOf(source);
} catch (NumberFormatException cause) {
@@ -119,8 +123,9 @@ final class DefaultFormat extends Format
*/
@Override
public Object parseObject(String source, final ParsePosition pos) {
- final int index = pos.getIndex();
- source = source.substring(index);
+ final int length = source.length();
+ final int index = CharSequences.skipLeadingWhitespaces(source, pos.getIndex(), length);
+ source = source.substring(index, CharSequences.skipTrailingWhitespaces(source, index, length));
try {
return valueOf(source);
} catch (NumberFormatException cause) {
@@ -128,4 +133,12 @@ final class DefaultFormat extends Format
return null;
}
}
+
+ /**
+ * Resolves to the singleton instance on deserialization.
+ */
+ private Object readResolve() throws InvalidObjectException {
+ final Format format = getInstance(type);
+ return (format != null) ? format : this;
+ }
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineAppender.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -25,7 +25,7 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.internal.util.X364;
// Related to JK7
-import org.apache.sis.internal.util.JDK7;
+import org.apache.sis.internal.jdk7.JDK7;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableAppender.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -31,7 +31,7 @@ import org.apache.sis.internal.util.X364
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
// Related to JK7
-import org.apache.sis.internal.util.JDK7;
+import org.apache.sis.internal.jdk7.JDK7;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TabularFormat.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -27,7 +27,7 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.util.resources.Errors;
// Related to JK7
-import org.apache.sis.internal.util.JDK7;
+import org.apache.sis.internal.jdk7.JDK7;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/Statistics.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/Statistics.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/Statistics.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -27,7 +27,7 @@ import static java.lang.Double.isNaN;
import static java.lang.Double.doubleToLongBits;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -44,7 +44,7 @@ import static org.apache.sis.math.MathFu
import static org.apache.sis.math.MathFunctions.fractionDigitsForDelta;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -27,7 +27,7 @@ import java.text.Format;
import java.text.AttributedCharacterIterator;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.collection.CollectionsExt;
-import org.apache.sis.internal.util.SurjectiveConverter;
+import org.apache.sis.internal.converter.SurjectiveConverter;
import org.apache.sis.internal.simple.SimpleCharacterIterator;
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/MeasurementRange.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -24,7 +24,7 @@ import org.apache.sis.util.Numbers;
import org.apache.sis.util.resources.Errors;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Range.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Range.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/measure/Range.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -24,7 +24,7 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.util.Numbers;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/About.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/About.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/About.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -52,7 +52,7 @@ import static org.apache.sis.util.collec
import static org.apache.sis.util.collection.TableColumn.VALUE_AS_TEXT;
// JDK7 related
-import org.apache.sis.internal.util.JDK7;
+import org.apache.sis.internal.jdk7.JDK7;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArraysExt.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -21,7 +21,7 @@ import java.util.Comparator;
import java.lang.reflect.Array;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -23,8 +23,8 @@ import static java.lang.Character.*;
import static org.apache.sis.util.StringBuilders.replace;
// Related to JDK7
-import static org.apache.sis.internal.util.JDK7.lowSurrogate;
-import static org.apache.sis.internal.util.JDK7.highSurrogate;
+import static org.apache.sis.internal.jdk7.JDK7.lowSurrogate;
+import static org.apache.sis.internal.jdk7.JDK7.highSurrogate;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Classes.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -225,32 +225,6 @@ public final class Classes extends Stati
}
/**
- * Casts the {@code type} class to represent a subclass of the class represented by the
- * {@code sub} argument. Checks that the cast is valid, and returns {@code null} if it
- * is not.
- *
- * <p>This method performs the same work than
- * <code>type.{@linkplain Class#asSubclass(Class) asSubclass}(sub)</code>,
- * except that {@code null} is returned instead than throwing an exception
- * if the cast is not valid or if any of the argument is {@code null}.</p>
- *
- * @param <U> The compile-time bounds of the {@code sub} argument.
- * @param type The class to cast to a sub-class, or {@code null}.
- * @param sub The subclass to cast to, or {@code null}.
- * @return The {@code type} argument casted to a subclass of the {@code sub} argument,
- * or {@code null} if this cast can not be performed.
- *
- * @see Class#asSubclass(Class)
- */
- @SuppressWarnings({"unchecked","rawtypes"})
- public static <U> Class<? extends U> asSubclassOrNull(final Class<?> type, final Class<U> sub) {
- // Design note: We are required to return null if 'sub' is null (not to return 'type'
- // unchanged), because if we returned 'type', we would have an unsafe cast if this
- // method is invoked indirectly from a parameterized method.
- return (type != null && sub != null && sub.isAssignableFrom(type)) ? (Class) type : null;
- }
-
- /**
* Returns the class of the specified object, or {@code null} if {@code object} is null.
* This method is also useful for fetching the class of an object known only by its bound
* type. As of Java 6, the usual pattern:
@@ -267,6 +241,7 @@ public final class Classes extends Stati
* @return The class of the given object, or {@code null} if the given object was null.
*/
@SuppressWarnings("unchecked")
+ @Workaround(library="JDK", version="1.7")
public static <T> Class<? extends T> getClass(final T object) {
return (object != null) ? (Class<? extends T>) object.getClass() : null;
}
@@ -282,7 +257,7 @@ public final class Classes extends Stati
* @param objects The collection of objects.
* @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) {
+ private static <T> Set<Class<? extends T>> getClasses(final Iterable<? extends T> objects) {
final Set<Class<? extends T>> types = new LinkedHashSet<Class<? extends T>>();
for (final T object : objects) {
types.add(getClass(object));
@@ -291,23 +266,49 @@ public final class Classes extends Stati
}
/**
- * Returns the set of every interfaces implemented by the given class or interface. This is
- * similar to {@link Class#getInterfaces()} except that this method searches recursively in
- * the super-interfaces. For example if the given type is {@link java.util.ArrayList}, then
+ * Returns every interfaces implemented, directly or indirectly, by the given class or interface.
+ * This is similar to {@link Class#getInterfaces()} except that this method searches recursively
+ * in the super-interfaces. For example if the given type is {@link java.util.ArrayList}, then
* the returned set will contains {@link java.util.List} (which is implemented directly)
* together with its parent interfaces {@link Collection} and {@link Iterable}.
*
+ * @param <T> The compile-time type of the {@code Class} argument.
+ * @param type The class or interface for which to get all implemented interfaces.
+ * @return All implemented interfaces (not including the given {@code type} if it was an
+ * interface), or an empty array if none.
+ *
+ * @see Class#getInterfaces()
+ */
+ @SuppressWarnings({"unchecked","rawtypes"}) // Generic array creation.
+ public static <T> Class<? super T>[] getAllInterfaces(final Class<T> type) {
+ final Set<Class<?>> interfaces = getInterfaceSet(type);
+ return (interfaces != null) ? interfaces.toArray(new Class[interfaces.size()]) : EMPTY_ARRAY;
+ }
+
+ /**
+ * Implementation of {@link #getAllInterfaces(Class)} returning a {@link Set}.
+ * The public API exposes the method returning an array instead than a set for
+ * the following reasons:
+ *
+ * <ul>
+ * <li>Consistency with other methods ({@link #getLeafInterfaces(Class, Class)},
+ * {@link Class#getInterfaces()}).</li>
+ * <li>Because arrays in Java are covariant, while the {@code Set} are not.
+ * Consequently callers can cast {@code Class<? super T>[]} to {@code Class<?>[]}
+ * while they can not cast {@code Set<Class<? super T>>} to {@code Set<Class<?>>}.</li>
+ * </ul>
+ *
* @param type The class or interface for which to get all implemented interfaces.
* @return All implemented interfaces (not including the given {@code type} if it was an
- * interface), or an empty set if none. Callers can freely modify the returned set.
+ * interface), or {@code null} if none. Callers can freely modify the returned set.
*/
- public static Set<Class<?>> getAllInterfaces(Class<?> type) {
+ static Set<Class<?>> getInterfaceSet(Class<?> type) {
Set<Class<?>> interfaces = null;
while (type != null) {
- interfaces = getAllInterfaces(type, interfaces);
+ interfaces = getInterfaceSet(type, interfaces);
type = type.getSuperclass();
}
- return (interfaces != null) ? interfaces : Collections.<Class<?>>emptySet();
+ return interfaces;
}
/**
@@ -318,15 +319,15 @@ public final class Classes extends Stati
* @return The given set (may be {@code null}), or a new set if the given set was null
* and at least one interface has been found.
*/
- private static Set<Class<?>> getAllInterfaces(final Class<?> type, Set<Class<?>> addTo) {
+ private static Set<Class<?>> getInterfaceSet(final Class<?> type, Set<Class<?>> addTo) {
final Class<?>[] interfaces = type.getInterfaces();
for (int i=0; i<interfaces.length; i++) {
final Class<?> candidate = interfaces[i];
if (addTo == null) {
- addTo = new LinkedHashSet<Class<?>>(hashMapCapacity(interfaces.length - i));
+ addTo = new LinkedHashSet<Class<?>>(hashMapCapacity(interfaces.length));
}
if (addTo.add(candidate)) {
- getAllInterfaces(candidate, addTo);
+ getInterfaceSet(candidate, addTo);
}
}
return addTo;
@@ -396,7 +397,7 @@ next: for (final Class<?> candidat
* @return The most specialized class, or {@code null} if the given collection does not contain
* at least one non-null element.
*/
- public static Class<?> findSpecializedClass(final Collection<?> objects) {
+ public static Class<?> findSpecializedClass(final Iterable<?> objects) {
final Set<Class<?>> types = getClasses(objects);
types.remove(null);
/*
@@ -448,7 +449,7 @@ next: for (final Class<?> candidat
* @return The most specific class common to all supplied objects, or {@code null} if the
* given collection does not contain at least one non-null element.
*/
- public static Class<?> findCommonClass(final Collection<?> objects) {
+ public static Class<?> findCommonClass(final Iterable<?> objects) {
final Set<Class<?>> types = getClasses(objects);
types.remove(null);
return common(types);
@@ -494,13 +495,16 @@ next: for (final Class<?> candidat
* Callers can freely modify the returned set.
*/
public static Set<Class<?>> findCommonInterfaces(final Class<?> c1, final Class<?> c2) {
- final Set<Class<?>> interfaces = getAllInterfaces(c1);
- final Set<Class<?>> buffer = getAllInterfaces(c2); // To be recycled.
+ final Set<Class<?>> interfaces = getInterfaceSet(c1);
+ final Set<Class<?>> buffer = getInterfaceSet(c2); // To be recycled.
+ if (interfaces == null || buffer == null) {
+ return Collections.emptySet();
+ }
interfaces.retainAll(buffer);
for (Iterator<Class<?>> it=interfaces.iterator(); it.hasNext();) {
final Class<?> candidate = it.next();
buffer.clear(); // Safe because the buffer can not be Collections.EMPTY_SET at this point.
- getAllInterfaces(candidate, buffer);
+ getInterfaceSet(candidate, buffer);
if (interfaces.removeAll(buffer)) {
it = interfaces.iterator();
}
@@ -578,11 +582,11 @@ cmp: for (final Class<?> c : c1) {
if (classe == null) {
return "<*>";
}
- Class<?> enclosing = classe.getEnclosingClass();
while (classe.isAnonymousClass()) {
classe = classe.getSuperclass();
}
String name = classe.getSimpleName();
+ final Class<?> enclosing = classe.getEnclosingClass();
if (enclosing != null) {
name = getShortName(enclosing) + '.' + name;
}
@@ -621,7 +625,7 @@ cmp: for (final Class<?> c : c1) {
* @param allowedTypes The allowed types.
* @return {@code true} if the given type is assignable to one of the allowed types.
*/
- public static boolean isAssignableTo(final Class<?> type, final Class<?>... allowedTypes) {
+ public static boolean isAssignableToAny(final Class<?> type, final Class<?>... allowedTypes) {
if (type != null) {
if (allowedTypes == null) {
return true;
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -25,7 +25,7 @@ import org.apache.sis.internal.util.Loca
import static org.apache.sis.util.CharSequences.trimWhitespaces;
// Related to JDK7
-import org.apache.sis.internal.util.JDK7;
+import org.apache.sis.internal.jdk7.JDK7;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -25,11 +25,11 @@ package org.apache.sis.util;
*
* {@section Conditions for equality}
* <ul>
- * <li>{@link org.apache.sis.metadata.iso.MetadataEntity} subclasses
+ * <li>{@link org.apache.sis.metadata.iso.ISOMetadata} subclasses
* <ol>
* <li>{@link ComparisonMode#STRICT STRICT} – Objects must be of the same class
* and all attributes must be equal, including {@code xlink} and others
- * {@linkplain org.apache.sis.metadata.iso.MetadataEntity#getIdentifiers() identifiers}.</li>
+ * {@linkplain org.apache.sis.metadata.iso.ISOMetadata#getIdentifiers() identifiers}.</li>
* <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} – The same attributes than the above
* {@code STRICT} mode must be equal, but the metadata object don't need to be implemented
* by the same class provided that they implement the same GeoAPI interface.</li>
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Numbers.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -26,10 +26,11 @@ import java.util.Collections;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
-
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.collection.CollectionsExt;
+import static java.lang.Double.doubleToLongBits;
+
/**
* Static methods working with {@link Number} objects, and a few primitive types by extension.
@@ -46,8 +47,8 @@ public final class Numbers extends Stati
* Constant of value {@value} used in {@code switch} statements or as index in arrays.
*/
public static final byte
+ BIG_DECIMAL=10, BIG_INTEGER=9,
DOUBLE=8, FLOAT=7, LONG=6, INTEGER=5, SHORT=4, BYTE=3, CHARACTER=2, BOOLEAN=1, OTHER=0;
- // Note: This class assumes that DOUBLE is the greatest public constant.
/**
* Mapping between a primitive type and its wrapper, if any.
@@ -62,8 +63,8 @@ public final class Numbers extends Stati
*/
private static final Map<Class<?>,Numbers> MAPPING = new IdentityHashMap<Class<?>,Numbers>(16);
static {
- new Numbers(BigDecimal.class, true, false, (byte) (DOUBLE+2)); // Undocumented enum.
- new Numbers(BigInteger.class, false, true, (byte) (DOUBLE+1)); // Undocumented enum.
+ new Numbers(BigDecimal.class, true, false, BIG_DECIMAL);
+ new Numbers(BigInteger.class, false, true, BIG_INTEGER);
new Numbers(Double .TYPE, Double .class, true, false, (byte) Double .SIZE, DOUBLE, 'D', Double .valueOf(Double.NaN));
new Numbers(Float .TYPE, Float .class, true, false, (byte) Float .SIZE, FLOAT, 'F', Float .valueOf(Float .NaN));
new Numbers(Long .TYPE, Long .class, false, true, (byte) Long .SIZE, LONG, 'J', Long .valueOf( 0L));
@@ -304,7 +305,7 @@ public final class Numbers extends Stati
throws IllegalArgumentException
{
return narrowestClass((n1 != null) ? n1.getClass() : null,
- (n2 != null) ? n2.getClass() : null);
+ (n2 != null) ? n2.getClass() : null);
}
/**
@@ -350,148 +351,116 @@ public final class Numbers extends Stati
}
/**
- * Returns the smallest class capable to hold the specified value. If the given value is
- * {@code null}, then this method returns {@code null}. Otherwise this method delegates
- * to {@link #narrowestClass(double)} or {@link #narrowestClass(long)} depending on the value type.
- *
- * @param value The value to be wrapped in a finer (if possible) {@link Number}.
- * @return The narrowest type capable to hold the given value.
- *
- * @see #narrowestNumber(Number)
- */
- public static Class<? extends Number> narrowestClass(final Number value) {
- if (value == null) {
- return null;
- }
- if (isPrimitiveInteger(value.getClass())) {
- return narrowestClass(value.longValue());
- } else {
- return narrowestClass(value.doubleValue());
- }
- }
-
- /**
- * Returns the smallest class capable to hold the specified value.
- * This is similar to {@link #narrowestClass(long)}, but extended to floating point values.
- *
- * @param value The value to be wrapped in a {@link Number}.
- * @return The narrowest type capable to hold the given value.
- *
- * @see #narrowestNumber(double)
- */
- public static Class<? extends Number> narrowestClass(final double value) {
- final long lg = (long) value;
- if (value == lg) {
- return narrowestClass(lg);
- }
- final float fv = (float) value;
- if (Double.doubleToRawLongBits(value) == Double.doubleToRawLongBits(fv)) {
- return Float.class;
- }
- return Double.class;
- }
-
- /**
* Returns the smallest class capable to hold the specified value.
- * This method makes the following choice:
+ * This method applies the following choices, in that order:
*
* <ul>
- * <li>If the given value is between {@value java.lang.Byte#MIN_VALUE} and
+ * <li>If the given value is {@code null}, then this method returns {@code null}.</li>
+ * <li>Otherwise if the given value can not be casted from {@code double} to an other type
+ * without precision lost, return {@code Double.class}.</li>
+ * <li>Otherwise if the given value can not be casted from {@code float} to an other type
+ * without precision lost, return {@code Float.class}.</li>
+ * <li>Otherwise if the given value is between {@value java.lang.Byte#MIN_VALUE} and
* {@value java.lang.Byte#MAX_VALUE}, then this method returns {@code Byte.class};</li>
- * <li>If the given value is between {@value java.lang.Short#MIN_VALUE} and
+ * <li>Otherwise if the given value is between {@value java.lang.Short#MIN_VALUE} and
* {@value java.lang.Short#MAX_VALUE}, then this method returns {@code Short.class};</li>
- * <li>If the given value is between {@value java.lang.Integer#MIN_VALUE} and
+ * <li>Otherwise if the given value is between {@value java.lang.Integer#MIN_VALUE} and
* {@value java.lang.Integer#MAX_VALUE}, then this method returns {@code Integer.class};</li>
* <li>Otherwise this method returns {@code Long.class};</li>
* </ul>
*
- * @param value The value to be wrapped in a {@link Number}.
+ * @param value The value to be wrapped in a finer (if possible) {@link Number}.
* @return The narrowest type capable to hold the given value.
*
- * @see #narrowestNumber(long)
+ * @see #narrowestNumber(Number)
*/
- public static Class<? extends Number> narrowestClass(final long value) {
- // Tests MAX_VALUE before MIN_VALUE because it is more likely to fail.
- if (value <= Byte .MAX_VALUE && value >= Byte .MIN_VALUE) return Byte.class;
- if (value <= Short .MAX_VALUE && value >= Short .MIN_VALUE) return Short.class;
- if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) return Integer.class;
- return Long.class;
+ @SuppressWarnings("fallthrough")
+ public static Class<? extends Number> narrowestClass(final Number value) {
+ if (value == null) {
+ return null;
+ }
+ boolean isFloat = false;
+ final long longValue = value.longValue();
+ switch (getEnumConstant(value.getClass())) {
+ default: {
+ final double doubleValue = value.doubleValue();
+ final float floatValue = (float) doubleValue;
+ isFloat = (doubleToLongBits(floatValue) == doubleToLongBits(doubleValue));
+ if (doubleValue != longValue) {
+ return isFloat ? Float.class : Double.class;
+ }
+ // Fall through.
+ }
+ case LONG: if (((int) longValue) != longValue) return isFloat ? Float.class : Long.class;
+ case INTEGER: if (((short) longValue) != longValue) return Integer.class;
+ case SHORT: if (((byte) longValue) != longValue) return Short .class;
+ case BYTE: return Byte.class;
+ }
}
/**
- * Returns the number of the smallest class capable to hold the specified value. If the
- * given value is {@code null}, then this method returns {@code null}. Otherwise this
- * method delegates to {@link #narrowestNumber(double)} or {@link #narrowestNumber(long)}
- * depending on the value type.
+ * Returns the given number wrapped in the smallest class capable to hold the specified value.
+ * This method is equivalent to the following code, in a slightly more efficient way:
+ *
+ * {@preformat java
+ * return cast(value, narrowestClass(value));
+ * }
*
* @param value The value to be wrapped in a finer (if possible) {@link Number}.
* @return The narrowest type capable to hold the given value.
*
* @see #narrowestClass(Number)
+ * @see #cast(Number, Class)
*/
+ @SuppressWarnings("fallthrough")
public static Number narrowestNumber(final Number value) {
if (value == null) {
return null;
}
final Number candidate;
- if (isPrimitiveInteger(value.getClass())) {
- candidate = narrowestNumber(value.longValue());
- } else {
- candidate = narrowestNumber(value.doubleValue());
+ boolean isFloat = false;
+ final long longValue = value.longValue();
+ switch (getEnumConstant(value.getClass())) {
+ default: {
+ final double doubleValue = value.doubleValue();
+ final float floatValue = (float) doubleValue;
+ isFloat = (doubleToLongBits(floatValue) == doubleToLongBits(doubleValue));
+ if (doubleValue != longValue) {
+ candidate = isFloat ? ((Number) Float .valueOf(floatValue))
+ : ((Number) Double.valueOf(doubleValue));
+ break;
+ }
+ // Fall through everywhere.
+ }
+ case LONG: {
+ if (((int) longValue) != longValue) {
+ candidate = isFloat ? ((Number) Float.valueOf((float) longValue))
+ : ((Number) Long.valueOf(longValue));
+ break;
+ }
+ }
+ case INTEGER: {
+ if (((short) longValue) != longValue) {
+ candidate = Integer.valueOf((int) longValue);
+ break;
+ }
+ }
+ case SHORT: {
+ if (((byte) longValue) != longValue) {
+ candidate = Short.valueOf((short) longValue);
+ break;
+ }
+ }
+ case BYTE: {
+ candidate = Byte.valueOf((byte) longValue);
+ break;
+ }
}
// Keep the existing instance if possible.
return value.equals(candidate) ? value : candidate;
}
/**
- * Returns the number of the smallest class capable to hold the specified value.
- * This is similar to {@link #narrowestNumber(long)}, but extended to floating point values.
- *
- * @param value The value to be wrapped in a {@link Number}.
- * @return The narrowest type capable to hold the given value.
- *
- * @see #narrowestClass(double)
- */
- public static Number narrowestNumber(final double value) {
- final long lg = (long) value;
- if (value == lg) {
- return narrowestNumber(lg);
- }
- final float fv = (float) value;
- if (Double.doubleToRawLongBits(value) == Double.doubleToRawLongBits(fv)) {
- return Float.valueOf(fv);
- }
- return Double.valueOf(value);
- }
-
- /**
- * Returns the number of the smallest type capable to hold the specified value.
- * This method makes the following choice:
- *
- * <ul>
- * <li>If the given value is between {@value java.lang.Byte#MIN_VALUE} and
- * {@value java.lang.Byte#MAX_VALUE}, then it is wrapped in a {@link Byte} object.</li>
- * <li>If the given value is between {@value java.lang.Short#MIN_VALUE} and
- * {@value java.lang.Short#MAX_VALUE}, then it is wrapped in a {@link Short} object.</li>
- * <li>If the given value is between {@value java.lang.Integer#MIN_VALUE} and
- * {@value java.lang.Integer#MAX_VALUE}, then it is wrapped in an {@link Integer} object.</li>
- * <li>Otherwise the value is wrapped in a {@link Long} object.</li>
- * </ul>
- *
- * @param value The value to be wrapped in a {@link Number}.
- * @return The given value as a number of the narrowest type capable to hold it.
- *
- * @see #narrowestClass(long)
- */
- public static Number narrowestNumber(final long value) {
- // Tests MAX_VALUE before MIN_VALUE because it is more likely to fail.
- if (value <= Byte .MAX_VALUE && value >= Byte .MIN_VALUE) return Byte .valueOf((byte) value);
- if (value <= Short .MAX_VALUE && value >= Short .MIN_VALUE) return Short .valueOf((short) value);
- if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) return Integer.valueOf((int) value);
- return Long.valueOf(value);
- }
-
- /**
* Returns the smallest number capable to hold the specified value.
*
* @param value The value to be wrapped in a {@link Number}.
@@ -499,11 +468,10 @@ public final class Numbers extends Stati
* @throws NumberFormatException if the given value can not be parsed as a number.
*
* @see #narrowestNumber(Number)
- * @see #narrowestNumber(double)
- * @see #narrowestNumber(long)
*/
- public static Number narrowestNumber(String value) throws NumberFormatException {
- value = CharSequences.trimWhitespaces(value);
+ public static Number narrowestNumber(final String value) throws NumberFormatException {
+ // Do not trim whitespaces. It is up to the caller to do that if he wants.
+ // For such low level function, we are better to avoid hidden initiative.
final int length = value.length();
for (int i=0; i<length; i++) {
final char c = value.charAt(i);
@@ -516,7 +484,8 @@ public final class Numbers extends Stati
/**
* Casts a number to the specified class. The class must by one of {@link Byte},
- * {@link Short}, {@link Integer}, {@link Long}, {@link Float} or {@link Double}.
+ * {@link Short}, {@link Integer}, {@link Long}, {@link Float}, {@link Double},
+ * {@link BigInteger} or {@link BigDecimal}.
* This method makes the following choice:
*
* <ul>
@@ -527,10 +496,6 @@ public final class Numbers extends Stati
* <li>And likewise for all remaining known types.</li>
* </ul>
*
- * {@note This method is intentionally restricted to primitive types. Other types
- * like <code>BigDecimal</code> are not the purpose of this method.
- * See <code>ObjectConverter</code> for more generic methods.}
- *
* This method does not verify if the given type is wide enough for the given value,
* because the type has typically been calculated by {@link #widestClass(Class, Class)}
* or {@link #narrowestClass(Number)}. If nevertheless the given type is not wide enough,
@@ -551,20 +516,51 @@ public final class Numbers extends Stati
if (number == null || number.getClass() == type) {
return (N) number;
}
- if (type == Double .class) return (N) Double .valueOf(number.doubleValue());
- if (type == Float .class) return (N) Float .valueOf(number. floatValue());
- if (type == Long .class) return (N) Long .valueOf(number. longValue());
- if (type == Integer.class) return (N) Integer.valueOf(number. intValue());
- if (type == Short .class) return (N) Short .valueOf(number. shortValue());
- if (type == Byte .class) return (N) Byte .valueOf(number. byteValue());
- throw unknownType(type);
+ switch (getEnumConstant(type)) {
+ case BYTE: return (N) Byte .valueOf(number. byteValue());
+ case SHORT: return (N) Short .valueOf(number. shortValue());
+ case INTEGER: return (N) Integer.valueOf(number. intValue());
+ case LONG: return (N) Long .valueOf(number. longValue());
+ case FLOAT: return (N) Float .valueOf(number. floatValue());
+ case DOUBLE: return (N) Double .valueOf(number.doubleValue());
+ case BIG_INTEGER: {
+ final BigInteger c;
+ if (number instanceof BigInteger) {
+ c = (BigInteger) number;
+ } else if (number instanceof BigDecimal) {
+ c = ((BigDecimal) number).toBigInteger();
+ } else {
+ c = BigInteger.valueOf(number.longValue());
+ }
+ return (N) c;
+ }
+ case BIG_DECIMAL: {
+ final BigDecimal c;
+ if (number instanceof BigDecimal) {
+ c = (BigDecimal) number;
+ } else if (number instanceof BigInteger) {
+ c = new BigDecimal((BigInteger) number);
+ } else if (isInteger(number.getClass())) {
+ c = BigDecimal.valueOf(number.longValue());
+ } else {
+ c = BigDecimal.valueOf(number.doubleValue());
+ }
+ return (N) c;
+ }
+ default: {
+ if (type.isInstance(number)) {
+ return (N) number;
+ }
+ throw unknownType(type);
+ }
+ }
}
/**
* Wraps the given value in a {@code Number} of the specified class.
- * The given type shall be one of {@link Byte}, {@link Short}, {@link Integer},
- * {@link Long}, {@link Float} or {@link Double} classes. Furthermore, the given
- * value shall be convertible to the given class without precision lost,
+ * The given type shall be one of {@link Byte}, {@link Short}, {@link Integer}, {@link Long},
+ * {@link Float}, {@link Double}, {@link BigInteger} and {@link BigDecimal} classes.
+ * Furthermore, the given value shall be convertible to the given class without precision lost,
* otherwise an {@link IllegalArgumentException} will be thrown.
*
* @param <N> The wrapper class.
@@ -580,14 +576,18 @@ public final class Numbers extends Stati
throws IllegalArgumentException
{
final N number;
- if (type == Double .class) return (N) Double .valueOf(value); // No need to verify.
- else if (type == Float .class) number = (N) Float .valueOf((float) value);
- else if (type == Long .class) number = (N) Long .valueOf((long) value);
- else if (type == Integer.class) number = (N) Integer.valueOf((int) value);
- else if (type == Short .class) number = (N) Short .valueOf((short) value);
- else if (type == Byte .class) number = (N) Byte .valueOf((byte) value);
- else throw unknownType(type);
- if (Double.doubleToLongBits(number.doubleValue()) != Double.doubleToLongBits(value)) {
+ switch (getEnumConstant(type)) {
+ case BYTE: number = (N) Byte .valueOf((byte) value); break;
+ case SHORT: number = (N) Short .valueOf((short) value); break;
+ case INTEGER: number = (N) Integer .valueOf((int) value); break;
+ case LONG: number = (N) Long .valueOf((long) value); break;
+ case FLOAT: number = (N) Float .valueOf((float) value); break;
+ case DOUBLE: return (N) Double .valueOf(value); // No need to verify.
+ case BIG_INTEGER: number = (N) BigInteger.valueOf((long) value); break;
+ case BIG_DECIMAL: return (N) BigDecimal.valueOf(value); // No need to verify.
+ default: throw unknownType(type);
+ }
+ if (doubleToLongBits(number.doubleValue()) != doubleToLongBits(value)) {
throw new IllegalArgumentException(Errors.format(Errors.Keys.CanNotConvertValue_2, value, type));
}
return number;
@@ -595,6 +595,7 @@ public final class Numbers extends Stati
/**
* Converts the specified string into a value object. The value object can be an instance of
+ * {@link BigDecimal}, {@link BigInteger},
* {@link Double}, {@link Float}, {@link Long}, {@link Integer}, {@link Short}, {@link Byte},
* {@link Boolean}, {@link Character} or {@link String} according the specified type. This
* method makes the following choice:
@@ -607,11 +608,6 @@ public final class Numbers extends Stati
* <li>And likewise for all remaining known types.</li>
* </ul>
*
- * {@note This method is intentionally restricted to primitive types, with the addition of
- * <code>String</code> which can be though as an identity operation. Other types
- * like <code>BigDecimal</code> are not the purpose of this method. See the
- * <code>ConverterRegistry</code> class for a more generic method.}
- *
* @param <T> The requested type.
* @param value the value to parse.
* @param type The requested type.
@@ -621,31 +617,36 @@ public final class Numbers extends Stati
* string value is not parseable as a number of the specified type.
*/
@SuppressWarnings("unchecked")
- public static <T> T valueOf(String value, final Class<T> type)
+ public static <T> T valueOf(final String value, final Class<T> type)
throws IllegalArgumentException, NumberFormatException
{
if (value == null || type == String.class) {
return (T) value;
}
- if (type == Character.class) {
- /*
- * If the string is empty, returns 0 which means "end of string" in C/C++
- * and NULL in Unicode standard. If non-empty, take only the first char.
- * This is somewhat consistent with Boolean.valueOf(...) which is quite
- * lenient about the parsing as well, and throwing a NumberFormatException
- * for those would not be appropriate.
- */
- return (T) Character.valueOf(value.isEmpty() ? 0 : value.charAt(0));
- }
- value = CharSequences.trimWhitespaces(value);
- if (type == Double .class) return (T) Double .valueOf(value);
- if (type == Float .class) return (T) Float .valueOf(value);
- if (type == Long .class) return (T) Long .valueOf(value);
- if (type == Integer.class) return (T) Integer.valueOf(value);
- if (type == Short .class) return (T) Short .valueOf(value);
- if (type == Byte .class) return (T) Byte .valueOf(value);
- if (type == Boolean.class) return (T) Boolean.valueOf(value);
- throw unknownType(type);
+ switch (getEnumConstant(type)) {
+ case CHARACTER: {
+ /*
+ * If the string is empty, returns 0 which means "end of string" in C/C++
+ * and NULL in Unicode standard. If non-empty, take only the first char.
+ * This is somewhat consistent with Boolean.valueOf(...) which is quite
+ * lenient about the parsing as well, and throwing a NumberFormatException
+ * for those would not be appropriate.
+ */
+ return (T) Character.valueOf(value.isEmpty() ? 0 : value.charAt(0));
+ }
+ // Do not trim whitespaces. It is up to the caller to do that if he wants.
+ // For such low level function, we are better to avoid hidden initiative.
+ case BOOLEAN: return (T) Boolean.valueOf(value);
+ case BYTE: return (T) Byte .valueOf(value);
+ case SHORT: return (T) Short .valueOf(value);
+ case INTEGER: return (T) Integer.valueOf(value);
+ case LONG: return (T) Long .valueOf(value);
+ case FLOAT: return (T) Float .valueOf(value);
+ case DOUBLE: return (T) Double .valueOf(value);
+ case BIG_INTEGER: return (T) new BigInteger(value);
+ case BIG_DECIMAL: return (T) new BigDecimal(value);
+ default: throw unknownType(type);
+ }
}
/**
@@ -706,8 +707,10 @@ public final class Numbers extends Stati
}
/**
- * Returns one of {@link #DOUBLE}, {@link #FLOAT}, {@link #LONG}, {@link #INTEGER},
- * {@link #SHORT}, {@link #BYTE}, {@link #CHARACTER}, {@link #BOOLEAN} or {@link #OTHER}
+ * Returns a numeric constant for the given type.
+ * The constants are {@link #BIG_DECIMAL}, {@link #BIG_INTEGER},
+ * {@link #DOUBLE}, {@link #FLOAT}, {@link #LONG}, {@link #INTEGER},
+ * {@link #SHORT}, {@link #BYTE}, {@link #CHARACTER}, {@link #BOOLEAN}, or {@link #OTHER}
* constants for the given type. This is a commodity for usage in {@code switch} statements.
*
* @param type A type (usually either a primitive type or its wrapper).
@@ -715,13 +718,7 @@ public final class Numbers extends Stati
*/
public static byte getEnumConstant(final Class<?> type) {
final Numbers mapping = MAPPING.get(type);
- if (mapping != null) {
- // Filter out the non-public enum for BigDecimal and BigInteger.
- if (mapping.size >= 0) {
- return mapping.ordinal;
- }
- }
- return OTHER;
+ return (mapping != null) ? mapping.ordinal : OTHER;
}
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverter.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -25,23 +25,38 @@ import org.apache.sis.math.FunctionPrope
* The source and target types may be the same, in which case the {@code ObjectConverter} actually converts
* the values rather than the type.
*
- * <p>The main method of this interface is {@link #convert(Object)}, which receive an object of type
- * <var>S</var> and returns an object of type <var>T</var>. Some characteristics about the <var>S</var>
- * to <var>T</var> mapping are given by the {@link #properties()} enumeration, together with the
- * {@link #getSourceClass()} and {@link #getTargetClass()} methods.</p>
- *
- * <p>The <cite>domain</cite> of this function is the set of all values of type <var>S</var> for
- * which the {@link #convert(Object)} method does not throw {@link UnconvertibleObjectException}.
- * Note that values for which {@code convert(S)} returns {@code null} are considered as part of
- * the domain, even if the {@code null} target value stands for unconvertible source values.</p>
+ * <p>The main method of this interface is {@link #convert(Object)}, which receives an object of type
+ * <var>S</var> and returns an object of type <var>T</var>. The set of all <var>S</var> values for which
+ * {@code convert(S)} does not throw {@link UnconvertibleObjectException} is called the <cite>domain</cite>
+ * of this function, regardless of whether the <var>T</var> result is {@code null} or not.</p>
+ *
+ * {@section Function properties}
+ * Some characteristics about the <var>S</var> to <var>T</var> mapping are given by the
+ * {@link #properties()} enumeration, together with the {@link #getSourceClass()} and
+ * {@link #getTargetClass()} methods. Some possible function properties are:
*
- * <p>The above definition affects the function {@linkplain #properties() properties}
- * that this converter can declare:</p>
+ * <ul>
+ * <li>{@linkplain FunctionProperty#INJECTIVE Injective} if no pair of <var>S</var> can produce
+ * the same <var>T</var> value (e.g.: conversions from {@link Integer} to {@code String}).</li>
+ * <li>{@linkplain FunctionProperty#SURJECTIVE Surjective} if every values of <var>T</var> can be
+ * created from one or many values of <var>S</var> (e.g.: conversions from {@link String} to
+ * {@link Integer}).</li>
+ * <li>{@linkplain FunctionProperty#isBijective Bijective} if there is a one-to-one
+ * relationship between the <var>S</var> and <var>T</var> values.</li>
+ * <li>{@linkplain FunctionProperty#ORDER_PRESERVING Order preserving} if any sequence of
+ * increasing <var>S</var> values (in the sense of {@link Comparable}) is mapped to a
+ * sequence of increasing <var>T</var> values.</li>
+ * <li>{@linkplain FunctionProperty#ORDER_REVERSING Order reversing} if any sequence of
+ * increasing <var>S</var> values (in the sense of {@link Comparable}) is mapped to
+ * a sequence of decreasing <var>T</var> values.</li>
+ * </ul>
+ *
+ * Below are some guidelines about the function properties that a converter can declare:
*
* <ul>
* <li>If {@code convert(S)} returns {@code null} for unconvertible objects, then this {@code ObjectConverter}
- * can not declare {@link FunctionProperty#INJECTIVE} in its set of {@linkplain #properties() properties},
- * because more than one source value can produce the same target value (namely {@code null}).</li>
+ * can not be declared injective because more than one <var>S</var> value can produce the same
+ * <var>T</var> value (namely {@code null}).</li>
* <li>If {@code convert(S)} throws an exception for unconvertible objects, then this {@code ObjectConverter}
* can be declared as an injective function if the other values meet the criteria.
* </ul>
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ObjectConverters.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -19,11 +19,43 @@ package org.apache.sis.util;
import java.util.Map;
import java.util.Set;
import org.apache.sis.util.collection.CollectionsExt;
-import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.converter.IdentityConverter;
+import org.apache.sis.internal.converter.SystemRegistry;
/**
* Creates {@link ObjectConverter} instances, or uses them for creating collection views.
+ * Converters are created by the following methods:
+ *
+ * <ul>
+ * <li>{@link #identity(Class)}</li>
+ * <li>{@link #find(Class, Class)}</li>
+ * </ul>
+ *
+ * Converters can be used for creating derived collections by the following methods:
+ *
+ * <ul>
+ * <li>{@link #derivedSet(Set, ObjectConverter)}</li>
+ * <li>{@link #derivedMap(Map, ObjectConverter, ObjectConverter)}</li>
+ * <li>{@link #derivedKeys(Map, ObjectConverter, Class)}</li>
+ * <li>{@link #derivedValues(Map, Class, ObjectConverter)}</li>
+ * </ul>
+ *
+ * {@section Example}
+ * The following code convert instances in a collection from type {@code S} to type {@code T},
+ * where the types are unknown at compile-time. Note that the converter is obtained only once
+ * before to be applied to every elements in the loop.
+ *
+ * {@preformat java
+ * Class<S> sourceType = ...
+ * Class<T> targetType = ...
+ * Collection<S> sources = ...;
+ * Collection<T> targets = ...;
+ * ObjectConverter<S,T> converter = ObjectConverters.find(sourceType, targetType);
+ * for (S source : sources) {
+ * targets.add(converter.convert(source));
+ * }
+ * }
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3 (derived from geotk-3.00)
@@ -46,7 +78,7 @@ public final class ObjectConverters exte
*/
public static <T> ObjectConverter<T,T> identity(final Class<T> type) {
ArgumentChecks.ensureNonNull("type", type);
- return IdentityConverter.create(type);
+ return new IdentityConverter<T,T>(type, type, null).unique();
}
/**
@@ -59,11 +91,10 @@ public final class ObjectConverters exte
* @return The converter from the specified source class to the target class.
* @throws UnconvertibleObjectException if no converter is found.
*/
- public static <S,T> ObjectConverter<S,T> find(final Class<S> source, final Class<T> target)
+ public static <S,T> ObjectConverter<? super S, ? extends T> find(final Class<S> source, final Class<T> target)
throws UnconvertibleObjectException
{
- // TODO: port the implementation from Geotk
- throw new UnconvertibleObjectException(Errors.format(Errors.Keys.CanNotConvertFromType_2, source, target));
+ return SystemRegistry.INSTANCE.find(source, target);
}
/**
@@ -142,7 +173,7 @@ public final class ObjectConverters exte
final Class<V> valueType)
{
ArgumentChecks.ensureNonNull("valueType", valueType);
- return CollectionsExt.derivedMap(storage, keyConverter, IdentityConverter.create(valueType));
+ return CollectionsExt.derivedMap(storage, keyConverter, identity(valueType));
}
/**
@@ -170,6 +201,6 @@ public final class ObjectConverters exte
final ObjectConverter<SV,V> valueConverter)
{
ArgumentChecks.ensureNonNull("keyType", keyType);
- return CollectionsExt.derivedMap(storage, IdentityConverter.create(keyType), valueConverter);
+ return CollectionsExt.derivedMap(storage, identity(keyType), valueConverter);
}
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -24,7 +24,7 @@ import java.util.Map;
import java.util.Set;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/DefaultTreeTable.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -31,7 +31,7 @@ import static org.apache.sis.util.collec
import static org.apache.sis.util.collection.CollectionsExt.hashMapCapacity;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
@@ -66,6 +66,9 @@ import org.apache.sis.internal.util.Obje
* @since 0.3
* @version 0.3
* @module
+ *
+ * @see Node
+ * @see TableColumn
*/
@NotThreadSafe
public class DefaultTreeTable implements TreeTable, Cloneable, Serializable {
@@ -308,6 +311,9 @@ public class DefaultTreeTable implements
* @since 0.3
* @version 0.3
* @module
+ *
+ * @see DefaultTreeTable
+ * @see TableColumn
*/
@NotThreadSafe
public static class Node implements TreeTable.Node, Cloneable, Serializable {
@@ -443,7 +449,7 @@ public class DefaultTreeTable implements
}
/**
- * Creates a node with a single column for object names (c<cite>convenience constructor</cite>).
+ * Creates a node with a single column for object names (<cite>convenience constructor</cite>).
* The node will have the following columns:
*
* <table class="sis">
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -121,7 +121,6 @@ public class TableColumn<V> implements C
* the column elements are typically instances of {@link String} or {@link InternationalString},
* depending on whether the data provide localization support or not.
*/
- @SuppressWarnings("unchecked")
public static final TableColumn<CharSequence> VALUE_AS_TEXT = new Constant<CharSequence>("VALUE_AS_TEXT",
CharSequence.class, Vocabulary.Keys.Value);
@@ -129,13 +128,12 @@ public class TableColumn<V> implements C
* Frequently-used constant for a column of object numerical values.
* The column {@linkplain #getHeader() header} is "<cite>Value</cite>" (eventually localized).
*/
- @SuppressWarnings("unchecked")
public static final TableColumn<Number> VALUE_AS_NUMBER = new Constant<Number>("VALUE_AS_NUMBER",
Number.class, Vocabulary.Keys.Value);
/**
* A map containing only the {@link #NAME} column.
- * This is the default set of columns when parsing a table tree.
+ * This is the default set of columns when parsing a tree table.
*/
static final Map<TableColumn<?>,Integer> NAME_MAP =
Collections.<TableColumn<?>,Integer>singletonMap(NAME, 0);
@@ -249,7 +247,6 @@ public class TableColumn<V> implements C
public TableColumn(final Class<V> type, final CharSequence header) {
ArgumentChecks.ensureNonNull("type", this.type = type);
ArgumentChecks.ensureNonNull("header", this.header = header);
- this.header = Types.toInternationalString(header);
}
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTable.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -30,17 +30,17 @@ import java.util.List;
*
* {@preformat text
* Citation
- * ├───Title…………………………………………………………… Open Geospatial Consortium
- * ├───Presentation Forms………………………… document digital
- * ├───Cited Responsible Parties
- * │ ├───Organisation Name………………… Open Geospatial Consortium
- * │ ├───Role…………………………………………………… resource provider
- * │ └───Contact Info
- * │ └───Online Resource
- * │ ├───Linkage……………………… http://www.opengeospatial.org/
- * │ └───Function…………………… information
- * └───Identifiers
- * └───Code…………………………………………………… OGC
+ * ├─Title…………………………………………………………… Open Geospatial Consortium
+ * ├─Presentation Forms………………………… document digital
+ * ├─Cited Responsible Parties
+ * │ ├─Organisation Name………………… Open Geospatial Consortium
+ * │ ├─Role…………………………………………………… resource provider
+ * │ └─Contact Info
+ * │ └─Online Resource
+ * │ ├─Linkage……………………… http://www.opengeospatial.org/
+ * │ └─Function…………………… information
+ * └─Identifiers
+ * └─Code…………………………………………………… OGC
* }
*
* <p>In many cases, the columns are known in advance as hard-coded static constants.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -40,7 +40,7 @@ import org.apache.sis.internal.util.Loca
import static org.apache.sis.util.Characters.NO_BREAK_SPACE;
// Related to JDK7
-import org.apache.sis.internal.util.JDK7;
+import org.apache.sis.internal.jdk7.JDK7;
/**
@@ -52,9 +52,9 @@ import org.apache.sis.internal.util.JDK7
*
* {@preformat text
* Node #1
- * ├───Node #2
- * │ └───Node #4
- * └───Node #3
+ * ├─Node #2
+ * │ └─Node #4
+ * └─Node #3
* }
*
* If the same {@code TreeTable} is formatted with two columns,
@@ -62,9 +62,9 @@ import org.apache.sis.internal.util.JDK7
*
* {@preformat text
* Node #1……………………… More #1
- * ├───Node #2…………… More #2
- * │ └───Node #4… More #4
- * └───Node #3…………… More #3
+ * ├─Node #2…………… More #2
+ * │ └─Node #4… More #4
+ * └─Node #3…………… More #3
* }
*
* This representation can be printed to the {@linkplain java.io.Console#writer() console output}
@@ -118,7 +118,7 @@ public class TreeTableFormat extends Tab
/**
* The position of the vertical line, relative to the position of the label of the parent node.
- * The default value is 0, which means that the vertical line is drawn below the first letter
+ * The default value is 2, which means that the vertical line is drawn below the third letter
* of the node label.
*
* @see #getVerticalLinePosition()
@@ -132,9 +132,9 @@ public class TreeTableFormat extends Tab
*
* <ul>
* <li>{@code treeBlank} = {@code " "}</li>
- * <li>{@code treeLine} = {@code "│ "}</li>
- * <li>{@code treeCross} = {@code "├───"}</li>
- * <li>{@code treeEnd} = {@code "└───"}</li>
+ * <li>{@code treeLine} = {@code " │ "}</li>
+ * <li>{@code treeCross} = {@code " ├─"}</li>
+ * <li>{@code treeEnd} = {@code " └─"}</li>
* </ul>
*
* @see #clearTreeSymbols()
@@ -151,10 +151,11 @@ public class TreeTableFormat extends Tab
*/
public TreeTableFormat(final Locale locale, final TimeZone timezone) {
super(locale, timezone);
- indentation = 4;
- beforeFill = "……";
- fillCharacter = '…';
- omitTrailingNulls = true;
+ indentation = 4;
+ verticalLinePosition = 2;
+ beforeFill = "……";
+ fillCharacter = '…';
+ omitTrailingNulls = true;
}
/**
@@ -241,7 +242,7 @@ public class TreeTableFormat extends Tab
/**
* Returns the position of the vertical line, relative to the position of the root label.
- * The default value is 0, which means that the vertical line is drawn below the first
+ * The default value is 2, which means that the vertical line is drawn below the third
* letter of the root label.
*
* @return The current vertical line position.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTables.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -49,20 +49,20 @@ import org.apache.sis.util.ArgumentCheck
* <table class="compact"><tr><td>
* {@preformat text
* root
- * ├───users
- * │ └───alice
- * │ ├───data
- * │ │ └───mercator
- * │ └───document
- * └───lib
+ * ├─users
+ * │ └─alice
+ * │ ├─data
+ * │ │ └─mercator
+ * │ └─document
+ * └─lib
* }
* </td><td>
* {@preformat text
* root
- * ├───users/alice
- * │ ├───data/mercator
- * │ └───document
- * └───lib
+ * ├─users/alice
+ * │ ├─data/mercator
+ * │ └─document
+ * └─lib
* }
* </td></tr></table>
* {@preformat java
@@ -119,9 +119,9 @@ public final class TreeTables extends St
*
* {@preformat text
* from
- * └───users
- * └───alice
- * └───data
+ * └─users
+ * └─alice
+ * └─data
* }
*
* @param from The root node from which to start the search.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/UnmodifiableArrayList.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -21,7 +21,7 @@ import java.util.AbstractList;
import org.apache.sis.util.ArgumentChecks;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakHashSet.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -32,7 +32,7 @@ import org.apache.sis.util.NullArgumentE
import static org.apache.sis.util.collection.WeakEntry.*;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/collection/WeakValueHashMap.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -36,7 +36,7 @@ import org.apache.sis.util.resources.Err
import static org.apache.sis.util.collection.WeakEntry.*;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/AbstractName.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -30,7 +30,7 @@ import org.opengis.util.InternationalStr
import org.apache.sis.util.resources.Errors;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -35,7 +35,7 @@ import org.apache.sis.util.resources.Err
import static org.apache.sis.util.collection.CollectionsExt.isNullOrEmpty;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -33,7 +33,7 @@ import org.apache.sis.util.ArgumentCheck
import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -34,7 +34,7 @@ import org.apache.sis.util.collection.Un
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/iso/SimpleInternationalString.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -26,7 +26,7 @@ import net.jcip.annotations.Immutable;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
// Related to JDK7
-import org.apache.sis.internal.util.Objects;
+import org.apache.sis.internal.jdk7.Objects;
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Sun Mar 17 23:50:02 2013
@@ -78,6 +78,11 @@ public final class Errors extends Indexe
public static final int CanNotConvertValue_2 = 74;
/**
+ * Can not instantiate an object of type ‘{0}’.
+ */
+ public static final int CanNotInstantiate_1 = 81;
+
+ /**
* Can not set a value for property “{0}”.
*/
public static final int CanNotSetPropertyValue_1 = 75;
@@ -103,6 +108,16 @@ public final class Errors extends Indexe
public static final int DuplicatedValue_1 = 38;
/**
+ * Found {0} duplicated values.
+ */
+ public static final int DuplicatedValuesCount_1 = 78;
+
+ /**
+ * Duplicated values for the “{0}” property.
+ */
+ public static final int DuplicatedValuesForProperty_1 = 79;
+
+ /**
* Element “{0}” is already present.
*/
public static final int ElementAlreadyPresent_1 = 36;
@@ -255,6 +270,11 @@ public final class Errors extends Indexe
public static final int MismatchedDimension_3 = 58;
/**
+ * Missing value in the “{0}” column.
+ */
+ public static final int MissingValueInColumn_1 = 77;
+
+ /**
* Argument ‘{0}’ shall not be negative. The given value was {1}.
*/
public static final int NegativeArgument_2 = 8;
@@ -300,6 +320,16 @@ public final class Errors extends Indexe
public static final int NonEquilibratedParenthesis_2 = 59;
/**
+ * Conversion is not invertible.
+ */
+ public static final int NonInvertibleConversion = 82;
+
+ /**
+ * Transform is not invertible.
+ */
+ public static final int NonInvertibleTransform = 83;
+
+ /**
* “{0}” is not a linear unit.
*/
public static final int NonLinearUnit_1 = 47;
@@ -380,6 +410,11 @@ public final class Errors extends Indexe
public static final int UnexpectedEndOfString_1 = 30;
/**
+ * Type of the “{0}” property is unknown.
+ */
+ public static final int UnknownTypeForProperty_1 = 80;
+
+ /**
* Type ‘{0}’ is unknown in this context.
*/
public static final int UnknownType_1 = 76;
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1457600&r1=1457599&r2=1457600&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Sun Mar 17 23:50:02 2013
@@ -27,11 +27,14 @@
CanNotConvertFromType_2 = Can not convert from type \u2018{0}\u2019 to type \u2018{1}\u2019.
CanNotConvertValue_2 = Can not convert value \u201c{0}\u201d to type \u2018{1}\u2019.
CanNotComputeDerivative = Can not compute the derivative.
+CanNotInstantiate_1 = Can not instantiate an object of type \u2018{0}\u2019.
CanNotSetPropertyValue_1 = Can not set a value for property \u201c{0}\u201d.
ClassNotFinal_1 = Class \u2018{0}\u2019 is not final.
CloneNotSupported_1 = Can not clone an object of type \u2018{0}\u2019.
DeadThread_1 = Thread \u201c{0}\u201d is dead.
DuplicatedValue_1 = Value \u201c{0}\u201d is duplicated.
+DuplicatedValuesForProperty_1 = Duplicated values for the \u201c{0}\u201d property.
+DuplicatedValuesCount_1 = Found {0} duplicated values.
ElementAlreadyPresent_1 = Element \u201c{0}\u201d is already present.
EmptyArgument_1 = Argument \u2018{0}\u2019 shall not be empty.
EmptyDictionary = The dictionary shall contains at least one entry.
@@ -62,12 +65,15 @@ MandatoryAttribute_2 = Attrib
MismatchedCRS = The coordinate reference system must be the same for all objects.
MismatchedDimension_2 = Mismatched object dimension: {0}D and {1}D.
MismatchedDimension_3 = Argument \u2018{0}\u2019 has {2} dimension{2,choice,1#|2#s}, while {1} was expected.
+MissingValueInColumn_1 = Missing value in the \u201c{0}\u201d column.
NegativeArgument_2 = Argument \u2018{0}\u2019 shall not be negative. The given value was {1}.
NodeChildOfItself_1 = Node \u201c{0}\u201d can not be a child of itself.
NodeHasAnotherParent_1 = Node \u201c{0}\u201d already has another parent.
NodeHasNoParent_1 = Node \u201c{0}\u201d has no parent.
NodeNotFound_1 = No \u201c{0}\u201d node found.
NonEquilibratedParenthesis_2 = Missing a \u2018{1}\u2019 parenthesis in \u201c{0}\u201d.
+NonInvertibleConversion = Conversion is not invertible.
+NonInvertibleTransform = Transform is not invertible.
NonAngularUnit_1 = \u201c{0}\u201d is not an angular unit.
NonLinearUnit_1 = \u201c{0}\u201d is not a linear unit.
NonScaleUnit_1 = \u201c{0}\u201d is not a scale unit.
@@ -89,6 +95,7 @@ UndefinedOrderingForElements_2 = Orderi
UnexpectedChange_1 = Unexpected change in \u2018{0}\u2019.
UnexpectedEndOfString_1 = More characters were expected at the end of \u201c{0}\u201d.
UnknownType_1 = Type \u2018{0}\u2019 is unknown in this context.
+UnknownTypeForProperty_1 = Type of the \u201c{0}\u201d property is unknown.
UnmodifiableAffineTransform = This affine transform is unmodifiable.
UnmodifiableGeometry = This geometry is unmodifiable.
UnmodifiableMetadata = This metadata is unmodifiable.