You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2016/12/10 17:46:12 UTC
svn commit: r1773531 [2/3] - in /sis/trunk: ./ application/sis-console/
core/sis-metadata/src/main/java/org/apache/sis/io/wkt/
core/sis-metadata/src/main/java/org/apache/sis/metadata/
core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/...
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/UnitFormat.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -43,6 +43,7 @@ import org.apache.sis.util.Localized;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.CorruptedObjectException;
import org.apache.sis.util.collection.WeakValueHashMap;
+import org.apache.sis.util.iso.DefaultNameSpace;
/**
@@ -83,7 +84,12 @@ public class UnitFormat extends Format i
private static final long serialVersionUID = -3064428584419360693L;
/**
- * The SI "\u201cdeca\u201d prefix. This is the only SI prefix encoded on two letters instead than one.
+ * The unit name for dimensionless unit.
+ */
+ static final String UNITY = "unity";
+
+ /**
+ * The SI \u201cdeca\u201d prefix. This is the only SI prefix encoded on two letters instead than one.
* It can be represented by the CJK compatibility character \u201c\u3372\u201d, but use of those characters
* is generally not recommended outside of Chinese, Japanese or Korean texts.
*/
@@ -186,8 +192,8 @@ public class UnitFormat extends Format i
/** Actually illegal for UCUM, but at least ensure that it contains only ASCII characters. */
@Override void appendPower(final Appendable toAppendTo, final Fraction power) throws IOException {
- toAppendTo.append("^(").append(String.valueOf(power.numerator))
- .append('/').append(String.valueOf(power.denominator)).append(')');
+ toAppendTo.append(EXPONENT).append(OPEN).append(String.valueOf(power.numerator))
+ .append('/').append(String.valueOf(power.denominator)).append(CLOSE);
}
},
@@ -199,6 +205,11 @@ public class UnitFormat extends Format i
NAME('\u22c5', '\u2215');
/**
+ * Other symbols not in the {@link Style} enumeration because common to all.
+ */
+ static final char EXPONENT_OR_MULTIPLY = '*', EXPONENT = '^', OPEN = '(', CLOSE = ')';
+
+ /**
* Symbols to use for unit multiplications or divisions.
*/
final char multiply, divide;
@@ -234,17 +245,18 @@ public class UnitFormat extends Format i
* Appends a rational power.
*/
void appendPower(final Appendable toAppendTo, final Fraction power) throws IOException {
+ toAppendTo.append(EXPONENT);
final String value = power.toString();
if (value.length() == 1) {
- toAppendTo.append('^').append(value);
+ toAppendTo.append(value);
} else {
- toAppendTo.append("^(").append(value).append(')');
+ toAppendTo.append(OPEN).append(value).append(CLOSE);
}
}
}
/**
- * Symbols or names to use for formatting unit in replacement to the default unit symbols or names.
+ * Symbols or names to use for formatting units in replacement to the default unit symbols or names.
*
* @see #label(Unit, String)
*/
@@ -452,7 +464,7 @@ public class UnitFormat extends Format i
if (!locale.equals(Locale.ROOT)) copy(Locale.ROOT, getBundle(Locale.ROOT), map);
/*
* The UnitAliases file contains names that are not unit symbols and are not included in the UnitNames
- * property files neither. It contains longer names somtime used (for example "decimal degree" instead
+ * property files neither. It contains longer names sometime used (for example "decimal degree" instead
* of "degree"), some plural forms (for example "feet" instead of "foot") and a few common misspellings
* (for exemple "Celcius" instead of "Celsius").
*/
@@ -541,7 +553,7 @@ public class UnitFormat extends Format i
label = unit.getSymbol();
if (label != null) {
if (label.isEmpty()) {
- label = "unity";
+ label = UNITY;
}
// Following is not thread-safe, but it is okay since we do not use INSTANCE for unit names.
final ResourceBundle names = symbolToName();
@@ -569,7 +581,8 @@ public class UnitFormat extends Format i
final double scale = Units.toStandardUnit(unit);
if (scale != 1) {
if (Double.isNaN(scale)) {
- throw new IllegalArgumentException(Errors.format(Errors.Keys.NonRatioUnit_1, "?(" + unit.getSystemUnit() + ')'));
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.NonRatioUnit_1,
+ "?\u22c5" + Style.OPEN + unit.getSystemUnit() + Style.CLOSE));
}
final String text = Double.toString(scale);
int length = text.length();
@@ -620,12 +633,16 @@ public class UnitFormat extends Format i
deferred.add(entry);
}
}
- // At this point, all numerators have been appended. Now append the denominators together.
+ /*
+ * At this point, all numerators have been appended. Now append the denominators together.
+ * For example pressure dimension is formatted as M\u2215(L\u22c5T�) no matter if 'M' was the first
+ * dimension in the given 'components' map or not.
+ */
if (!deferred.isEmpty()) {
toAppendTo.append(style.divide);
final boolean useParenthesis = (deferred.size() > 1);
if (useParenthesis) {
- toAppendTo.append('(');
+ toAppendTo.append(Style.OPEN);
}
isFirst = true;
for (final Map.Entry<?,? extends Number> entry : deferred) {
@@ -636,7 +653,7 @@ public class UnitFormat extends Format i
formatComponent(entry, true, style, toAppendTo);
}
if (useParenthesis) {
- toAppendTo.append(')');
+ toAppendTo.append(Style.CLOSE);
}
}
}
@@ -733,24 +750,6 @@ public class UnitFormat extends Format i
}
/**
- * Returns {@code true} if the given unit seems to be an URI.
- * Examples:
- * <ul>
- * <li>{@code "urn:ogc:def:uom:EPSG::9001"}</li>
- * <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])"}</li>
- * </ul>
- */
- private static boolean isURI(final CharSequence uom) {
- for (int i=uom.length(); --i>=0;) {
- final char c = uom.charAt(i);
- if (c == ':' || c == '#') {
- return true;
- }
- }
- return false;
- }
-
- /**
* Returns {@code true} if the {@code '*'} character at the given index is surrounded by digits
* or a sign on its right side. For example this method returns {@code true} for "10*-6", which
* means 1E-6 in UCUM syntax. This check is used for heuristic rules at parsing time.
@@ -796,6 +795,10 @@ public class UnitFormat extends Format i
* The product operator can be either {@code '.'} (ASCII) or {@code '\u22c5'} (Unicode) character.
* Exponent after symbol can be decimal digits as in \u201cm2\u201d or a superscript as in \u201cm�\u201d.</p>
*
+ * <p>The default implementation delegates to
+ * <code>{@linkplain #parse(CharSequence, ParsePosition) parse}(symbols, new ParsePosition(0))</code>
+ * and verifies that all non-white characters have been parsed.</p>
+ *
* @param symbols the unit symbols or URI to parse.
* @return the unit parsed from the specified symbols.
* @throws ParserException if a problem occurred while parsing the given symbols.
@@ -803,8 +806,43 @@ public class UnitFormat extends Format i
* @see Units#valueOf(String)
*/
@Override
- @SuppressWarnings( {"null", "fallthrough"})
- public Unit<?> parse(CharSequence symbols) throws ParserException {
+ public Unit<?> parse(final CharSequence symbols) throws ParserException {
+ final ParsePosition position = new ParsePosition(0);
+ final Unit<?> unit = parse(symbols, position);
+ final int length = symbols.length();
+ final int unrecognized = CharSequences.skipTrailingWhitespaces(symbols, position.getIndex(), length);
+ if (unrecognized < length) {
+ throw new ParserException(Errors.format(Errors.Keys.UnexpectedCharactersAfter_2,
+ CharSequences.trimWhitespaces(symbols, 0, unrecognized),
+ CharSequences.trimWhitespaces(symbols, unrecognized, length)),
+ symbols, unrecognized);
+ }
+ return unit;
+ }
+
+ /**
+ * Parses a portion of the given text as an instance of {@code Unit}.
+ * Parsing begins at the index given by {@link ParsePosition#getIndex()}.
+ * After parsing, the above-cited index is updated to the first unparsed character.
+ *
+ * <p>The parsing is lenient: symbols can be products or quotients of units like \u201cm\u2215s\u201d,
+ * words like \u201cmeters per second\u201d, or authority codes like {@code "urn:ogc:def:uom:EPSG::1026"}.
+ * The product operator can be either {@code '.'} (ASCII) or {@code '\u22c5'} (Unicode) character.
+ * Exponent after symbol can be decimal digits as in \u201cm2\u201d or a superscript as in \u201cm�\u201d.</p>
+ *
+ * <p>Note that contrarily to {@link #parseObject(String, ParsePosition)}, this method never return {@code null}.
+ * If an error occurs at parsing time, an unchecked {@link ParserException} is thrown.</p>
+ *
+ * @param symbols the unit symbols to parse.
+ * @param position on input, index of the first character to parse.
+ * On output, index after the last parsed character.
+ * @return the unit parsed from the specified symbols.
+ * @throws ParserException if a problem occurred while parsing the given symbols.
+ */
+ @SuppressWarnings({"null", "fallthrough"})
+ public Unit<?> parse(CharSequence symbols, final ParsePosition position) throws ParserException {
+ ArgumentChecks.ensureNonNull("symbols", symbols);
+ ArgumentChecks.ensureNonNull("position", position);
/*
* Check for authority codes (currently only EPSG, but more could be added later).
* If the unit is not an authority code (which is the most common case), then we
@@ -815,77 +853,159 @@ public class UnitFormat extends Format i
* This is the intended behavior for AuthorityFactory, but in the particular case of this method
* we want to try to parse as a xpointer before to give up.
*/
- if (isURI(symbols)) {
- final String uom = symbols.toString();
+ int start = CharSequences.skipLeadingWhitespaces(symbols, position.getIndex(), symbols.length());
+ int end = XPaths.endOfURI(symbols, start);
+ if (end >= 0) {
+ final String uom = symbols.subSequence(start, end).toString();
String code = DefinitionURI.codeOf("uom", Constants.EPSG, uom);
- if (code != null && code != uom) try { // Really identity check, see above comment.
- return Units.valueOfEPSG(Integer.parseInt(code));
- } catch (NumberFormatException e) {
- throw (ParserException) new ParserException(
- Errors.format(Errors.Keys.IllegalArgumentValue_2, "symbols", symbols),
- uom, Math.max(0, uom.indexOf(code))).initCause(e);
+ if (code != null && code != uom) { // Really identity check, see above comment.
+ NumberFormatException failure = null;
+ try {
+ final Unit<?> unit = Units.valueOfEPSG(Integer.parseInt(code));
+ if (unit != null) {
+ position.setIndex(end);
+ return unit;
+ }
+ } catch (NumberFormatException e) {
+ failure = e;
+ }
+ throw (ParserException) new ParserException(Errors.format(Errors.Keys.UnknownUnit_1,
+ Constants.EPSG + DefaultNameSpace.DEFAULT_SEPARATOR + code),
+ symbols, start + Math.max(0, uom.indexOf(code))).initCause(failure);
}
code = XPaths.xpointer("uom", uom);
if (code != null) {
symbols = code;
+ start = 0;
}
}
/*
* Split the unit around the multiplication and division operators and parse each term individually.
+ * Note that exponentation need to be kept as part of a single unit symbol.
+ *
+ * The 'start' variable is the index of the first character of the next unit term to parse.
*/
- int offset = 0; // Index of the first character of the next unit term to parse.
- int operation = NOOP; // Enumeration value: MULTIPLY, DIVIDE.
- Unit<?> unit = null;
- final int length = symbols.length();
- for (int i=0; i<length; i++) {
- final char c = symbols.charAt(i); // No need to use code points because we search characters in BMP.
+ int operation = NOOP; // Enumeration value: IMPLICIT, MULTIPLY, DIVIDE.
+ Unit<?> unit = null;
+ end = symbols.length();
+ int i = start;
+scan: for (int n; i < end; i += n) {
+ final int c = Character.codePointAt(symbols, i);
+ n = Character.charCount(c);
final int next;
switch (c) {
/*
- * Star is for exponentiation in UCUM syntax, but some symbols may use it for unit multiplications.
- * We interpret
+ * For any character that are is not an operator or parenthesis, either continue the scanning of
+ * character or stop it, depending on whether the character is valid for a unit symbol or not.
+ * In the later case, we consider that we reached the end of a unit symbol.
*/
- case '*': if (isExponentOperator(symbols, i, length)) continue;
- next = MULTIPLY; break;
+ default: {
+ if (AbstractUnit.isSymbolChar(c)) {
+ if (operation == IMPLICIT) {
+ operation = MULTIPLY;
+ }
+ continue;
+ }
+ if (Character.isWhitespace(c) || Character.isDigit(c) || Characters.isSuperScript(c)) {
+ continue;
+ }
+ break scan;
+ }
+ /*
+ * Star is for exponentiation in UCUM syntax, but some symbols may use it for unit multiplication.
+ * We interpret the symbol as a multiplication if the characters before or after it seem to be for
+ * a unit symbol.
+ */
+ case Style.EXPONENT_OR_MULTIPLY: {
+ if (!isExponentOperator(symbols, i, end)) {
+ next = MULTIPLY;
+ break;
+ }
+ // else fall through.
+ }
+ case Style.EXPONENT: {
+ if (operation == IMPLICIT) {
+ // Support of exponentiation after parenthesis is not yet supported.
+ break scan;
+ }
+ continue;
+ }
/*
* The period is the multiplication operator in UCUM format. According UCUM there is no ambiguity
* with the decimal separator since unit terms should not contain floating point numbers. However
* we relax this rule in order to support scale factor of angular units (e.g. \u03c0/180). The period
* is interpreted as a decimal separator if there is a decimal digit before and after it.
*/
- case '.': if (isDecimalSeparator(symbols, i, length)) continue;
- case '\u22c5': // Fallthrough
+ case '.': if (isDecimalSeparator(symbols, i, end)) continue;
+ case '\u22c5': // Fall through
case '�': next = MULTIPLY; break;
case '�':
case '\u2044': // Fraction slash
case '/':
case '\u2215': next = DIVIDE; break;
- default: continue;
+ /*
+ * If we find an '(' parenthesis, invoke recursively this method for the part inside parenthesis.
+ * The parsing should end at the ')' parenthesis since it is not a valid unit symbol. If we do not
+ * find that closing parenthesis, this will be considered an error.
+ */
+ case Style.OPEN: {
+ final ParsePosition sub = new ParsePosition(i + Character.charCount(c));
+ final Unit<?> term = parse(symbols, sub);
+ i = CharSequences.skipLeadingWhitespaces(symbols, sub.getIndex(), end);
+ if (i >= end || Character.codePointAt(symbols, i) != Style.CLOSE) {
+ throw new ParserException(Errors.format(Errors.Keys.NonEquilibratedParenthesis_2,
+ symbols.subSequence(start, i), Style.CLOSE), symbols, start);
+ }
+ unit = apply(operation, unit, term);
+ operation = IMPLICIT; // Default operation if there is no � or / symbols after parenthesis.
+ start = i + (n = 1); // Skip the number of characters in the '(' Unicode code point.
+ continue;
+ }
}
- final Unit<?> term = parseSymbol(symbols, offset, i);
- switch (operation) {
- case NOOP: unit = term; break;
- case MULTIPLY: unit = unit.multiply(term); break;
- case DIVIDE: unit = unit.divide(term); break;
- default: throw new AssertionError(operation);
+ /*
+ * At this point, we have either a first unit to parse (NOOP), or a multiplication or division to apply
+ * between the previously parsed units and the next unit to parse. A special case is IMPLICIT, which is
+ * a multiplication without explicit � symbol after the parenthesis. The implicit multiplication can be
+ * overridden by an explicit � or / symbol, which is what happened if we reach this point (tip: look in
+ * the above 'switch' statement all cases that end with 'break', not 'break scan' or 'continue').
+ */
+ if (operation != IMPLICIT) {
+ unit = apply(operation, unit, parseSymbol(symbols, start, i));
}
operation = next;
- offset = i+1;
- }
- final Unit<?> term = parseSymbol(symbols, offset, length);
- switch (operation) {
- case NOOP: unit = term; break;
- case MULTIPLY: unit = unit.multiply(term); break;
- case DIVIDE: unit = unit.divide(term); break;
- default: throw new AssertionError(operation);
+ start = i + n;
}
+ /*
+ * At this point we either found an unrecognized character or reached the end of string. Parse the
+ * remaining characters as a unit and apply the pending unit operation (multiplication or division).
+ */
+ unit = apply(operation, unit, parseSymbol(symbols, start, i));
+ position.setIndex(i);
return unit;
}
/**
- * Meaning of some characters parsed by {@link #parse(CharSequence)}.
+ * Meaning of some characters parsed by {@link #parse(CharSequence)}. The {@code IMPLICIT} case
+ * is a multiplication without symbol, which can be overridden by an explicit � or / symbol.
+ */
+ private static final int NOOP = 0, IMPLICIT = 1, MULTIPLY = 2, DIVIDE = 3;
+
+ /**
+ * Applies a multiplication or division operation between the given units.
+ *
+ * @param operation one of {@link #NOOP}, {@link #IMPLICIT}, {@link #MULTIPLY} or {@link #DIVIDE}.
+ * @param unit the left operand, which is the unit parsed so far.
+ * @param term the right operation, which is the newly parsed unit.
*/
- private static final int NOOP = 0, MULTIPLY = 1, DIVIDE = 2;
+ private static Unit<?> apply(final int operation, final Unit<?> unit, final Unit<?> term) {
+ switch (operation) {
+ case NOOP: return term;
+ case IMPLICIT:
+ case MULTIPLY: return unit.multiply(term);
+ case DIVIDE: return unit.divide(term);
+ default: throw new AssertionError(operation);
+ }
+ }
/**
* Parses a single unit symbol with its exponent.
@@ -933,7 +1053,7 @@ public class UnitFormat extends Format i
return parseSymbol(uom, s, length).multiply(multiplier);
}
}
- s = uom.lastIndexOf('*');
+ s = uom.lastIndexOf(Style.EXPONENT_OR_MULTIPLY);
if (s >= 0) {
final int base = Integer.parseInt(uom.substring(0, s));
final int exp = Integer.parseInt(uom.substring(s+1));
@@ -1022,6 +1142,9 @@ public class UnitFormat extends Format i
"degrees", "degree").toString();
unit = nameToUnit().get(lc);
if (unit == null) {
+ if (CharSequences.regionMatches(symbols, lower, UNITY, true)) {
+ return Units.UNITY;
+ }
throw new ParserException(Errors.format(Errors.Keys.UnknownUnit_1, uom), symbols, lower);
}
}
@@ -1062,33 +1185,6 @@ public class UnitFormat extends Format i
}
/**
- * Parses the given text as an instance of {@code Unit}.
- *
- * @param symbols the unit symbols to parse.
- * @param pos on input, index of the first character to parse.
- * On output, index after the last parsed character.
- * @return the unit parsed from the specified symbols.
- * @throws ParserException if a problem occurred while parsing the given symbols.
- */
- public Unit<?> parse(final CharSequence symbols, final ParsePosition pos) {
- final int start = pos.getIndex();
- int stop = start;
- while (stop < symbols.length()) {
- final int c = Character.codePointAt(symbols, stop);
- if (Character.isWhitespace(c) || c == ']') break; // Temporary hack before we complete the JSR-275 replacement.
- stop += Character.charCount(c);
- }
- try {
- final Unit<?> unit = parse(symbols.subSequence(start, stop));
- pos.setIndex(stop);
- return unit;
- } catch (ParserException e) {
- pos.setErrorIndex(start);
- return null;
- }
- }
-
- /**
* Parses text from a string to produce a unit. The default implementation delegates to {@link #parse(CharSequence)}
* and wraps the {@link ParserException} into a {@link ParseException} for compatibility with {@code java.text} API.
*
@@ -1106,8 +1202,9 @@ public class UnitFormat extends Format i
}
/**
- * Parses text from a string to produce a unit. The default implementation delegates to
- * {@link #parse(CharSequence, ParsePosition)} with no additional work.
+ * Parses text from a string to produce a unit, or returns {@code null} if the parsing failed.
+ * The default implementation delegates to {@link #parse(CharSequence, ParsePosition)} and catches
+ * the {@link ParserException}.
*
* @param source the text, part of which should be parsed.
* @param pos index and error index information as described above.
@@ -1115,6 +1212,44 @@ public class UnitFormat extends Format i
*/
@Override
public Object parseObject(final String source, final ParsePosition pos) {
- return parse(source, pos);
+ try {
+ return parse(source, pos);
+ } catch (ParserException e) {
+ pos.setErrorIndex(e.getPosition());
+ return null;
+ }
+ }
+
+ /**
+ * Returns a clone of this unit format. The new unit format will be initialized to the same
+ * {@linkplain #getLocale() locale} and {@linkplain #label(Unit, String) labels} than this format.
+ *
+ * @return a clone of this unit format.
+ */
+ @Override
+ public UnitFormat clone() {
+ final UnitFormat f = (UnitFormat) super.clone();
+ try {
+ f.setFinal("unitToLabel", unitToLabel);
+ f.setFinal("labelToUnit", labelToUnit);
+ } catch (ReflectiveOperationException e) {
+ throw new AssertionError(e);
+ }
+ return f;
+ }
+
+ /**
+ * Sets final field to a clone of the given map. The given map shall be either
+ * a {@link HashMap} or the instance returned by {@link Collections#emptyMap()}.
+ */
+ private void setFinal(final String name, Map<?,?> value) throws ReflectiveOperationException {
+ if (value instanceof HashMap<?,?>) {
+ value = (Map<?,?>) ((HashMap<?,?>) value).clone();
+ } else {
+ value = new HashMap<>();
+ }
+ java.lang.reflect.Field f = UnitFormat.class.getDeclaredField(name);
+ f.setAccessible(true);
+ f.set(this, value);
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -1208,9 +1208,9 @@ public final class Units extends Static
*/
private static <Q extends Quantity<Q>> ConventionalUnit<Q> add(SystemUnit<Q> target, UnitConverter toTarget, String symbol, byte scope, short epsg) {
final ConventionalUnit<Q> unit = UnitRegistry.init(new ConventionalUnit<>(target, toTarget, symbol, scope, epsg));
- final ConventionalUnit<Q>[] related = target.related;
+ final ConventionalUnit<Q>[] related = target.related();
if (related != null && unit.scope != UnitRegistry.SI) {
- // Search first empty slot. This algorithm is inefficient, but the length of those arrays is small (<= 6).
+ // Search first empty slot. This algorithm is inefficient, but the length of those arrays is small (<= 7).
int i = 0;
while (related[i] != null) i++;
related[i] = unit;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -21,6 +21,7 @@ import java.util.HashMap;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.io.Serializable;
+import java.io.ObjectStreamException;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.internal.system.Modules;
@@ -273,8 +274,9 @@ public class OptionKey<T> implements Ser
* only for instance of the exact {@code OptionKey} class, not subclasses.
*
* @return the unique {@code OptionKey} instance.
+ * @throws ObjectStreamException required by specification but should never be thrown.
*/
- private Object readResolve() {
+ private Object readResolve() throws ObjectStreamException {
try {
return OptionKey.class.getField(name).get(null);
} catch (ReflectiveOperationException e) {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -20,6 +20,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.ObjectStreamException;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Iterator;
@@ -186,7 +187,7 @@ public class RangeSet<E extends Comparab
/**
* Returns the singleton instance on deserialization.
*/
- Object readResolve() {
+ Object readResolve() throws ObjectStreamException {
return INSTANCE;
}
};
@@ -256,9 +257,9 @@ public class RangeSet<E extends Comparab
* This constructor is provided for sub-classing only.
* Client code should use the static {@link #create(Class, boolean, boolean)} method instead.
*
- * @param elementType The type of the range elements.
- * @param isMinIncluded {@code true} if the minimal values are inclusive, or {@code false} if exclusive.
- * @param isMaxIncluded {@code true} if the maximal values are inclusive, or {@code false} if exclusive.
+ * @param elementType the type of the range elements.
+ * @param isMinIncluded {@code true} if the minimal values are inclusive, or {@code false} if exclusive.
+ * @param isMaxIncluded {@code true} if the maximal values are inclusive, or {@code false} if exclusive.
*/
protected RangeSet(final Class<E> elementType, final boolean isMinIncluded, final boolean isMaxIncluded) {
ArgumentChecks.ensureNonNull("elementType", elementType);
@@ -278,10 +279,10 @@ public class RangeSet<E extends Comparab
/**
* Constructs an initially empty set of ranges.
*
- * @param <E> The type of range elements.
- * @param elementType The type of the range elements.
- * @param isMinIncluded {@code true} if the minimal values are inclusive, or {@code false} if exclusive.
- * @param isMaxIncluded {@code true} if the maximal values are inclusive, or {@code false} if exclusive.
+ * @param <E> the type of range elements.
+ * @param elementType the type of the range elements.
+ * @param isMinIncluded {@code true} if the minimal values are inclusive, or {@code false} if exclusive.
+ * @param isMaxIncluded {@code true} if the maximal values are inclusive, or {@code false} if exclusive.
* @return A new range set for range elements of the given type.
*/
@SuppressWarnings({"unchecked","rawtypes"})
@@ -309,7 +310,7 @@ public class RangeSet<E extends Comparab
* Returns the comparator associated with this sorted set.
*/
@Override
- @SuppressWarnings({"unchecked","rawtypes"}) // Because we share the same static instance.
+ @SuppressWarnings({"unchecked","rawtypes"}) // Because we share the same static instance.
public Comparator<Range<E>> comparator() {
return Compare.INSTANCE;
}
@@ -320,7 +321,7 @@ public class RangeSet<E extends Comparab
@Override
public void clear() {
if (array instanceof Object[]) {
- Arrays.fill((Object[]) array, 0, length, null); // Let GC do its job.
+ Arrays.fill((Object[]) array, 0, length, null); // Let GC do its job.
}
length = 0;
modCount++;
@@ -331,7 +332,7 @@ public class RangeSet<E extends Comparab
*/
@Override
public int size() {
- assert (length & 1) == 0; // Length must be even.
+ assert (length & 1) == 0; // Length must be even.
return length >>> 1;
}
@@ -356,7 +357,7 @@ public class RangeSet<E extends Comparab
public final void trimToSize() {
// This method is final because equals(Object) and other methods rely on this behavior.
if (array != null && Array.getLength(array) != length) {
- reallocate(); // Will set the array to null if length == 0.
+ reallocate(); // Will set the array to null if length == 0.
assert isSorted();
}
}
@@ -365,9 +366,9 @@ public class RangeSet<E extends Comparab
* Inserts two values at the given index. The underlying {@linkplain #array} shall be
* non-null before this method is invoked. This method increases the array size as needed.
*
- * @param lower The index where to insert the values.
- * @param minValue The first value to insert.
- * @param maxValue The second value to insert.
+ * @param lower the index where to insert the values.
+ * @param minValue the first value to insert.
+ * @param maxValue the second value to insert.
*/
private void insertAt(final int lower, final E minValue, final E maxValue) {
final Object oldArray = array;
@@ -387,8 +388,8 @@ public class RangeSet<E extends Comparab
* Removes the values in the given range. The underlying {@linkplain #array} shall be
* non-null before this method is invoked.
*
- * @param lower First value to remove, inclusive.
- * @param upper Last value to remove, exclusive.
+ * @param lower first value to remove, inclusive.
+ * @param upper last value to remove, exclusive.
*/
private void removeAt(final int lower, final int upper) {
final int oldLength = length;
@@ -428,9 +429,9 @@ public class RangeSet<E extends Comparab
* Returns the index of {@code value} in {@link #array}. This method delegates to
* one of {@code Arrays.binarySearch} methods, depending on element primary type.
*
- * @param value The value to search.
- * @param lower Index of the first value to examine.
- * @param upper Index after the last value to examine.
+ * @param value the value to search.
+ * @param lower index of the first value to examine.
+ * @param upper index after the last value to examine.
*/
final int binarySearch(final E value, final int lower, final int upper) {
switch (elementCode) {
@@ -466,10 +467,10 @@ public class RangeSet<E extends Comparab
* match the ones given to the constructor of this {@code RangeSet}, then delegates to
* {@link #add(Comparable, Comparable)}.</p>
*
- * @param range The range to add.
+ * @param range the range to add.
* @return {@code true} if this set changed as a result of this method call.
- * @throws IllegalArgumentException If the {@code isMinIncluded} or {@code isMaxIncluded}
- * property doesn't match the one given at this {@code RangeSet} constructor.
+ * @throws IllegalArgumentException if the {@code isMinIncluded} or {@code isMaxIncluded}
+ * property does not match the one given at this {@code RangeSet} constructor.
*/
@Override
public boolean add(final Range<E> range) throws IllegalArgumentException {
@@ -489,8 +490,8 @@ public class RangeSet<E extends Comparab
* the existing ranges will be merged. This may result in smaller {@linkplain #size() size}
* of this set.
*
- * @param minValue The minimal value.
- * @param maxValue The maximal value.
+ * @param minValue the minimal value.
+ * @param maxValue the maximal value.
* @return {@code true} if this set changed as a result of this method call.
* @throws IllegalArgumentException if {@code minValue} is greater than {@code maxValue}.
*/
@@ -503,7 +504,7 @@ public class RangeSet<E extends Comparab
if (array == null) {
ensureOrdered(minValue, maxValue);
Class<?> type = elementType;
- if (type != Boolean.class) { // Because there is no Arrays.binarySearch(boolean[], \u2026) method.
+ if (type != Boolean.class) { // Because there is no Arrays.binarySearch(boolean[], \u2026) method.
type = wrapperToPrimitive(type);
}
array = Array.newInstance(type, 8);
@@ -517,7 +518,7 @@ public class RangeSet<E extends Comparab
int i0 = binarySearch(minValue, 0, length);
int i1 = binarySearch(maxValue, (i0 >= 0) ? i0 : ~i0, length);
if (i0 < 0) {
- i0 = ~i0; // Really tild operator, not minus sign.
+ i0 = ~i0; // Really tild operator, not minus sign.
if ((i0 & 1) == 0) {
/*
* If the "insertion point" is outside any existing range, if the maximum value
@@ -572,7 +573,7 @@ public class RangeSet<E extends Comparab
* Ensure that the index is odd. This means that if the maximum value is the begining of an
* existing range, then we move to the end of that range. Otherwise the index is unchanged.
*/
- i1 |= 1; // Equivalent to executing i1++ only if i1 is even.
+ i1 |= 1; // Equivalent to executing i1++ only if i1 is even.
/*
* At this point, the index of the [minValue \u2026 maxValue] range is now [i0 \u2026 i1].
* Remove everything between i0 and i1, excluding i0 and i1 themselves.
@@ -610,9 +611,9 @@ public class RangeSet<E extends Comparab
* the {@code isMinIncluded} and {@code isMaxIncluded} are consistent with the ones given to the
* constructor of this {@code RangeSet}, then delegates to {@link #remove(Comparable, Comparable)}.</p>
*
- * @param object The range to remove.
+ * @param object the range to remove.
* @return {@code true} if this set changed as a result of this method call.
- * @throws IllegalArgumentException If the {@code isMinIncluded} or {@code isMaxIncluded}
+ * @throws IllegalArgumentException if the {@code isMinIncluded} or {@code isMaxIncluded}
* property is not the complement of the one given at this {@code RangeSet} constructor.
*/
@Override
@@ -636,8 +637,8 @@ public class RangeSet<E extends Comparab
* then the existing range may be splitted in two smaller ranges. This may result in greater
* {@linkplain #size() size} of this set.
*
- * @param minValue The minimal value.
- * @param maxValue The maximal value.
+ * @param minValue the minimal value.
+ * @param maxValue the maximal value.
* @return {@code true} if this set changed as a result of this method call.
* @throws IllegalArgumentException if {@code minValue} is greater than {@code maxValue}.
*/
@@ -684,7 +685,7 @@ public class RangeSet<E extends Comparab
* index : A0 B0 i1 Bn A(n+1) B(n+1)
* range : \u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u25fe\u25fe\u25fe
*/
- removeAt(i0, i1 & ~1); // equivalent to (i0, i1 - 1)
+ removeAt(i0, i1 & ~1); // equivalent to (i0, i1 - 1)
Array.set(array, i0, maxValue);
}
} else {
@@ -747,7 +748,7 @@ public class RangeSet<E extends Comparab
final int di = i1 - i0;
assert di >= 2 : di;
if (di > 2) {
- removeAt(i0 + 1, i1 & ~1); // equivalent to (i0 + 1, i1 - 1)
+ removeAt(i0 + 1, i1 & ~1); // equivalent to (i0 + 1, i1 - 1)
}
Array.set(array, i0, minValue);
Array.set(array, i0 + 1, maxValue);
@@ -780,13 +781,13 @@ public class RangeSet<E extends Comparab
* The default implementation checks the type of the given object, then delegates to
* <code>{@linkplain #contains(Range, boolean) contains}(object, false)</code>.
*
- * @param object The object to check for inclusion in this set.
+ * @param object the object to check for inclusion in this set.
* @return {@code true} if the given object is contained in this set.
*/
@Override
public boolean contains(final Object object) {
if (object instanceof Range<?>) {
- @SuppressWarnings("unchecked") // We are going to check just the line after.
+ @SuppressWarnings("unchecked") // We are going to check just the line after.
final Range<E> range = (Range<E>) object;
if (range.getElementType() == elementType) {
return contains(range, false);
@@ -806,8 +807,8 @@ public class RangeSet<E extends Comparab
* behaves as documented in the {@link #contains(Object)} method.</li>
* </ul>
*
- * @param range The range to check for inclusion in this set.
- * @param exact {@code true} for searching for an exact match,
+ * @param range the range to check for inclusion in this set.
+ * @param exact {@code true} for searching for an exact match,
* or {@code false} for searching for inclusion in any range.
* @return {@code true} if the given object is contained in this set.
*/
@@ -891,8 +892,8 @@ public class RangeSet<E extends Comparab
* this {@code RangeSet} with the given range. Changes in this {@code RangeSet}
* will be reflected in the returned view, and conversely.
*
- * @param subRange The range to intersect with this {@code RangeSet}.
- * @return A view of the specified range within this range set.
+ * @param subRange the range to intersect with this {@code RangeSet}.
+ * @return a view of the specified range within this range set.
*/
public SortedSet<Range<E>> intersect(final Range<E> subRange) {
ArgumentChecks.ensureNonNull("subRange", subRange);
@@ -915,9 +916,9 @@ public class RangeSet<E extends Comparab
* This method takes the minimal value of the {@code upper} argument instead
* than the maximal value because the upper endpoint is exclusive.</div>
*
- * @param lower Low endpoint (inclusive) of the sub set.
- * @param upper High endpoint (exclusive) of the sub set.
- * @return A view of the specified range within this sorted set.
+ * @param lower low endpoint (inclusive) of the sub set.
+ * @param upper high endpoint (exclusive) of the sub set.
+ * @return a view of the specified range within this sorted set.
*
* @see #intersect(Range)
*/
@@ -942,8 +943,8 @@ public class RangeSet<E extends Comparab
* documented in the {@link #subSet(Range, Range)} method, except that the lower
* endpoint is {@code null}.
*
- * @param upper High endpoint (exclusive) of the headSet.
- * @return A view of the specified initial range of this sorted set.
+ * @param upper high endpoint (exclusive) of the headSet.
+ * @return a view of the specified initial range of this sorted set.
*
* @see #intersect(Range)
*/
@@ -965,8 +966,8 @@ public class RangeSet<E extends Comparab
* documented in the {@link #subSet(Range, Range)} method, except that the upper
* endpoint is {@code null}.
*
- * @param lower Low endpoint (inclusive) of the tailSet.
- * @return A view of the specified final range of this sorted set.
+ * @param lower low endpoint (inclusive) of the tailSet.
+ * @return a view of the specified final range of this sorted set.
*
* @see #intersect(Range)
*/
@@ -1015,7 +1016,7 @@ public class RangeSet<E extends Comparab
/**
* Creates a new subset of the enclosing {@code RangeSet} between the given values.
*
- * @param subRange The range to intersect with the enclosing {@code RangeSet}.
+ * @param subRange the range to intersect with the enclosing {@code RangeSet}.
*/
SubSet(final Range<E> subRange) {
this.subRange = subRange;
@@ -1384,8 +1385,8 @@ public class RangeSet<E extends Comparab
* If the specified value is inside a range, returns the index of this range.
* Otherwise, returns {@code -1}.
*
- * @param value The value to search.
- * @return The index of the range which contains this value, or -1 if there is no such range.
+ * @param value the value to search.
+ * @return the index of the range which contains this value, or -1 if there is no such range.
*/
public int indexOfRange(final E value) {
int index = binarySearch(value, 0, length);
@@ -1410,8 +1411,8 @@ public class RangeSet<E extends Comparab
* exclusive. The returned values always increase with {@code index}.
* Widening conversions are performed as needed.
*
- * @param index The range index, from 0 inclusive to {@link #size() size} exclusive.
- * @return The minimum value for the range at the specified index, inclusive.
+ * @param index the range index, from 0 inclusive to {@link #size() size} exclusive.
+ * @return the minimum value for the range at the specified index, inclusive.
* @throws IndexOutOfBoundsException if {@code index} is out of bounds.
* @throws ClassCastException if range elements are not convertible to {@code long}.
*/
@@ -1428,8 +1429,8 @@ public class RangeSet<E extends Comparab
* exclusive. The returned values always increase with {@code index}.
* Widening conversions are performed as needed.
*
- * @param index The range index, from 0 inclusive to {@link #size() size} exclusive.
- * @return The minimum value for the range at the specified index, inclusive.
+ * @param index the range index, from 0 inclusive to {@link #size() size} exclusive.
+ * @return the minimum value for the range at the specified index, inclusive.
* @throws IndexOutOfBoundsException if {@code index} is out of bounds.
* @throws ClassCastException if range elements are not convertible to numbers.
*
@@ -1448,8 +1449,8 @@ public class RangeSet<E extends Comparab
* exclusive. The returned values always increase with {@code index}.
* Widening conversions are performed as needed.
*
- * @param index The range index, from 0 inclusive to {@link #size() size} exclusive.
- * @return The maximum value for the range at the specified index, inclusive.
+ * @param index the range index, from 0 inclusive to {@link #size() size} exclusive.
+ * @return the maximum value for the range at the specified index, inclusive.
* @throws IndexOutOfBoundsException if {@code index} is out of bounds.
* @throws ClassCastException if range elements are not convertible to {@code long}.
*/
@@ -1466,8 +1467,8 @@ public class RangeSet<E extends Comparab
* exclusive. The returned values always increase with {@code index}.
* Widening conversions are performed as needed.
*
- * @param index The range index, from 0 inclusive to {@link #size size} exclusive.
- * @return The maximum value for the range at the specified index, exclusive.
+ * @param index the range index, from 0 inclusive to {@link #size size} exclusive.
+ * @return the maximum value for the range at the specified index, exclusive.
* @throws IndexOutOfBoundsException if {@code index} is out of bounds.
* @throws ClassCastException if range elements are not convertible to numbers.
*
@@ -1493,7 +1494,7 @@ public class RangeSet<E extends Comparab
* Returns the range at the given array index. The given index is relative to
* the interval {@link #array}, which is twice the index of range elements.
*
- * @param index The range index, from 0 inclusive to {@link #length} exclusive.
+ * @param index the range index, from 0 inclusive to {@link #length} exclusive.
*/
final Range<E> getRange(final int index) {
return newRange(getValue(index), getValue(index+1));
@@ -1502,9 +1503,9 @@ public class RangeSet<E extends Comparab
/**
* Returns a new {@link Range} object initialized with the given values.
*
- * @param lower The lower value, inclusive.
- * @param upper The upper value, exclusive.
- * @return The new range for the given values.
+ * @param lower the lower value, inclusive.
+ * @param upper the upper value, exclusive.
+ * @return the new range for the given values.
*/
protected Range<E> newRange(final E lower, final E upper) {
return new Range<>(elementType, lower, isMinIncluded, upper, isMaxIncluded);
@@ -1536,7 +1537,7 @@ public class RangeSet<E extends Comparab
/**
* Compares the specified object with this set of ranges for equality.
*
- * @param object The object to compare with this range.
+ * @param object the object to compare with this range.
* @return {@code true} if the given object is equal to this range.
*/
@Override
@@ -1572,13 +1573,13 @@ public class RangeSet<E extends Comparab
default: return Arrays.equals((Object[]) a1, (Object[]) a2);
}
}
- return super.equals(object); // Allow comparison with other Set implementations.
+ return super.equals(object); // Allow comparison with other Set implementations.
}
/**
* Returns a clone of this range set.
*
- * @return A clone of this range set.
+ * @return a clone of this range set.
*/
@Override
@SuppressWarnings("unchecked")
@@ -1598,8 +1599,8 @@ public class RangeSet<E extends Comparab
* Invoked before serialization. Trims the internal array to the minimal size
* in order to reduce the size of the object to be serialized.
*
- * @param out The output stream where to serialize this range set.
- * @throws IOException If an I/O error occurred while writing.
+ * @param out the output stream where to serialize this range set.
+ * @throws IOException if an I/O error occurred while writing.
*/
private void writeObject(final ObjectOutputStream out) throws IOException {
trimToSize();
@@ -1609,9 +1610,9 @@ public class RangeSet<E extends Comparab
/**
* Invoked after deserialization. Initializes the transient fields.
*
- * @param in The input stream from which to deserialize a range set.
- * @throws IOException If an I/O error occurred while reading or if the stream contains invalid data.
- * @throws ClassNotFoundException If the class serialized on the stream is not on the classpath.
+ * @param in the input stream from which to deserialize a range set.
+ * @throws IOException if an I/O error occurred while reading or if the stream contains invalid data.
+ * @throws ClassNotFoundException if the class serialized on the stream is not on the classpath.
*/
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/TableColumn.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -19,6 +19,7 @@ package org.apache.sis.util.collection;
import java.util.Map;
import java.util.Collections;
import java.io.Serializable;
+import java.io.ObjectStreamException;
import java.io.InvalidObjectException;
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
@@ -90,7 +91,7 @@ import org.apache.sis.util.resources.Voc
*
* The constants defined in this class use a similar approach for providing serialization support.
*
- * @param <V> Base type of all values in the column identified by this instance.
+ * @param <V> base type of all values in the column identified by this instance.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
@@ -180,7 +181,7 @@ public class TableColumn<V> implements C
* This implementation differs resource bundle loading until first needed,
* and resolves deserialized instances to the singleton instances.
*
- * @param <V> Base type of all values in the column identified by this instance.
+ * @param <V> base type of all values in the column identified by this instance.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
@@ -206,9 +207,9 @@ public class TableColumn<V> implements C
/**
* Creates a new instance for a build-in constant.
*
- * @param field The programmatic name of the static final field holding this constant.
- * @param type Base type of all values in the column identified by this instance.
- * @param header The resource key for the column header.
+ * @param field the programmatic name of the static final field holding this constant.
+ * @param type base type of all values in the column identified by this instance.
+ * @param header the resource key for the column header.
*/
Constant(final String field, final Class<V> type, final short header) {
super(type);
@@ -231,10 +232,10 @@ public class TableColumn<V> implements C
/**
* Invoked on deserialization for resolving this instance to one of the predefined constants.
*
- * @return One of the predefined constants.
- * @throws InvalidObjectException If this instance can not be resolved.
+ * @return one of the predefined constants.
+ * @throws InvalidObjectException if this instance can not be resolved.
*/
- private Object readResolve() throws InvalidObjectException {
+ private Object readResolve() throws ObjectStreamException {
try {
return TableColumn.class.getField(field).get(null);
} catch (ReflectiveOperationException cause) {
@@ -259,7 +260,7 @@ public class TableColumn<V> implements C
/**
* Creates a new instance for a build-in constant.
*
- * @param type Base type of all values in the column identified by this instance.
+ * @param type base type of all values in the column identified by this instance.
*/
TableColumn(final Class<V> type) {
this.type = type;
@@ -268,8 +269,8 @@ public class TableColumn<V> implements C
/**
* Creates a new instance for the given type of values.
*
- * @param type Base type of all values in the column identified by this instance.
- * @param header The text to display as column header.
+ * @param type base type of all values in the column identified by this instance.
+ * @param header the text to display as column header.
*/
public TableColumn(final Class<V> type, final CharSequence header) {
ArgumentChecks.ensureNonNull("type", this.type = type);
@@ -279,7 +280,7 @@ public class TableColumn<V> implements C
/**
* Returns the text to display as column header.
*
- * @return The text to display as column header.
+ * @return the text to display as column header.
*/
public synchronized InternationalString getHeader() {
final InternationalString i18n = Types.toInternationalString(header);
@@ -288,8 +289,7 @@ public class TableColumn<V> implements C
}
/**
- * Returns the base type of all values in any column identified by this {@code TableColumn}
- * instance.
+ * Returns the base type of all values in any column identified by this {@code TableColumn} instance.
*/
@Override
public final Class<V> getElementType() {
@@ -298,8 +298,7 @@ public class TableColumn<V> implements C
/**
* Returns a string representation of this table column.
- * The default implementation returns the {@linkplain #getHeader() header}
- * in its default locale.
+ * The default implementation returns the {@linkplain #getHeader() header} in its default locale.
*/
@Override
public String toString() {
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -19,6 +19,8 @@ package org.apache.sis.util.iso;
import java.util.List;
import java.util.Collections;
import java.util.Locale;
+import java.util.Objects;
+import java.io.ObjectStreamException;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@@ -32,9 +34,6 @@ import org.apache.sis.xml.Namespaces;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.internal.jaxb.gco.CharSequenceAdapter;
-// Branch-dependent imports
-import java.util.Objects;
-
/**
* Identifier within a {@linkplain DefaultNameSpace name space} for a local object.
@@ -107,8 +106,8 @@ public class DefaultLocalName extends Ab
* method will be invoked for fetching an unlocalized name.
* Otherwise the {@link CharSequence#toString()} method will be used.
*
- * @param scope The scope of this name, or {@code null} for a global scope.
- * @param name The local name (never {@code null}).
+ * @param scope the scope of this name, or {@code null} for a global scope.
+ * @param name the local name (never {@code null}).
*/
protected DefaultLocalName(NameSpace scope, final CharSequence name) {
ArgumentChecks.ensureNonNull("name", name);
@@ -158,8 +157,8 @@ public class DefaultLocalName extends Ab
* with the same values than the given name.</li>
* </ul>
*
- * @param object The object to get as a SIS implementation, or {@code null} if none.
- * @return A SIS implementation containing the values of the given object (may be the
+ * @param object the object to get as a SIS implementation, or {@code null} if none.
+ * @return a SIS implementation containing the values of the given object (may be the
* given object itself), or {@code null} if the argument was null.
*/
public static DefaultLocalName castOrCopy(final LocalName object) {
@@ -233,7 +232,7 @@ public class DefaultLocalName extends Ab
* This string does not include the scope, which is consistent with the
* {@linkplain #getParsedNames() parsed names} definition.
*
- * @return A local-independent string representation of this name.
+ * @return a local-independent string representation of this name.
*/
@Override
public synchronized String toString() {
@@ -265,7 +264,7 @@ public class DefaultLocalName extends Ab
* zero, or a positive integer as this name lexicographically precedes, is equal to,
* or follows the specified object.
*
- * @param name The other name to compare with this name.
+ * @param name the other name to compare with this name.
* @return -1 if this name precedes the given one, +1 if it follows, 0 if equals.
*/
@Override
@@ -287,7 +286,7 @@ public class DefaultLocalName extends Ab
/**
* Compares this local name with the specified object for equality.
*
- * @param object The object to compare with this name for equality.
+ * @param object the object to compare with this name for equality.
* @return {@code true} if the given object is equal to this name.
*/
@Override
@@ -318,9 +317,10 @@ public class DefaultLocalName extends Ab
* deserialized class is a subclass. This is the intended behavior since we don't want
* to replace an instance of a user-defined class.</p>
*
- * @return The unique instance.
+ * @return the unique instance.
+ * @throws ObjectStreamException required by specification but should never be thrown.
*/
- private Object readResolve() {
+ private Object readResolve() throws ObjectStreamException {
final DefaultNameSpace ns;
if (scope == null) { // Not a bug: readResolve() is intentionally private.
ns = GlobalNameSpace.GLOBAL;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultNameSpace.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -20,7 +20,9 @@ import java.util.Map;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
+import java.util.Objects;
import java.io.Serializable;
+import java.io.ObjectStreamException;
import org.opengis.util.NameSpace;
import org.opengis.util.LocalName;
import org.opengis.util.ScopedName;
@@ -32,9 +34,6 @@ import org.apache.sis.internal.util.Unmo
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
-// Branch-dependent imports
-import java.util.Objects;
-
/**
* A domain in which {@linkplain AbstractName names} given by character strings are defined.
@@ -144,15 +143,15 @@ public class DefaultNameSpace implements
* Creates a new namespace with the given separator.
*
* @param parent
- * The parent namespace, or {@code null} if none.
+ * the parent namespace, or {@code null} if none.
* @param name
- * The name of the new namespace, usually as a {@link String}
+ * the name of the new namespace, usually as a {@link String}
* or an {@link InternationalString}.
* @param headSeparator
- * The separator to insert between the namespace and the
+ * the separator to insert between the namespace and the
* {@linkplain AbstractName#head() head} of any name in that namespace.
* @param separator
- * The separator to insert between the {@linkplain AbstractName#getParsedNames()
+ * the separator to insert between the {@linkplain AbstractName#getParsedNames()
* parsed names} of any name in that namespace.
*/
protected DefaultNameSpace(final DefaultNameSpace parent, CharSequence name,
@@ -182,8 +181,8 @@ public class DefaultNameSpace implements
* Wraps the given namespace in a {@code DefaultNameSpace} implementation.
* This method returns an existing instance when possible.
*
- * @param ns The namespace to wrap, or {@code null} for the global one.
- * @return The given namespace as a {@code DefaultNameSpace} implementation.
+ * @param ns the namespace to wrap, or {@code null} for the global one.
+ * @return the given namespace as a {@code DefaultNameSpace} implementation.
*/
static DefaultNameSpace castOrCopy(final NameSpace ns) {
if (ns == null) {
@@ -200,14 +199,14 @@ public class DefaultNameSpace implements
* This method returns an existing instance when possible.
*
* @param name
- * The name for the namespace to obtain, or {@code null}.
+ * the name for the namespace to obtain, or {@code null}.
* @param headSeparator
- * The separator to insert between the namespace and the
+ * the separator to insert between the namespace and the
* {@linkplain AbstractName#head() head} of any name in that namespace.
* @param separator
- * The separator to insert between the {@linkplain AbstractName#getParsedNames()
+ * the separator to insert between the {@linkplain AbstractName#getParsedNames()
* parsed names} of any name in that namespace.
- * @return A namespace having the given name, or {@code null} if name was null.
+ * @return a namespace having the given name, or {@code null} if name was null.
*/
static DefaultNameSpace forName(final GenericName name, final String headSeparator, final String separator) {
if (name == null) {
@@ -262,8 +261,8 @@ public class DefaultNameSpace implements
/**
* Returns the depth of the given namespace.
*
- * @param ns The namespace for which to get the depth, or {@code null}.
- * @return The depth of the given namespace.
+ * @param ns the namespace for which to get the depth, or {@code null}.
+ * @return the depth of the given namespace.
*/
private static int depth(DefaultNameSpace ns) {
int depth = 0;
@@ -283,7 +282,7 @@ public class DefaultNameSpace implements
* assert name.scope().isGlobal() == true;
* }
*
- * @return The identifier of this namespace.
+ * @return the identifier of this namespace.
*/
@Override
public GenericName name() {
@@ -344,8 +343,8 @@ public class DefaultNameSpace implements
* the head separator is {@code "://"} for {@code "www"} (which is having this namespace),
* but it is {@code "."} for all children ({@code "opengeospatial"} and {@code "org"}).</p>
*
- * @param name The name of the child namespace.
- * @return The child namespace. It may be an existing instance.
+ * @param name the name of the child namespace.
+ * @return the child namespace. It may be an existing instance.
*/
final DefaultNameSpace child(final CharSequence name) {
return child(key(name), name, separator, separator);
@@ -355,8 +354,8 @@ public class DefaultNameSpace implements
* Returns a key to be used in the {@linkplain #childs} pool from the given name.
* The key must be the unlocalized version of the given string.
*
- * @param name The name.
- * @return A key from the given name.
+ * @param name the name.
+ * @return a key from the given name.
*/
private static String key(final CharSequence name) {
return (name instanceof InternationalString) ?
@@ -368,16 +367,16 @@ public class DefaultNameSpace implements
* The returned namespace will have this namespace as its parent.
*
* @param key
- * The unlocalized name of the child namespace, to be used as a key in the cache.
+ * the unlocalized name of the child namespace, to be used as a key in the cache.
* @param name
- * The name of the child namespace, or {@code null} if same than key.
+ * the name of the child namespace, or {@code null} if same than key.
* @param headSeparator
- * The separator to insert between the namespace and the
+ * the separator to insert between the namespace and the
* {@linkplain AbstractName#head() head} of any name in that namespace.
* @param separator
- * The separator to insert between the {@linkplain AbstractName#getParsedNames()
+ * the separator to insert between the {@linkplain AbstractName#getParsedNames()
* parsed names} of any name in that namespace.
- * @return The child namespace. It may be an existing instance.
+ * @return the child namespace. It may be an existing instance.
*/
private DefaultNameSpace child(final String key, CharSequence name,
final String headSeparator, final String separator)
@@ -419,10 +418,9 @@ public class DefaultNameSpace implements
* namespace as its {@linkplain DefaultLocalName#scope() scope}. This method may returns
* an existing instance on a "best effort" basis, but this is not guaranteed.
*
- * @param name The name of the instance to create.
- * @param candidate The instance to cache if no instance was found for the given name,
- * or {@code null} if none.
- * @return A name which is local in this namespace.
+ * @param name the name of the instance to create.
+ * @param candidate the instance to cache if no instance was found for the given name, or {@code null} if none.
+ * @return a name which is local in this namespace.
*/
final DefaultLocalName local(final CharSequence name, final DefaultLocalName candidate) {
ensureNonNull("name", name);
@@ -474,7 +472,7 @@ public class DefaultNameSpace implements
* {@link NameSpace} contract. This implementation follows the JCR convention for debugging convenience,
* but applications needing better guarantees should use {@link Names#toExpandedString(GenericName)} instead.
*
- * @return A JCR-like lexical form of this namespace.
+ * @return a JCR-like lexical form of this namespace.
*
* @see Names#toExpandedString(GenericName)
*/
@@ -487,7 +485,7 @@ public class DefaultNameSpace implements
/**
* Returns {@code true} if this namespace is equal to the given object.
*
- * @param object The object to compare with this namespace.
+ * @param object the object to compare with this namespace.
* @return {@code true} if the given object is equal to this namespace.
*/
@Override
@@ -502,7 +500,7 @@ public class DefaultNameSpace implements
/**
* Returns {@code true} if the namespace is equal to the given one, ignoring the parent.
*
- * @param that The namespace to compare with this one.
+ * @param that the namespace to compare with this one.
* @return {@code true} if both namespaces are equal, ignoring the parent.
*/
private boolean equalsIgnoreParent(final DefaultNameSpace that) {
@@ -527,9 +525,10 @@ public class DefaultNameSpace implements
* the deserialized class is a subclass defined in an other package. This is the intended
* behavior since we don't want to replace an instance of a user-defined class.</p>
*
- * @return The unique instance.
+ * @return the unique instance.
+ * @throws ObjectStreamException required by specification but should never be thrown.
*/
- Object readResolve() {
+ Object readResolve() throws ObjectStreamException {
final DefaultNameSpace p = parent();
final String key = key(name);
final WeakValueHashMap<String,Object> pool = p.childs;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/GlobalNameSpace.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/GlobalNameSpace.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/GlobalNameSpace.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/GlobalNameSpace.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -16,6 +16,8 @@
*/
package org.apache.sis.util.iso;
+import java.io.ObjectStreamException;
+
/**
* The global namespace. Only one instance of this class is allowed to exists. We do not expose
@@ -58,10 +60,10 @@ final class GlobalNameSpace extends Defa
/**
* Returns the unique instance of global name space on deserialization.
*
- * @return The unique instance.
+ * @return the unique instance.
*/
@Override
- Object readResolve() {
+ Object readResolve() throws ObjectStreamException {
return GLOBAL;
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -735,7 +735,7 @@ public final class Errors extends Indexe
public static final short UnexpectedChange_1 = 128;
/**
- * The \u201c{1}\u201d characters after \u201c{0}\u201d was unexpected.
+ * The \u201c{1}\u201d characters after \u201c{0}\u201d were unexpected.
*/
public static final short UnexpectedCharactersAfter_2 = 129;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Sat Dec 10 17:46:11 2016
@@ -158,7 +158,7 @@ TreeDepthExceedsMaximum = Tree
UndefinedOrderingForElements_2 = Ordering between \u201c{0}\u201d and \u201c{1}\u201d elements is undefined.
UnexpectedArrayLength_2 = Expected an array of length {0}, but got {1}.
UnexpectedChange_1 = Unexpected change in \u2018{0}\u2019.
-UnexpectedCharactersAfter_2 = The \u201c{1}\u201d characters after \u201c{0}\u201d was unexpected.
+UnexpectedCharactersAfter_2 = The \u201c{1}\u201d characters after \u201c{0}\u201d were unexpected.
UnexpectedCharactersAtBound_4 = Text for \u2018{0}\u2019 was expected to {1,choice,0#begin|1#end} with \u201c{2}\u201d, but found \u201c{3}\u201d.
UnexpectedEndOfFile_1 = Unexpected end of file while reading \u201c{0}\u201d.
UnexpectedEndOfString_1 = More characters were expected at the end of \u201c{0}\u201d.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilInternationalString.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilInternationalString.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilInternationalString.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilInternationalString.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -18,6 +18,7 @@ package org.apache.sis.xml;
import java.util.Locale;
import java.io.Serializable;
+import java.io.ObjectStreamException;
import org.opengis.util.InternationalString;
import org.apache.sis.util.resources.Errors;
@@ -116,7 +117,7 @@ final class NilInternationalString imple
/**
* Invoked on deserialization for replacing the deserialized instance by the unique instance.
*/
- private Object readResolve() {
+ private Object readResolve() throws ObjectStreamException {
return reason.createNilObject(InternationalString.class);
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/NilReason.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -20,6 +20,7 @@ import java.util.Map;
import java.net.URI;
import java.net.URISyntaxException;
import java.io.Serializable;
+import java.io.ObjectStreamException;
import java.lang.reflect.Proxy;
import java.lang.reflect.InvocationHandler;
import org.opengis.util.InternationalString;
@@ -174,7 +175,7 @@ public final class NilReason implements
* defined in this class, in declaration order. All other elements are the instances
* created by the {@link #valueOf(String)} method, in no particular order.
*
- * @return An array containing the instances of {@code NilReason}.
+ * @return an array containing the instances of {@code NilReason}.
*/
public static NilReason[] values() {
final int predefinedCount = PREDEFINED.length;
@@ -219,9 +220,9 @@ public final class NilReason implements
*
* This method returns existing instances when possible.
*
- * @param reason The reason why an element is not present.
- * @return The reason as a {@code NilReason} object.
- * @throws URISyntaxException If the given string is not one of the predefined enumeration
+ * @param reason the reason why an element is not present.
+ * @return the reason as a {@code NilReason} object.
+ * @throws URISyntaxException if the given string is not one of the predefined enumeration
* values and can not be parsed as a URI.
*/
public static NilReason valueOf(String reason) throws URISyntaxException {
@@ -262,9 +263,10 @@ public final class NilReason implements
/**
* Invoked after deserialization in order to return a unique instance if possible.
*
- * @return A unique instance of the deserialized {@code NilReason}.
+ * @return a unique instance of the deserialized {@code NilReason}.
+ * @throws ObjectStreamException required by specification but should never be thrown.
*/
- private Object readResolve() {
+ private Object readResolve() throws ObjectStreamException {
if (reason instanceof String) {
for (final NilReason candidate : PREDEFINED) {
if (reason.equals(candidate.reason)) {
@@ -284,7 +286,7 @@ public final class NilReason implements
* instance itself, then this method returns an empty string. For all other cases, the
* string contains at least two characters.</p>
*
- * @return The explanation, or {@code null} if this {@code NilReason} is not of kind {@link #OTHER}.
+ * @return the explanation, or {@code null} if this {@code NilReason} is not of kind {@link #OTHER}.
*/
public String getOtherExplanation() {
if (reason instanceof String) {
@@ -305,8 +307,7 @@ public final class NilReason implements
* Otherwise returns {@code null}. The URI and the {@linkplain #getOtherExplanation() other
* explanation} attributes are mutually exclusive.
*
- * @return The URI, or {@code null} if the explanation of this {@code NilReason}
- * is not referenced by a URI.
+ * @return the URI, or {@code null} if the explanation of this {@code NilReason} is not referenced by a URI.
*/
public URI getURI() {
return (reason instanceof URI) ? (URI) reason : null;
@@ -318,7 +319,7 @@ public final class NilReason implements
* is one of the predefined constants, or a string of the form {@code "other:explanation"},
* or a URI.
*
- * @return The GML string representation of this {@code NilReason}.
+ * @return the GML string representation of this {@code NilReason}.
*/
@Override
public String toString() {
@@ -336,7 +337,7 @@ public final class NilReason implements
/**
* Compares this {@code NilReason} with the specified object for equality.
*
- * @param other The object to compare with this {@code NilReason}.
+ * @param other the object to compare with this {@code NilReason}.
*/
@Override
public boolean equals(final Object other) {
@@ -366,11 +367,11 @@ public final class NilReason implements
* will be recognized as "nil" by the XML marshaller.</li>
* </ul>
*
- * @param <T> The compile-time type of the {@code type} argument.
- * @param type The object type as an <strong>interface</strong>
+ * @param <T> the compile-time type of the {@code type} argument.
+ * @param type the object type as an <strong>interface</strong>
* (usually a <a href="http://www.geoapi.org">GeoAPI</a> one) or one of the special types.
- * @throws IllegalArgumentException If the given type is not a supported type.
- * @return An {@link NilObject} of the given type.
+ * @throws IllegalArgumentException if the given type is not a supported type.
+ * @return an {@link NilObject} of the given type.
*/
@SuppressWarnings("unchecked")
public synchronized <T> T createNilObject(final Class<T> type) {
@@ -440,9 +441,9 @@ public final class NilReason implements
* probably still use a {@link String} where the string contain 1 or 2 Java characters. This may also facilitate the
* encoding in the XML files, since many files use an other encoding than UTF-16 anyway.</div>
*
- * @throws IllegalArgumentException If the given type is not a supported type.
+ * @throws IllegalArgumentException if the given type is not a supported type.
*/
- @SuppressWarnings({"RedundantStringConstructorCall", "BooleanConstructorCall"})
+ @SuppressWarnings({"RedundantStringConstructorCall", "BooleanConstructorCall", "UnnecessaryBoxing"})
private static Object createNilPrimitive(final Class<?> type) {
if (type == String .class) return new String(""); // REALLY need a new instance.
if (type == Boolean.class) return new Boolean(false); // REALLY need a new instance, not Boolean.FALSE.
@@ -491,9 +492,8 @@ public final class NilReason implements
* <li>Otherwise this method returns {@code null}.</li>
* </ul>
*
- * @param object The object for which to get the {@code NilReason}, or {@code null}.
- * @return The reason why the given object contains no information,
- * or {@code null} if the given object is not nil.
+ * @param object the object for which to get the {@code NilReason}, or {@code null}.
+ * @return the reason why the given object contains no information, or {@code null} if the given object is not nil.
*
* @see NilObject#getNilReason()
*
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/XPathsTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/XPathsTest.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/XPathsTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/XPathsTest.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -27,11 +27,24 @@ import static org.junit.Assert.*;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.8
* @module
*/
public final strictfp class XPathsTest extends TestCase {
/**
+ * Tests the {@link XPaths#endOfURI(CharSequence, int)} method.
+ *
+ * @since 0.8
+ */
+ @Test
+ public void testEndOfURI() {
+ assertEquals(26, XPaths.endOfURI("urn:ogc:def:uom:EPSG::9001", 0));
+ assertEquals(97, XPaths.endOfURI("http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])", 0));
+ assertEquals(-1, XPaths.endOfURI("m/s", 0));
+ assertEquals(-1, XPaths.endOfURI("m.s", 0));
+ }
+
+ /**
* Tests {@link XPaths#xpointer(String, String)}.
*/
@Test
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/RangeFormatTest.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -225,9 +225,9 @@ public final strictfp class RangeFormatT
assertEquals(NumberRange.create(-10, true, 20, true ), parse("[-10 \u2026 20]" ));
assertEquals(NumberRange.create( -3, false, 4, false), parse("( -3 \u2026 4) "));
- assertEquals(NumberRange.create( 2, true, 8, false), parse(" [2 \u2026 8) _"));
- assertEquals(NumberRange.create( 40, false, 90, true ), parse(" (40 \u2026 90]_"));
- assertEquals(NumberRange.create(300, true, 300, true ), parse(" 300_"));
+ assertEquals(NumberRange.create( 2, true, 8, false), parse(" [2 \u2026 8) "));
+ assertEquals(NumberRange.create( 40, false, 90, true ), parse(" (40 \u2026 90]"));
+ assertEquals(NumberRange.create(300, true, 300, true ), parse(" 300 "));
assertEquals(NumberRange.create(300, true, 300, true ), parse("[300]"));
assertEquals(NumberRange.create(300, false, 300, false), parse("(300)"));
assertEquals(NumberRange.create(300, true, 300, true ), parse("{300}"));
@@ -349,4 +349,17 @@ public final strictfp class RangeFormatT
assertEquals(9, minPos.getEndIndex());
assertEquals(range, parse(text));
}
+
+ /**
+ * Tests {@link RangeFormat#clone()}.
+ */
+ @Test
+ public void testClone() {
+ final RangeFormat f1 = new RangeFormat(Locale.FRANCE);
+ f1.setElementPattern("#0.###", false);
+ final RangeFormat f2 = f1.clone();
+ f2.setElementPattern("#0.00#", false);
+ assertEquals("#0.###", f1.getElementPattern(false));
+ assertEquals("#0.00#", f2.getElementPattern(false));
+ }
}
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java?rev=1773531&r1=1773530&r2=1773531&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/measure/SystemUnitTest.java [UTF-8] Sat Dec 10 17:46:11 2016
@@ -60,7 +60,7 @@ public final strictfp class SystemUnitTe
for (final Field f : Units.class.getFields()) {
final Object value = f.get(null);
if (value instanceof SystemUnit<?>) {
- final ConventionalUnit<?>[] related = ((SystemUnit<?>) value).related;
+ final ConventionalUnit<?>[] related = ((SystemUnit<?>) value).related();
if (related != null) {
final String symbol = ((SystemUnit<?>) value).getSymbol();
for (final ConventionalUnit<?> r : related) {