You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2012/10/21 16:17:58 UTC
svn commit: r1400652 - in /sis/branches/JDK6: ./
ide-project/NetBeans/nbproject/
sis-utility/src/main/java/org/apache/sis/internal/util/
sis-utility/src/main/java/org/apache/sis/io/
sis-utility/src/main/java/org/apache/sis/math/ sis-utility/src/main/ja...
Author: desruisseaux
Date: Sun Oct 21 14:17:57 2012
New Revision: 1400652
URL: http://svn.apache.org/viewvc?rev=1400652&view=rev
Log:
Merge from the JDK7 branch.
Added:
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/JDK7.java (with props)
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/
- copied from r1400647, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/
- copied from r1400647, sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/io/
sis/branches/JDK6/src/site/apt/code-format.apt
- copied unchanged from r1400647, sis/branches/JDK7/src/site/apt/code-format.apt
Modified:
sis/branches/JDK6/ (props changed)
sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/EndOfLineFormatter.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Arrays.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Characters.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java
sis/branches/JDK6/src/main/javadoc/stylesheet.css
sis/branches/JDK6/src/site/apt/index.apt
Propchange: sis/branches/JDK6/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1400377-1400647
Modified: sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties (original)
+++ sis/branches/JDK6/ide-project/NetBeans/nbproject/genfiles.properties Sun Oct 21 14:17:57 2012
@@ -3,6 +3,6 @@
build.xml.data.CRC32=58e6b21c
build.xml.script.CRC32=462eaba0
build.xml.stylesheet.CRC32=28e38971@1.53.1.46
-nbproject/build-impl.xml.data.CRC32=ec6468cc
+nbproject/build-impl.xml.data.CRC32=ec3465c9
nbproject/build-impl.xml.script.CRC32=5fe86ff5
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
Added: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/JDK7.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/JDK7.java?rev=1400652&view=auto
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/JDK7.java (added)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/JDK7.java Sun Oct 21 14:17:57 2012
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.util;
+
+
+/**
+ * Place holder for methods defined only in JDK7. Those methods are defined in existing classes,
+ * so we can not creates a new class of the same name like we did for {@link Objects}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.3 (derived from GeoAPI)
+ * @version 0.3
+ * @module
+ */
+public final class JDK7 {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private JDK7() {
+ }
+
+ /**
+ * Returns the platform specific line-separator.
+ *
+ * @return The platform-specific line separator.
+ *
+ * @see System#lineSeparator()
+ */
+ public static String lineSeparator() {
+ return System.getProperty("line.separator", "\n");
+ }
+
+ /**
+ * Returns {@code true} if the given code point is in the BMP plane.
+ *
+ * @param c The code point.
+ * @return {@code true} if the given code point is in the BMP plane.
+ *
+ * @see Character#isBmpCodePoint(int)
+ */
+ public static boolean isBmpCodePoint(final int c) {
+ return c >= Character.MIN_VALUE &&
+ c <= Character.MAX_VALUE;
+ }
+
+ /**
+ * Returns the leading surrogate for the given code point.
+ *
+ * @param c The code point.
+ * @return The leading surrogate.
+ *
+ * @see Character#highSurrogate(int)
+ */
+ public static char highSurrogate(int c) {
+ c -= Character.MIN_SUPPLEMENTARY_CODE_POINT;
+ c >>>= 10;
+ c += Character.MIN_HIGH_SURROGATE;
+ return (char) c;
+ }
+
+ /**
+ * Returns the trailing surrogate for the given code point.
+ *
+ * @param c The code point.
+ * @return The trailing surrogate.
+ *
+ * @see Character#lowSurrogate(int)
+ */
+ public static char lowSurrogate(int c) {
+ c &= 0x3FF;
+ c += Character.MIN_LOW_SURROGATE;
+ return (char) c;
+ }
+}
Propchange: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/JDK7.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/internal/util/JDK7.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/EndOfLineFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/EndOfLineFormatter.java?rev=1400652&r1=1400647&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/EndOfLineFormatter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/EndOfLineFormatter.java Sun Oct 21 14:17:57 2012
@@ -21,6 +21,9 @@ import org.apache.sis.util.Decorator;
import org.apache.sis.util.Characters;
import org.apache.sis.util.ArgumentChecks;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* An {@link Appendable} which replaces various EOL by a unique string.
@@ -69,7 +72,7 @@ public class EndOfLineFormatter extends
*/
public EndOfLineFormatter(final Appendable out) {
super(out);
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
/**
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java?rev=1400652&r1=1400647&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/FilteredAppendable.java Sun Oct 21 14:17:57 2012
@@ -28,6 +28,9 @@ import static org.apache.sis.util.Charac
import static org.apache.sis.util.Characters.PARAGRAPH_SEPARATOR;
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* Base class for writing filtered characters to another {@link Appendable}.
@@ -176,11 +179,11 @@ public abstract class FilteredAppendable
* @throws IOException If an error occurred while appending the code point.
*/
final void appendCodePoint(final int c) throws IOException {
- if (Character.isBmpCodePoint(c)) {
+ if (JDK7.isBmpCodePoint(c)) {
out.append((char) c);
} else if (Character.isSupplementaryCodePoint(c)) {
- out.append(Character.highSurrogate(c))
- .append(Character. lowSurrogate(c));
+ out.append(JDK7.highSurrogate(c))
+ .append(JDK7. lowSurrogate(c));
} else {
throw new CharConversionException();
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java?rev=1400652&r1=1400647&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/LineWrapFormatter.java Sun Oct 21 14:17:57 2012
@@ -27,6 +27,9 @@ import static org.apache.sis.util.Charac
import static org.apache.sis.util.Characters.SOFT_HYPHEN;
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* An {@link Appendable} which wraps the lines to some maximal line length.
@@ -204,7 +207,7 @@ searchHyp: for (int i=buffer.length();
* then fallback on the system default.
*/
if (lineSeparator == null) {
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
out.append(lineSeparator);
final int length = buffer.length();
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java?rev=1400652&r1=1400647&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/io/TableFormatter.java Sun Oct 21 14:17:57 2012
@@ -30,6 +30,9 @@ import org.apache.sis.util.resources.Err
import static org.apache.sis.util.Arrays.EMPTY_INT;
import static org.apache.sis.util.Characters.isLineOrParagraphSeparator;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* An {@link Appendable} which formats the text as a table suitable for displaying in devices using
@@ -141,7 +144,7 @@ public class TableFormatter extends Filt
* <code>{@link Cell#text} == null</code> means that we need to move
* to the next line.
*/
- private final List<Cell> cells = new ArrayList<>();
+ private final List<Cell> cells = new ArrayList<Cell>();
/**
* Alignment for current and next cells.
@@ -751,7 +754,7 @@ public class TableFormatter extends Filt
out.append(isLastColumn ? rightBorder : columnSeparator);
}
if (lineSeparator == null) {
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
out.append(lineSeparator);
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/math/MathFunctions.java Sun Oct 21 14:17:57 2012
@@ -298,7 +298,7 @@ public final class MathFunctions extends
*
* As seen from the above cases, this method distinguishes positive zero from negative zero.
* The handling of zero values is the difference between invoking {@code isPositive(double)}
- * and testing if (<var>value</var> >= 0).
+ * and testing if (<var>value</var> {@literal >= 0}).
*
* @param value The value to test.
* @return {@code true} if the given value is positive, excluding negative zero.
@@ -319,7 +319,7 @@ public final class MathFunctions extends
*
* As seen from the above cases, this method distinguishes positive zero from negative zero.
* The handling of zero values is the difference between invoking {@code isNegative(double)}
- * and testing if (<var>value</var> < 0).
+ * and testing if (<var>value</var> {@literal < 0}).
*
* @param value The value to test.
* @return {@code true} if the given value is negative, including negative zero.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ArgumentChecks.java Sun Oct 21 14:17:57 2012
@@ -165,6 +165,8 @@ public final class ArgumentChecks extend
* @param index The index to check.
* @throws IndexOutOfBoundsException If the given index is negative or not lower than the
* given upper value.
+ *
+ * @see #ensurePositive(String, int)
*/
public static void ensureValidIndex(final int upper, final int index) throws IndexOutOfBoundsException {
if (index < 0 || index >= upper) {
@@ -173,6 +175,30 @@ public final class ArgumentChecks extend
}
/**
+ * Ensures that the given index range is valid for a sequence of the given length.
+ * This method is designed for methods that expect an index range as their only arguments.
+ * For this reason, this method does not take argument names.
+ *
+ * <p>This method verifies only the {@code lower} and {@code upper} argument values.
+ * It does not <strong>not</strong> verify the validity of the {@code length} argument,
+ * because this information is assumed to be provided by the implementation rather than
+ * the user.</p>
+ *
+ * @param length The length of the sequence (array, {@link CharSequence}, <i>etc.</i>).
+ * @param lower The user-specified lower index, inclusive.
+ * @param upper The user-specified upper index, exclusive.
+ * @throws IndexOutOfBoundsException If the given [{@code lower} ⦠{@code upper}]
+ * range is out of the sequence index range.
+ *
+ * @see #ensureBetween(String, int, int, int)
+ */
+ public static void ensureValidIndexRange(final int length, final int lower, final int upper) throws IndexOutOfBoundsException {
+ if (lower < 0 || upper < lower || upper > length) {
+ throw new IndexOutOfBoundsException(Errors.format(Errors.Keys.IllegalRange_2, lower, upper));
+ }
+ }
+
+ /**
* Ensures that the given integer value is greater than or equals to zero.
* This method is used for checking values that are <strong>not</strong> index.
* For checking index values, use {@link #ensureValidIndex(int, int)} instead.
@@ -180,6 +206,9 @@ public final class ArgumentChecks extend
* @param name The name of the argument to be checked, used only if an exception is thrown.
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is negative.
+ *
+ * @see #ensureValidIndex(int, int)
+ * @see #ensureStrictlyPositive(String, int)
*/
public static void ensurePositive(final String name, final int value)
throws IllegalArgumentException
@@ -196,6 +225,8 @@ public final class ArgumentChecks extend
* @param name The name of the argument to be checked, used only if an exception is thrown.
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is negative.
+ *
+ * @see #ensureStrictlyPositive(String, long)
*/
public static void ensurePositive(final String name, final long value)
throws IllegalArgumentException
@@ -214,6 +245,8 @@ public final class ArgumentChecks extend
* @param name The name of the argument to be checked, used only if an exception is thrown.
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is {@linkplain Float#NaN NaN} or negative.
+ *
+ * @see #ensureStrictlyPositive(String, float)
*/
public static void ensurePositive(final String name, final float value)
throws IllegalArgumentException
@@ -233,6 +266,8 @@ public final class ArgumentChecks extend
* @param name The name of the argument to be checked, used only if an exception is thrown.
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is {@linkplain Double#NaN NaN} or negative.
+ *
+ * @see #ensureStrictlyPositive(String, double)
*/
public static void ensurePositive(final String name, final double value)
throws IllegalArgumentException
@@ -250,6 +285,8 @@ public final class ArgumentChecks extend
* @param name The name of the argument to be checked, used only if an exception is thrown.
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is negative or equals to zero.
+ *
+ * @see #ensurePositive(String, int)
*/
public static void ensureStrictlyPositive(final String name, final int value)
throws IllegalArgumentException
@@ -266,6 +303,8 @@ public final class ArgumentChecks extend
* @param name The name of the argument to be checked, used only if an exception is thrown.
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is negative or equals to zero.
+ *
+ * @see #ensurePositive(String, long)
*/
public static void ensureStrictlyPositive(final String name, final long value)
throws IllegalArgumentException
@@ -285,6 +324,8 @@ public final class ArgumentChecks extend
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is {@linkplain Float#NaN NaN},
* zero or negative.
+ *
+ * @see #ensurePositive(String, float)
*/
public static void ensureStrictlyPositive(final String name, final float value)
throws IllegalArgumentException
@@ -305,6 +346,8 @@ public final class ArgumentChecks extend
* @param value The user argument to check.
* @throws IllegalArgumentException if the given value is {@linkplain Double#NaN NaN},
* zero or negative.
+ *
+ * @see #ensurePositive(String, double)
*/
public static void ensureStrictlyPositive(final String name, final double value)
throws IllegalArgumentException
@@ -324,6 +367,8 @@ public final class ArgumentChecks extend
* @param max The maximal value, inclusive.
* @param value The value to be tested.
* @throws IllegalArgumentException if the given value is not in the given range.
+ *
+ * @see #ensureValidIndexRange(int, int, int)
*/
public static void ensureBetween(final String name, final int min, final int max, final int value)
throws IllegalArgumentException
@@ -397,12 +442,12 @@ public final class ArgumentChecks extend
* This method does nothing if the given direct position is null.
*
* @param name The name of the argument to be checked. Used only in case an exception is thrown.
- * @param position The direct position to check for its dimension.
* @param expected The expected number of dimensions.
+ * @param position The direct position to check for its dimension, or {@code null}.
* @throws MismatchedDimensionException If the given direct position is non-null and does
* not have the expected number of dimensions.
*/
- public static void ensureDimensionMatches(final String name, final DirectPosition position, final int expected)
+ public static void ensureDimensionMatches(final String name, final int expected, final DirectPosition position)
throws MismatchedDimensionException
{
if (position != null) {
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Arrays.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Arrays.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Arrays.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Arrays.java Sun Oct 21 14:17:57 2012
@@ -136,12 +136,12 @@ public final class Arrays extends Static
* <ul>
* <li>If the given {@code length} is longer than the length of the given {@code array},
* then the returned array will contain all the elements of {@code array} at index
- * <var>i</var> < {@code array.length}. Elements at index
- * <var>i</var> >= {@code array.length} are initialized to {@code null}.</li>
+ * <var>i</var>Â {@literal <}Â {@code array.length}. Elements at index
+ * <var>i</var>Â {@literal >=}Â {@code array.length} are initialized to {@code null}.</li>
*
* <li>If the given {@code length} is shorter than the length of the given {@code array},
* then the returned array will contain only the elements of {@code array} at index
- * <var>i</var> < {@code length}. Remaining elements are not copied.</li>
+ * <var>i</var>Â {@literal <}Â {@code length}. Remaining elements are not copied.</li>
*
* <li>If the given {@code length} is equal to the length of the given {@code array},
* then {@code array} is returned unchanged. <strong>No copy</strong> is performed.
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=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/CharSequences.java Sun Oct 21 14:17:57 2012
@@ -16,12 +16,18 @@
*/
package org.apache.sis.util;
+import java.nio.CharBuffer;
+
import static java.lang.Character.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.copyOf;
import static org.apache.sis.util.Arrays.resize;
import static org.apache.sis.util.StringBuilders.replace;
+// Related to JDK7
+import static org.apache.sis.internal.util.JDK7.lowSurrogate;
+import static org.apache.sis.internal.util.JDK7.highSurrogate;
+
/**
* Static methods working with {@link CharSequence} instances. Some methods defined in this
@@ -217,13 +223,21 @@ public final class CharSequences extends
if (fromIndex < 0) {
fromIndex = 0;
}
- final int length = text.length();
+ int length = text.length();
+ char head = (char) toSearch;
+ char tail = (char) 0;
+ if (head != toSearch) { // Outside BMP plane?
+ head = highSurrogate(toSearch);
+ tail = lowSurrogate (toSearch);
+ length--;
+ }
while (fromIndex < length) {
- final int c = codePointAt(text, fromIndex);
- if (c == toSearch) {
- return fromIndex;
+ if (text.charAt(fromIndex) == head) {
+ if (tail == 0 || text.charAt(fromIndex+1) == tail) {
+ return fromIndex;
+ }
}
- fromIndex += charCount(c);
+ fromIndex++;
}
}
return -1;
@@ -309,7 +323,7 @@ search: for (; fromIndex <= stopAt;
/*
* Go backward if the number of lines is negative.
* No need to use the codePoint API because we are
- * looking only for '\r' and '\n' characters.
+ * looking only for characters in the BMP plane.
*/
if (numLines <= 0) {
do {
@@ -419,8 +433,14 @@ search: for (; fromIndex <= stopAt;
* Each element in the returned array will be a single line. If the given text is already
* a single line, then this method returns a singleton containing only the given text.
*
- * <p>At the difference of <code>{@linkplain #split split}(toSplit, '\nâ)</code>,
- * this method does not remove whitespaces.</p>
+ * <p>Notes:</p>
+ * <ul>
+ * <li>At the difference of <code>{@linkplain #split split}(toSplit, '\nâ)</code>,
+ * this method does not remove whitespaces.</li>
+ * <li>This method does not check for Unicode
+ * {@linkplain Characters#LINE_SEPARATOR line separator} and
+ * {@linkplain Characters#PARAGRAPH_SEPARATOR paragraph separator}.</li>
+ * </ul>
*
* {@note Prior JDK8 this method was relatively cheap because all string instances created by
* <code>String.substring(int,int)</code> shared the same <code>char[]</code> internal
@@ -440,8 +460,8 @@ search: for (; fromIndex <= stopAt;
return EMPTY_ARRAY;
}
/*
- * This method is implemented on top of String.indexOf(int,int), which is the
- * fatest method available while taking care of the complexity of code points.
+ * This method is implemented on top of String.indexOf(int,int),
+ * assuming that it will be faster for String and StringBuilder.
*/
int lf = indexOf(text, '\n', 0);
int cr = indexOf(text, '\r', 0);
@@ -1544,4 +1564,38 @@ cmp: while (ia < lga) {
}
return text.subSequence(fromIndex, upper);
}
+
+ /**
+ * Copies a sequence of characters in the given {@code char[]} array.
+ *
+ * @param src The character sequences from which to copy characters.
+ * @param srcOffset Index of the first character from {@code src} to copy.
+ * @param dst The array where to copy the characters.
+ * @param dstOffset Index where to write the first character in {@code dst}.
+ * @param length Number of characters to copy.
+ *
+ * @see String#getChars(int, int, char[], int)
+ * @see StringBuilder#getChars(int, int, char[], int)
+ * @see StringBuffer#getChars(int, int, char[], int)
+ * @see CharBuffer#get(char[], int, int)
+ */
+ public static void copyChars(final CharSequence src, int srcOffset,
+ final char[] dst, int dstOffset, int length)
+ {
+ ArgumentChecks.ensurePositive("length", length);
+ if (src instanceof String) {
+ ((String) src).getChars(srcOffset, srcOffset + length, dst, dstOffset);
+ } else if (src instanceof StringBuilder) {
+ ((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 {
+ while (length != 0) {
+ dst[dstOffset++] = src.charAt(srcOffset++);
+ length--;
+ }
+ }
+ }
}
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Characters.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Characters.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Characters.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Characters.java Sun Oct 21 14:17:57 2012
@@ -18,7 +18,10 @@ package org.apache.sis.util;
/**
- * Static methods working on {@code char} values.
+ * Static methods working on {@code char} values, and some character constants.
+ * Apache SIS uses Unicode symbols directly in the source code for easier reading,
+ * except for some symbols that are difficult to differentiate from other similar
+ * symbols. For those symbols, constants are declared in this class.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-2.1)
@@ -27,20 +30,71 @@ package org.apache.sis.util;
*/
public final class Characters extends Static {
/**
- * The <cite>no-break space</cite> (Unicode {@code \\u00A0}, HTML {@code }).
+ * Hyphen character ('\u2010', Unicode {@code 2010}).
+ * This code tells to {@link org.apache.sis.io.LineWrapFormatter}
+ * that a line break is allowed to be inserted after this character.
+ *
+ * <p>For non-breaking hyphen, use the Unicode {@code 2011} character.</p>
+ */
+ public static final char HYPHEN = '\u2010';
+
+ /**
+ * Hyphen character to be visible only if there is a line break to insert after it
+ * (Unicode {@code 00AD}, HTML {@code ­}).
+ * Otherwise this character is invisible. When visible, the graphical symbol is similar
+ * to the {@link #HYPHEN} character.
+ */
+ public static final char SOFT_HYPHEN = '\u00AD';
+
+ /**
+ * The <cite>no-break space</cite> (Unicode {@code 00A0}, HTML {@code }).
* Apache SIS uses Unicode symbols directly in the source code for easier reading,
* except for no-break spaces since they can not be visually distinguished from the
- * ordinary space (Unicode {@code \u0020}).
+ * ordinary space (Unicode {@code 0020}).
*/
public static final char NO_BREAK_SPACE = '\u00A0';
/**
+ * The Unicode line separator (Unicode {@code 2028}, HTML {@code <br>}).
+ *
+ * @see Character#LINE_SEPARATOR
+ */
+ public static final char LINE_SEPARATOR = '\u2028';
+
+ /**
+ * The Unicode paragraph separator (Unicode {@code 2029}, HTML {@code <p>â¦</p>}).
+ *
+ * @see Character#PARAGRAPH_SEPARATOR
+ */
+ public static final char PARAGRAPH_SEPARATOR = '\u2029';
+
+ /**
* Do not allow instantiation of this class.
*/
private Characters() {
}
/**
+ * Returns {@code true} if the given code point is a {@linkplain Character#LINE_SEPARATOR
+ * line separator}, a {@linkplain Character#PARAGRAPH_SEPARATOR paragraph separator} or one
+ * of the {@code '\r'} or {@code '\n'} control characters.
+ *
+ * @param c The code point to test.
+ * @return {@code true} if the given code point is a line or paragraph separator.
+ *
+ * @see #LINE_SEPARATOR
+ * @see #PARAGRAPH_SEPARATOR
+ */
+ public static boolean isLineOrParagraphSeparator(final int c) {
+ switch (Character.getType(c)) {
+ default: return false;
+ case Character.LINE_SEPARATOR:
+ case Character.PARAGRAPH_SEPARATOR: return true;
+ case Character.CONTROL: return (c == '\r') || (c == '\n');
+ }
+ }
+
+ /**
* Determines whether the given character is a superscript. Most (but not all) superscripts
* have a Unicode value in the [2070 ⦠207F] range. Superscripts are the following symbols:
*
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/ComparisonMode.java Sun Oct 21 14:17:57 2012
@@ -26,12 +26,12 @@ package org.apache.sis.util;
* <p>This enumeration is <em>ordered</em> from stricter to more lenient degrees:</p>
*
* <ol>
- * <li>{@link #STRICT}: All attributes of the compared objects shall be strictly equal.</li>
- * <li>{@link #BY_CONTRACT}: Only the attributes published in the interface contract need to be compared.</li>
- * <li>{@link #IGNORE_METADATA}: Only the attributes relevant to the object functionality are compared.</li>
- * <li>{@link #APPROXIMATIVE}: Only the attributes relevant to the object functionality are compared,
- * with some tolerance threshold on numerical values.</li>
- * <li>{@link #DEBUG}: Special mode for figuring out why two objects expected to be equal are not.</li>
+ * <li>{@link #STRICT} â All attributes of the compared objects shall be strictly equal.</li>
+ * <li>{@link #BY_CONTRACT} â Only the attributes published in the interface contract need to be compared.</li>
+ * <li>{@link #IGNORE_METADATA} â Only the attributes relevant to the object functionality are compared.</li>
+ * <li>{@link #APPROXIMATIVE} â Only the attributes relevant to the object functionality are compared,
+ * with some tolerance threshold on numerical values.</li>
+ * <li>{@link #DEBUG}: â Special mode for figuring out why two objects expected to be equal are not.</li>
* </ol>
*
* If two objects are equal at some degree of strictness <var>E</var>, then they should also
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=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java Sun Oct 21 14:17:57 2012
@@ -20,6 +20,9 @@ import java.sql.SQLException;
import java.util.Set;
import java.util.HashSet;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* Static methods working with {@link Exception} instances.
@@ -106,7 +109,7 @@ public final class Exceptions extends St
if (buffer == null) {
done = new HashSet<String>();
buffer = new StringBuilder(128);
- lineSeparator = System.getProperty("line.separator", "\n");
+ lineSeparator = JDK7.lineSeparator();
if (header != null && !(header = header.trim()).isEmpty()) {
buffer.append(header);
done.add(header);
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=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/LenientComparable.java Sun Oct 21 14:17:57 2012
@@ -24,98 +24,80 @@ package org.apache.sis.util;
* coordinates calculation.
*
* {@section Conditions for equality}
- *
- * <table class="sis">
- * <tr><th colspan="2">{@link org.apache.sis.metadata.iso.MetadataEntity} subclasses</th></tr>
- * <tr><td>{@link ComparisonMode#STRICT STRICT}</td>
- * <td class="sep">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}.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}</td>
- * <td class="sep">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.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}</td>
- * <td class="sep">Only the attributes defined in the GeoAPI interfaces are compared.
- * The above-cited identifiers and {@code xlinks} attributes are ignored.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}</td>
- * <td class="sep">The same attributes than the above {@code IGNORE_METADATA} mode are compared,
- * but a slight (implementation dependant) difference is tolerated in floating point numbers.</td></tr>
- *
- *
- *
- * <tr><th class="hsep" colspan="2">{@link org.apache.sis.referencing.AbstractIdentifiedObject} subclasses</th></tr>
- * <tr><td>{@link ComparisonMode#STRICT STRICT}</td>
- * <td class="sep">Objects must be of the same class and all attributes must be equal.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}</td>
- * <td class="sep">The same attributes than the above {@code STRICT} mode must be equal,
- * but the referencing object don't need to be implemented by the same class
- * provided that they implement the same GeoAPI interface.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}</td>
- * <td class="sep">The
- * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getIdentifiers() identifiers},
- * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getAlias() aliases},
- * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getScope() scope},
- * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getDomainOfValidity() domain of validity} and
- * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getRemarks() remarks} are ignored because
- * they have no incidence on the coordinate values to be computed by
- * {@linkplain org.opengis.referencing.operation.ConcatenatedOperation coordinate operations}.
- * All other attributes that are relevant to coordinate calculations, must be equal.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}</td>
- * <td class="sep">The same attributes than the above {@code IGNORE_METADATA} mode are compared,
- * but a slight (implementation dependant) difference is tolerated in floating point numbers.</td></tr>
- *
- *
- *
- * <tr><th class="hsep" colspan="2">{@link org.apache.sis.referencing.operation.transform.AbstractMathTransform} subclasses
- * except {@link org.apache.sis.referencing.operation.transform.LinearTransform}</th></tr>
- * <tr><td>{@link ComparisonMode#STRICT STRICT}</td>
- * <td class="sep">Objects must be of the same class and all attributes must be equal, including the
- * {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform#getParameterValues()
- * parameter values}.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}</td>
- * <td class="sep">Synonymous to the {@code STRICT} mode, because there is no GeoAPI interfaces for the various
- * kind of math transforms.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}</td>
- * <td class="sep">Objects must be of the same class, but the parameter values can be different
- * if they are different way to formulate the same transform.
- * For example a {@code "Mercator (2SP)"} projection with a
- * {@linkplain org.apache.sis.referencing.operation.projection.UnitaryProjection.Parameters#standardParallels
- * standard parallel} value of 60° produces the same results than a {@code "Mercator (1SP)"} projection with a
- * {@linkplain org.apache.sis.referencing.operation.projection.UnitaryProjection.Parameters#scaleFactor scale factor}
- * value of 0.5</td></tr>
- *
- * <tr><td>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}</td>
- * <td class="sep">The same attributes than the above {@code IGNORE_METADATA} mode are compared,
- * but a slight (implementation dependant) difference is tolerated in floating point numbers.</td></tr>
- *
- *
- *
- * <tr><th class="hsep" colspan="2">{@link org.apache.sis.referencing.operation.matrix.XMatrix} and
- * {@link org.apache.sis.referencing.operation.transform.LinearTransform} implementations</th></tr>
- * <tr><td>{@link ComparisonMode#STRICT STRICT}</td>
- * <td class="sep">Objects must be of the same class, matrixes must have the same size and all matrix
- * elements must be equal.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}</td>
- * <td class="sep">Matrixes must have the same size and all matrix elements must be equal,
- * but the matrixes are not required to be the same implementation class
- * (any {@link org.opengis.referencing.operation.Matrix} is okay).</td></tr>
- *
- * <tr><td>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}</td>
- * <td class="sep">Synonymous to the {@code BY_CONTRACT} mode, because matrixes don't have metadata.</td></tr>
- *
- * <tr><td>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}</td>
- * <td class="sep">The same attributes than the above {@code BY_CONTRACT} mode are compared,
- * but a slight (implementation dependant) difference is tolerated in floating point numbers.</td></tr>
- * </table>
+ * <ul>
+ * <li>{@link org.apache.sis.metadata.iso.MetadataEntity} subclasses
+ * <ul class="verbose">
+ * <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>
+ * <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>
+ * <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} â Only the attributes defined
+ * in the GeoAPI interfaces are compared. The above-cited identifiers and {@code xlinks}
+ * attributes are ignored.</li>
+ * <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} â The same attributes than the above
+ * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
+ * difference is tolerated in floating point numbers.</li>
+ * </ul>
+ * </li>
+ * <li>{@link org.apache.sis.referencing.AbstractIdentifiedObject} subclasses
+ * <ul class="verbose">
+ * <li>{@link ComparisonMode#STRICT STRICT} â Objects must be of the same class
+ * and all attributes must be equal.</li>
+ * <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} â The same attributes than the above
+ * {@code STRICT} mode must be equal, but the referencing object don't need to be
+ * implemented by the same class provided that they implement the same GeoAPI interface.</li>
+ * <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} â The
+ * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getIdentifiers() identifiers},
+ * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getAlias() aliases},
+ * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getScope() scope},
+ * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getDomainOfValidity() domain of validity} and
+ * {@linkplain org.apache.sis.referencing.crs.AbstractCRS#getRemarks() remarks}
+ * are ignored because they have no incidence on the coordinate values to be computed by
+ * {@linkplain org.opengis.referencing.operation.ConcatenatedOperation coordinate operations}.
+ * All other attributes that are relevant to coordinate calculations, must be equal.</li>
+ * <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} â The same attributes than the above
+ * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
+ * difference is tolerated in floating point numbers.</li>
+ * </ul>
+ * </li>
+ * <li>{@link org.apache.sis.referencing.operation.transform.AbstractMathTransform} subclasses
+ * except {@link org.apache.sis.referencing.operation.transform.LinearTransform}
+ * <ul class="verbose">
+ * <li>{@link ComparisonMode#STRICT STRICT} â Objects must be of the same class and all
+ * attributes must be equal, including the
+ * {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform#getParameterValues() parameter values}.</li>
+ * <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} â Synonymous to the {@code STRICT} mode,
+ * because there is no GeoAPI interfaces for the various kind of math transforms.</li>
+ * <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} â Objects must be of the same
+ * class, but the parameter values can be different if they are different way to formulate
+ * the same transform. For example a {@code "Mercator (2SP)"} projection with a
+ * {@linkplain org.apache.sis.referencing.operation.projection.UnitaryProjection.Parameters#standardParallels
+ * standard parallel} value of 60° produces the same results than a {@code "Mercator (1SP)"} projection with a
+ * {@linkplain org.apache.sis.referencing.operation.projection.UnitaryProjection.Parameters#scaleFactor
+ * scale factor} value of 0.5</li>
+ * <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} â The same attributes than the above
+ * {@code IGNORE_METADATA} mode are compared, but a slight (implementation dependant)
+ * difference is tolerated in floating point numbers.</li>
+ * </ul>
+ * </li>
+ * <li>{@link org.apache.sis.referencing.operation.matrix.XMatrix} and
+ * {@link org.apache.sis.referencing.operation.transform.LinearTransform} implementations
+ * <ul class="verbose">
+ * <li>{@link ComparisonMode#STRICT STRICT} â Objects must be of the same class, matrixes
+ * must have the same size and all matrix elements must be equal.</li>
+ * <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} â Matrixes must have the same size
+ * and all matrix elements must be equal, but the matrixes are not required to be the
+ * same implementation class (any {@link org.opengis.referencing.operation.Matrix} is okay).</li>
+ * <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} â Synonymous to the
+ * {@code BY_CONTRACT} mode, because matrixes don't have metadata.</li>
+ * <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} â The same attributes than the above
+ * {@code BY_CONTRACT} mode are compared, but a slight (implementation dependant)
+ * difference is tolerated in floating point numbers.</li>
+ * </ul>
+ * </li>
+ * </ul>
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3 (derived from geotk-3.18)
@@ -125,21 +107,22 @@ package org.apache.sis.util;
public interface LenientComparable {
/**
* Compares this object with the given object for equality.
- * The strictness level is controlled by the second argument:
+ * The strictness level is controlled by the second argument,
+ * for stricter to more permissive values:
*
- * <table class="sis">
- * <tr><td>{@link ComparisonMode#STRICT STRICT}</td>
- * <td class="sep">All attributes of the compared objects shall be strictly equal.</td></tr>
- * <tr><td>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT}</td>
- * <td class="sep">Only the attributes published in the interface contract need to be compared.</td></tr>
- * <tr><td>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA}</td>
- * <td class="sep">Only the attributes relevant to the object functionality are compared.</td></tr>
- * <tr><td>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE}</td>
- * <td class="sep">Only the attributes relevant to the object functionality are compared,
- * with some tolerance threshold on numerical values.</td></tr>
- * <tr><td>{@link ComparisonMode#DEBUG DEBUG}</td>
- * <td class="sep">Special mode for figuring out why two objects expected to be equal are not.</td></tr>
- * </table>
+ * <ol>
+ * <li>{@link ComparisonMode#STRICT STRICT} â
+ * All attributes of the compared objects shall be strictly equal.</li>
+ * <li>{@link ComparisonMode#BY_CONTRACT BY_CONTRACT} â
+ * Only the attributes published in the interface contract need to be compared.</li>
+ * <li>{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} â
+ * Only the attributes relevant to the object functionality are compared.</li>
+ * <li>{@link ComparisonMode#APPROXIMATIVE APPROXIMATIVE} â
+ * Only the attributes relevant to the object functionality are compared,
+ * with some tolerance threshold on numerical values.</li>
+ * <li>{@link ComparisonMode#DEBUG DEBUG} â
+ * special mode for figuring out why two objects expected to be equal are not.</li>
+ * </ol>
*
* @param other The object to compare to {@code this}.
* @param mode The strictness level of the comparison.
@@ -151,14 +134,28 @@ public interface LenientComparable {
/**
* Returns {@code true} if this object is strictly equals to the given object.
- * This method is typically implemented as below:
+ * This method is usually implemented as below:
*
* {@preformat java
- * return equals(other, ComparisonMode.STRICT);
+ * public boolean equals(Object other) {
+ * return equals(other, ComparisonMode.STRICT);
+ * }
* }
*
- * In SIS implementations, this method is typically {@code final} in order to ensure that
- * subclasses override the above {@link #equals(Object, ComparisonMode)} method instead.
+ * Implementors shall ensure that the following conditions hold. Unless the {@code equals}
+ * behavior is clearly documented in the interface javadoc (as for example in the Java
+ * collection framework), {@link ComparisonMode#STRICT} is the only reliable mode for
+ * this method implementation.
+ *
+ * <ul>
+ * <li>{@code A.equals(B)} implies {@code B.equals(A)};</li>
+ * <li>{@code A.equals(B)} and {@code B.equals(C)} implies {@code A.equals(C)};</li>
+ * <li>{@code A.equals(B)} implies {@code A.hashCode() == B.hashCode()};</li>
+ * </ul>
+ *
+ * This method is declared {@code final} in most SIS implementations for ensuring that
+ * subclasses override the above {@link #equals(Object, ComparisonMode)} method instead
+ * than this one.
*
* @param other The object to compare to {@code this}.
* @return {@code true} if both objects are strictly equal.
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/logging/LoggerAdapter.java Sun Oct 21 14:17:57 2012
@@ -43,7 +43,7 @@ import org.apache.sis.util.Debug;
* defined in terms of {@link #severe(String) severe} ⦠{@link #finest(String) finest} methods
* instead because external frameworks like <a href="http://commons.apache.org/logging/">Commons-logging</a>
* don't work with {@link LogRecord}, and sometime provides nothing else than convenience methods
- * equivalent to {@link #severe(String) severe} … {@link #finest(String) finest}.</p>
+ * equivalent to {@link #severe(String) severe} ⦠{@link #finest(String) finest}.</p>
*
* {@section Restrictions}
* Because the configuration is expected to be fully controlled by the external logging
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java Sun Oct 21 14:17:57 2012
@@ -43,6 +43,9 @@ import org.apache.sis.util.logging.Loggi
import static org.apache.sis.util.Arrays.resize;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* {@link ResourceBundle} implementation accepting integers instead of strings for resource keys.
@@ -299,7 +302,7 @@ public class IndexedResourceBundle exten
keyLength = Math.max(keyLength, key.length());
}
}
- final String lineSeparator = System.getProperty("line.separator", "\n");
+ final String lineSeparator = JDK7.lineSeparator();
final String[] values = ensureLoaded(null);
for (int i=0; i<values.length; i++) {
final String key = keys [i];
Modified: sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java (original)
+++ sis/branches/JDK6/sis-utility/src/main/java/org/apache/sis/xml/XLink.java Sun Oct 21 14:17:57 2012
@@ -46,7 +46,7 @@ import org.apache.sis.internal.util.Obje
*
* <blockquote><table class="sis">
* <tr>
- * <th> </th>
+ * <th>Â </th>
* <th width="14%">{@link XLink.Type#SIMPLE simple}</th>
* <th width="14%">{@link XLink.Type#EXTENDED extended}</th>
* <th width="14%">{@link XLink.Type#LOCATOR locator}</th>
@@ -54,36 +54,17 @@ import org.apache.sis.internal.util.Obje
* <th width="14%">{@link XLink.Type#RESOURCE resource}</th>
* <th width="14%">{@link XLink.Type#TITLE title}</th>
* </tr>
- * <tr align="center"><td><b>{@link #getType() type}</b></td>
- * <td>R</td><td>R</td><td>R</td><td>R</td><td>R</td><td>R</td>
- * </tr>
- * <tr align="center"><td><b>{@link #getHRef() href}</b></td>
- * <td>O</td><td> </td><td>R</td><td> </td><td> </td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getRole() role}</b></td>
- * <td>O</td><td>O</td><td>O</td><td> </td><td>O</td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getArcRole() arcrole}</b></td>
- * <td>O</td><td> </td><td> </td><td>O</td><td> </td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getTitle() title}</b></td>
- * <td>O</td><td>O</td><td>O</td><td>O</td><td>O</td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getShow() show}</b></td>
- * <td>O</td><td> </td><td> </td><td>O</td><td> </td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getActuate() actuate}</b></td>
- * <td>O</td><td> </td><td> </td><td>O</td><td> </td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getLabel() label}</b></td>
- * <td> </td><td> </td><td>O</td><td> </td><td>O</td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getFrom() from}</b></td>
- * <td> </td><td> </td><td> </td><td>O</td><td> </td><td> </td>
- * </tr>
- * <tr align="center"><td><b>{@link #getTo() to}</b></td>
- * <td> </td><td> </td><td> </td><td>O</td><td> </td><td> </td>
- * </tr></table></blockquote>
+ * <tr align="center"><td><b>{@link #getType() type}</b></td> <td>R</td><td>R</td><td>R</td><td>R</td><td>R</td><td>R</td></tr>
+ * <tr align="center"><td><b>{@link #getHRef() href}</b></td> <td>O</td><td>Â </td><td>R</td><td>Â </td><td>Â </td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getRole() role}</b></td> <td>O</td><td>O</td><td>O</td><td>Â </td><td>O</td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getArcRole() arcrole}</b></td> <td>O</td><td>Â </td><td>Â </td><td>O</td><td>Â </td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getTitle() title}</b></td> <td>O</td><td>O</td><td>O</td><td>O</td><td>O</td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getShow() show}</b></td> <td>O</td><td>Â </td><td>Â </td><td>O</td><td>Â </td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getActuate() actuate}</b></td> <td>O</td><td>Â </td><td>Â </td><td>O</td><td>Â </td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getLabel() label}</b></td> <td>Â </td><td>Â </td><td>O</td><td>Â </td><td>O</td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getFrom() from}</b></td> <td>Â </td><td>Â </td><td>Â </td><td>O</td><td>Â </td><td>Â </td></tr>
+ * <tr align="center"><td><b>{@link #getTo() to}</b></td> <td>Â </td><td>Â </td><td>Â </td><td>O</td><td>Â </td><td>Â </td></tr>
+ * </table></blockquote>
*
* When {@code xlink} attributes are found at unmarshalling time instead of an object definition,
* those attributes are given to the {@link ObjectLinker#resolve(Class, XLink)} method. Users can
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java?rev=1400652&r1=1400647&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/LineWrapFormatterTest.java Sun Oct 21 14:17:57 2012
@@ -21,6 +21,9 @@ import java.io.IOException;
import static org.junit.Assert.*;
import static org.apache.sis.util.Characters.SOFT_HYPHEN;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* Tests the {@link LineWrapFormatter} implementations.
@@ -63,7 +66,7 @@ public final strictfp class LineWrapForm
*/
String insertedLineSeparator = lineSeparator;
if (out instanceof SingleCharAppendable) {
- insertedLineSeparator = System.lineSeparator();
+ insertedLineSeparator = JDK7.lineSeparator();
}
assertOutputEquals("Ah! comme" + insertedLineSeparator
+ "la " + BLUE + "neige" + DEFAULT + " a" + insertedLineSeparator
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java?rev=1400652&r1=1400647&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/io/TableFormatterTest.java Sun Oct 21 14:17:57 2012
@@ -20,6 +20,9 @@ import java.io.IOException;
import static org.junit.Assert.*;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* Tests the {@link TableFormatter} implementations.
@@ -78,7 +81,7 @@ public final strictfp class TableFormatt
* implementation), but simply in order to allow the test to pass.
*/
if (out instanceof SingleCharAppendable) {
- lineSeparator = System.lineSeparator();
+ lineSeparator = JDK7.lineSeparator();
}
assertOutputEquals(
"âââââââââââ¤ââââââââââ¤âââââââââ" + lineSeparator
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java Sun Oct 21 14:17:57 2012
@@ -48,6 +48,9 @@ import static java.lang.StrictMath.*;
import static org.opengis.test.Assert.*;
import static org.apache.sis.util.Characters.NO_BREAK_SPACE;
+// Related to JDK7
+import org.apache.sis.internal.util.JDK7;
+
/**
* Compares the XML document produced by a test method with the expected XML document.
@@ -509,7 +512,7 @@ public strictfp class XMLComparator {
if (tolerance > 0 && abs(doubleValue(expected) - doubleValue(actual)) <= tolerance) {
return;
}
- final String lineSeparator = System.getProperty("line.separator", "\n");
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder buffer = new StringBuilder(1024).append("Expected ")
.append(propertyName).append(" \"")
.append(expected).append("\" but got \"")
@@ -554,7 +557,7 @@ public strictfp class XMLComparator {
* @return An error message containing the expected and actual node.
*/
protected String formatErrorMessage(final Node expected, final Node result) {
- final String lineSeparator = System.getProperty("line.separator", "\n");
+ final String lineSeparator = JDK7.lineSeparator();
final StringBuilder buffer = new StringBuilder(256).append("Nodes are not equal:").append(lineSeparator);
formatErrorMessage(buffer, expected, result, lineSeparator);
return buffer.toString();
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Sun Oct 21 14:17:57 2012
@@ -50,6 +50,12 @@ import org.junit.runners.Suite;
org.apache.sis.util.collection.WeakHashSetTest.class,
org.apache.sis.util.collection.WeakValueHashMapTest.class,
org.apache.sis.util.collection.CacheTest.class,
+ org.apache.sis.io.X364Test.class,
+ org.apache.sis.io.EndOfLineFormatterTest.class,
+ org.apache.sis.io.IndentedLineFormatterTest.class,
+ org.apache.sis.io.ExpandedTabFormatterTest.class,
+ org.apache.sis.io.LineWrapFormatterTest.class,
+ org.apache.sis.io.TableFormatterTest.class,
org.apache.sis.xml.XLinkTest.class,
org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class,
org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCasesTest.class
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java Sun Oct 21 14:17:57 2012
@@ -17,6 +17,7 @@
package org.apache.sis.util;
import java.util.Arrays;
+import java.nio.CharBuffer;
import org.apache.sis.test.TestCase;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.util.type.SimpleInternationalString;
@@ -393,4 +394,27 @@ public final strictfp class CharSequence
assertEquals("Id4", token("..Id4 56B..", 2));
assertEquals("56", token("..Id4 56B..", 6));
}
+
+ /**
+ * Tests the {@link CharSequences#copyChars(CharSequence, int, char[], int, int)} method.
+ */
+ @Test
+ public void testCopyChars() {
+ final char[] buffer = new char[12];
+ for (int i=0; i<=4; i++) {
+ final CharSequence sequence;
+ switch (i) {
+ case 0: sequence = ("testCopyChars()"); break;
+ case 1: sequence = new StringBuilder ("testCopyChars()"); break;
+ case 2: sequence = new StringBuffer ("testCopyChars()"); break;
+ case 3: sequence = CharBuffer.wrap ("testCopyChars()"); break;
+ case 4: sequence = new SimpleInternationalString("testCopyChars()"); break;
+ default: throw new AssertionError(i);
+ }
+ Arrays.fill(buffer, '-');
+ copyChars(sequence, 4, buffer, 2, 9);
+ assertEquals("--CopyChars-", String.valueOf(buffer));
+ assertEquals("testCopyChars()", sequence.toString()); // CharBuffer position must be unchanged.
+ }
+ }
}
Modified: sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java (original)
+++ sis/branches/JDK6/sis-utility/src/test/java/org/apache/sis/util/CharactersTest.java Sun Oct 21 14:17:57 2012
@@ -16,6 +16,7 @@
*/
package org.apache.sis.util;
+import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -33,6 +34,30 @@ import static org.apache.sis.util.Charac
*/
public final strictfp class CharactersTest extends TestCase {
/**
+ * Tests the value of {@link Characters#LINE_SEPARATOR}
+ * and {@link Characters#PARAGRAPH_SEPARATOR} constant value.
+ */
+ @Test
+ public void testUnicodeSeparators() {
+ assertEquals(Character.LINE_SEPARATOR, Character.getType(LINE_SEPARATOR));
+ assertEquals(Character.PARAGRAPH_SEPARATOR, Character.getType(PARAGRAPH_SEPARATOR));
+ }
+
+ /**
+ * Tests the {@link Characters#isLineOrParagraphSeparator(int)} method.
+ */
+ @Test
+ @DependsOnMethod("testUnicodeSeparators")
+ public void testLineOrParagraphSeparator() {
+ assertFalse(isLineOrParagraphSeparator('z'));
+ assertFalse(isLineOrParagraphSeparator('\t'));
+ assertTrue (isLineOrParagraphSeparator('\r'));
+ assertTrue (isLineOrParagraphSeparator('\n'));
+ assertTrue (isLineOrParagraphSeparator(LINE_SEPARATOR));
+ assertTrue (isLineOrParagraphSeparator(PARAGRAPH_SEPARATOR));
+ }
+
+ /**
* Tests {@link Characters#toSuperScript(char)}.
*/
@Test
Modified: sis/branches/JDK6/src/main/javadoc/stylesheet.css
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/src/main/javadoc/stylesheet.css?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/src/main/javadoc/stylesheet.css (original)
+++ sis/branches/JDK6/src/main/javadoc/stylesheet.css Sun Oct 21 14:17:57 2012
@@ -109,8 +109,8 @@ div.block ul {
}
ul.verbose li {
- margin-top: 6pt;
- margin-bottom: 6pt;
+ margin-top: 3pt;
+ margin-bottom: 3pt;
}
/*
Modified: sis/branches/JDK6/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/src/site/apt/index.apt?rev=1400652&r1=1400651&r2=1400652&view=diff
==============================================================================
--- sis/branches/JDK6/src/site/apt/index.apt (original)
+++ sis/branches/JDK6/src/site/apt/index.apt Sun Oct 21 14:17:57 2012
@@ -24,7 +24,7 @@ The Apache SIS⢠library
* {{{./download.html}Downloading binaries}}
- * {{{http://builds.apache.org/job/sis-trunk/site/apidocs/index.html}Aggregated Javadoc}}
+ * {{{./apidocs/index.html}Aggregated Javadoc}}
* Developer Guide (English - translation to be provided later) ({{{./book/fr.xhtml}Français}})
@@ -37,6 +37,8 @@ The Apache SIS⢠library
* {{{./code-patterns.html}Recommended code patterns}}
+ * {{{./code-format.html}Code and Javadoc formatting}}
+
Apache SIS, Apache, the Apache feather logo, and the Apache SIS project logo are trademarks of
The Apache Software Foundation.