From commits-return-8573-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Fri Dec 30 09:23:28 2016
Return-Path:
X-Original-To: apmail-sis-commits-archive@www.apache.org
Delivered-To: apmail-sis-commits-archive@www.apache.org
Received: from mail.apache.org (hermes.apache.org [140.211.11.3])
by minotaur.apache.org (Postfix) with SMTP id 63C1B19904
for ; Fri, 30 Dec 2016 09:23:28 +0000 (UTC)
Received: (qmail 40756 invoked by uid 500); 30 Dec 2016 09:23:28 -0000
Delivered-To: apmail-sis-commits-archive@sis.apache.org
Received: (qmail 40717 invoked by uid 500); 30 Dec 2016 09:23:28 -0000
Mailing-List: contact commits-help@sis.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: sis-dev@sis.apache.org
Delivered-To: mailing list commits@sis.apache.org
Received: (qmail 40703 invoked by uid 99); 30 Dec 2016 09:23:28 -0000
Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Dec 2016 09:23:28 +0000
Received: from svn01-us-west.apache.org (localhost [127.0.0.1])
by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 2CB6D3A1C1F
for ; Fri, 30 Dec 2016 09:23:27 +0000 (UTC)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: svn commit: r1776531 [2/4] - in /sis/branches/JDK8:
application/sis-console/src/main/java/org/apache/sis/console/
core/sis-feature/src/main/java/org/apache/sis/feature/
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata...
Date: Fri, 30 Dec 2016 09:23:26 -0000
To: commits@sis.apache.org
From: desruisseaux@apache.org
X-Mailer: svnmailer-1.0.9
Message-Id: <20161230092327.2CB6D3A1C1F@svn01-us-west.apache.org>
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -296,7 +296,7 @@ public class DefaultMathTransformFactory
*
*
*
- * @param methods The operation methods to use, stored by reference (not copied).
+ * @param methods the operation methods to use, stored by reference (not copied).
*/
public DefaultMathTransformFactory(final Iterable extends OperationMethod> methods) {
ArgumentChecks.ensureNonNull("methods", methods);
@@ -329,7 +329,7 @@ public class DefaultMathTransformFactory
* @param type {@linkplain SingleOperation}.class for fetching all operation methods,
* {@linkplain org.opengis.referencing.operation.Projection}.class for fetching
* only map projection methods, etc.
- * @return Methods available in this factory for coordinate operations of the given type.
+ * @return methods available in this factory for coordinate operations of the given type.
*
* @see #getDefaultParameters(String)
* @see #createParameterizedTransform(ParameterValueGroup, Context)
@@ -374,8 +374,8 @@ public class DefaultMathTransformFactory
* non-{@linkplain org.apache.sis.util.Deprecable#isDeprecated() deprecated} matching method is returned.
* If all matching methods are deprecated, the first one is returned.
*
- * @param identifier The name or identifier of the operation method to search.
- * @return The coordinate operation method for the given name or identifier.
+ * @param identifier the name or identifier of the operation method to search.
+ * @return the coordinate operation method for the given name or identifier.
* @throws NoSuchIdentifierException if there is no operation method registered for the specified identifier.
*
* @see org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory#getOperationMethod(String)
@@ -414,8 +414,8 @@ public class DefaultMathTransformFactory
* Parameters are intended to be modified by the user before to be given to the
* {@link #createParameterizedTransform createParameterizedTransform(…)} method.
*
- * @param method The case insensitive name of the coordinate operation method to search for.
- * @return A new group of parameter values for the {@code OperationMethod} identified by the given name.
+ * @param method the case insensitive name of the coordinate operation method to search for.
+ * @return a new group of parameter values for the {@code OperationMethod} identified by the given name.
* @throws NoSuchIdentifierException if there is no method registered for the given name or identifier.
*
* @see #getAvailableMethods(Class)
@@ -431,9 +431,9 @@ public class DefaultMathTransformFactory
* Creates a transform from a group of parameters.
* The set of expected parameters varies for each operation.
*
- * @param parameters The parameter values. The {@linkplain ParameterDescriptorGroup#getName() parameter group name}
+ * @param parameters the parameter values. The {@linkplain ParameterDescriptorGroup#getName() parameter group name}
* shall be the name of the desired {@linkplain DefaultOperationMethod operation method}.
- * @return The transform created from the given parameters.
+ * @return the transform created from the given parameters.
* @throws NoSuchIdentifierException if there is no method for the given parameter group name.
* @throws FactoryException if the object creation failed. This exception is thrown
* if some required parameter has not been supplied, or has illegal value.
@@ -514,7 +514,7 @@ public class DefaultMathTransformFactory
* Sets the source coordinate system to the given value.
* The source ellipsoid is unconditionally set to {@code null}.
*
- * @param cs The coordinate system to set as the source (can be {@code null}).
+ * @param cs the coordinate system to set as the source (can be {@code null}).
*/
public void setSource(final CoordinateSystem cs) {
sourceCS = cs;
@@ -533,8 +533,8 @@ public class DefaultMathTransformFactory
* of prime meridian), see {@link org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory}.
* This policy helps to enforce a separation of concerns.
*
- * @param cs The coordinate system to set as the source, or {@code null}.
- * @param ellipsoid The ellipsoid associated to the given coordinate system, or {@code null}.
+ * @param cs the coordinate system to set as the source, or {@code null}.
+ * @param ellipsoid the ellipsoid associated to the given coordinate system, or {@code null}.
*/
public void setSource(final EllipsoidalCS cs, final Ellipsoid ellipsoid) {
sourceCS = cs;
@@ -545,7 +545,7 @@ public class DefaultMathTransformFactory
* Sets the target coordinate system to the given value.
* The target ellipsoid is unconditionally set to {@code null}.
*
- * @param cs The coordinate system to set as the target (can be {@code null}).
+ * @param cs the coordinate system to set as the target (can be {@code null}).
*/
public void setTarget(final CoordinateSystem cs) {
targetCS = cs;
@@ -558,8 +558,8 @@ public class DefaultMathTransformFactory
*
Design note:
* see {@link #setSource(EllipsoidalCS, Ellipsoid)}.
*
- * @param cs The coordinate system to set as the source, or {@code null}.
- * @param ellipsoid The ellipsoid associated to the given coordinate system, or {@code null}.
+ * @param cs the coordinate system to set as the source, or {@code null}.
+ * @param ellipsoid the ellipsoid associated to the given coordinate system, or {@code null}.
*/
public void setTarget(final EllipsoidalCS cs, final Ellipsoid ellipsoid) {
targetCS = cs;
@@ -569,7 +569,7 @@ public class DefaultMathTransformFactory
/**
* Returns the source coordinate system, or {@code null} if unspecified.
*
- * @return The source coordinate system, or {@code null}.
+ * @return the source coordinate system, or {@code null}.
*/
public CoordinateSystem getSourceCS() {
return sourceCS;
@@ -588,7 +588,7 @@ public class DefaultMathTransformFactory
/**
* Returns the target coordinate system, or {@code null} if unspecified.
*
- * @return The target coordinate system, or {@code null}.
+ * @return the target coordinate system, or {@code null}.
*/
public CoordinateSystem getTargetCS() {
return targetCS;
@@ -630,8 +630,8 @@ public class DefaultMathTransformFactory
* This method is invoked by {@link DefaultMathTransformFactory#swapAndScaleAxes(MathTransform, Context)}.
* Users an override this method if they need to customize the normalization process.
*
- * @param role Whether the normalization or denormalization matrix is desired.
- * @return The requested matrix, or {@code null} if this {@code Context} has no information about the coordinate system.
+ * @param role whether the normalization or denormalization matrix is desired.
+ * @return the requested matrix, or {@code null} if this {@code Context} has no information about the coordinate system.
* @throws FactoryException if an error occurred while computing the matrix.
*
* @see DefaultMathTransformFactory#createAffineTransform(Matrix)
@@ -668,7 +668,7 @@ public class DefaultMathTransformFactory
* Returns the parameter values used for the math transform creation, including the parameters completed
* by the factory.
*
- * @return The parameter values used by the factory.
+ * @return the parameter values used by the factory.
* @throws IllegalStateException if {@link DefaultMathTransformFactory#createParameterizedTransform(ParameterValueGroup, Context)}
* has not yet been invoked.
*/
@@ -689,9 +689,9 @@ public class DefaultMathTransformFactory
* parameter value validity. This may result in an {@link InvalidParameterNameException}
* or {@link InvalidParameterValueException} to be thrown.
*
- * @param writable {@code true} if this method should also check that the parameters group is not
- * an instance of {@link UnmodifiableParameterValueGroup}. Current implementation assumes
- * that modifiable parameters are instances of {@link DefaultParameterValueGroup}.
+ * @param writable {@code true} if this method should also check that the parameters group is not
+ * an instance of {@link UnmodifiableParameterValueGroup}. Current implementation assumes
+ * that modifiable parameters are instances of {@link DefaultParameterValueGroup}.
* @throws IllegalArgumentException if the copy can not be performed because a parameter has
* a unrecognized name or an illegal value.
*/
@@ -726,11 +726,11 @@ public class DefaultMathTransformFactory
* but its value is compared to the given one for consistency.
*
*
- * @param parameter The parameter which must have a value.
- * @param actual The current parameter value, or {@code NaN} if none.
- * @param expected The expected parameter value, derived from the ellipsoid.
- * @param unit The unit of {@code value}.
- * @param tolerance Maximal difference (in unit of {@code unit}) for considering the two values as equivalent.
+ * @param parameter the parameter which must have a value.
+ * @param actual the current parameter value, or {@code NaN} if none.
+ * @param expected the expected parameter value, derived from the ellipsoid.
+ * @param unit the unit of {@code value}.
+ * @param tolerance maximal difference (in unit of {@code unit}) for considering the two values as equivalent.
* @return {@code true} if there is a mismatch between the actual value and the expected one.
*/
private static boolean ensureSet(final ParameterValue> parameter, final double actual,
@@ -751,11 +751,11 @@ public class DefaultMathTransformFactory
* if available. This method writes semi-major and semi-minor parameter values only if they do not
* already exists in the given parameters.
*
- * @param ellipsoid The ellipsoid from which to get axis lengths of flattening factor, or {@code null}.
+ * @param ellipsoid the ellipsoid from which to get axis lengths of flattening factor, or {@code null}.
* @param semiMajor {@code "semi_major}, {@code "src_semi_major} or {@code "tgt_semi_major} parameter name.
* @param semiMinor {@code "semi_minor}, {@code "src_semi_minor} or {@code "tgt_semi_minor} parameter name.
* @param inverseFlattening {@code true} if this method can try to set the {@code "inverse_flattening"} parameter.
- * @return The exception if the operation failed, or {@code null} if none. This exception is not thrown now
+ * @return the exception if the operation failed, or {@code null} if none. This exception is not thrown now
* because the caller may succeed in creating the transform anyway, or otherwise may produce a more
* informative exception.
*/
@@ -847,8 +847,8 @@ public class DefaultMathTransformFactory
*
The given method and parameters are stored in the {@link #provider} and {@link #parameters}
* fields respectively. The actual stored values may differ from the values given to this method.
*
- * @param method Description of the transform to be created, or {@code null} if unknown.
- * @return The exception if the operation failed, or {@code null} if none. This exception is not thrown now
+ * @param method description of the transform to be created, or {@code null} if unknown.
+ * @return the exception if the operation failed, or {@code null} if none. This exception is not thrown now
* because the caller may succeed in creating the transform anyway, or otherwise may produce a more
* informative exception.
* @throws IllegalArgumentException if the operation fails because a parameter has a unrecognized name or an
@@ -959,11 +959,11 @@ public class DefaultMathTransformFactory
*
The {@code OperationMethod} instance used by this constructor can be obtained by a call to
* {@link #getLastMethodUsed()}.
*
- * @param parameters The parameter values. The {@linkplain ParameterDescriptorGroup#getName() parameter group name}
- * shall be the name of the desired {@linkplain DefaultOperationMethod operation method}.
- * @param context Information about the context (for example source and target coordinate systems)
- * in which the new transform is going to be used, or {@code null} if none.
- * @return The transform created from the given parameters.
+ * @param parameters the parameter values. The {@linkplain ParameterDescriptorGroup#getName() parameter group name}
+ * shall be the name of the desired {@linkplain DefaultOperationMethod operation method}.
+ * @param context information about the context (for example source and target coordinate systems)
+ * in which the new transform is going to be used, or {@code null} if none.
+ * @return the transform created from the given parameters.
* @throws NoSuchIdentifierException if there is no method for the given parameter group name.
* @throws FactoryException if the object creation failed. This exception is thrown
* if some required parameter has not been supplied, or has illegal value.
@@ -1076,9 +1076,9 @@ public class DefaultMathTransformFactory
* Users who need a different normalized space than the default one way find more convenient to
* override the {@link Context#getMatrix Context.getMatrix(ContextualParameters.MatrixRole)} method.
*
- * @param parameterized A transform for normalized input and output coordinates.
- * @param context Source and target coordinate systems in which the transform is going to be used.
- * @return A transform taking in account unit conversions and axis swapping.
+ * @param parameterized a transform for normalized input and output coordinates.
+ * @param context source and target coordinate systems in which the transform is going to be used.
+ * @return a transform taking in account unit conversions and axis swapping.
* @throws FactoryException if the object creation failed.
*
* @see org.apache.sis.referencing.cs.AxesConvention#NORMALIZED
@@ -1156,10 +1156,10 @@ public class DefaultMathTransformFactory
* allowing the caller to get back the complete parameter values.
* However this method only fills missing values, it never modify existing values.
*
- * @param baseCRS The source coordinate reference system.
- * @param parameters The parameter values for the transform.
- * @param derivedCS The target coordinate system.
- * @return The parameterized transform from {@code baseCRS} to {@code derivedCS},
+ * @param baseCRS the source coordinate reference system.
+ * @param parameters the parameter values for the transform.
+ * @param derivedCS the target coordinate system.
+ * @return the parameterized transform from {@code baseCRS} to {@code derivedCS},
* including unit conversions and axis swapping.
* @throws NoSuchIdentifierException if there is no transform registered for the coordinate operation method.
* @throws FactoryException if the object creation failed. This exception is thrown
@@ -1184,8 +1184,8 @@ public class DefaultMathTransformFactory
/**
* Creates a math transform that represent a change of coordinate system.
*
- * @param source the source coordinate system.
- * @param target the target coordinate system.
+ * @param source the source coordinate system.
+ * @param target the target coordinate system.
* @return a conversion from the given source to the given target coordinate system.
* @throws FactoryException if the conversion can not be created.
*
@@ -1208,8 +1208,8 @@ public class DefaultMathTransformFactory
* {@code [i][N]} element of the matrix will be 0 for i less than {@code M}, and 1
* for i equals {@code M}.
*
- * @param matrix The matrix used to define the affine transform.
- * @return The affine transform.
+ * @param matrix the matrix used to define the affine transform.
+ * @return the affine transform.
* @throws FactoryException if the object creation failed.
*
* @see MathTransforms#linear(Matrix)
@@ -1231,9 +1231,9 @@ public class DefaultMathTransformFactory
*
The dimension of the output space of the first transform must match the dimension of the input space
* in the second transform. In order to concatenate more than two transforms, use this constructor repeatedly.
*
- * @param tr1 The first transform to apply to points.
- * @param tr2 The second transform to apply to points.
- * @return The concatenated transform.
+ * @param tr1 the first transform to apply to points.
+ * @param tr2 the second transform to apply to points.
+ * @return the concatenated transform.
* @throws FactoryException if the object creation failed.
*
* @see MathTransforms#concatenate(MathTransform, MathTransform)
@@ -1272,11 +1272,11 @@ public class DefaultMathTransformFactory
* Target: firstAffectedOrdinate + subTransform.getTargetDimensions() + numTrailingOrdinates
* }
*
- * @param firstAffectedOrdinate The lowest index of the affected ordinates.
- * @param subTransform Transform to use for affected ordinates.
- * @param numTrailingOrdinates Number of trailing ordinates to pass through. Affected ordinates will range
+ * @param firstAffectedOrdinate the lowest index of the affected ordinates.
+ * @param subTransform transform to use for affected ordinates.
+ * @param numTrailingOrdinates number of trailing ordinates to pass through. Affected ordinates will range
* from {@code firstAffectedOrdinate} inclusive to {@code dimTarget-numTrailingOrdinates} exclusive.
- * @return A pass through transform.
+ * @return a pass through transform.
* @throws FactoryException if the object creation failed.
*/
@Override
@@ -1298,7 +1298,7 @@ public class DefaultMathTransformFactory
/**
* There is no XML format for math transforms.
*
- * @param xml Math transform encoded in XML format.
+ * @param xml math transform encoded in XML format.
* @throws FactoryException if the object creation failed.
*/
@Override
@@ -1313,8 +1313,8 @@ public class DefaultMathTransformFactory
* Well
* Known Text (WKT).
*
- * @param text Math transform encoded in Well-Known Text format.
- * @return The math transform (never {@code null}).
+ * @param text math transform encoded in Well-Known Text format.
+ * @return the math transform (never {@code null}).
* @throws FactoryException if the Well-Known Text can not be parsed,
* or if the math transform creation failed from some other reason.
*/
@@ -1355,7 +1355,7 @@ public class DefaultMathTransformFactory
Throwable cause = e.getCause();
while (cause != null) {
if (cause instanceof ParameterNotFoundException) {
- throw new InvalidGeodeticParameterException(e.getMessage(), cause); // More accurate exception.
+ throw new InvalidGeodeticParameterException(e.getLocalizedMessage(), cause);
}
cause = cause.getCause();
}
@@ -1379,7 +1379,7 @@ public class DefaultMathTransformFactory
*
Invoking {@code getLastMethodUsed()} can be useful after a call to
* {@link #createParameterizedTransform createParameterizedTransform(…)}.
*
- * @return The last method used by a {@code create(…)} constructor, or {@code null} if unknown of unsupported.
+ * @return the last method used by a {@code create(…)} constructor, or {@code null} if unknown of unsupported.
*
* @see #createParameterizedTransform(ParameterValueGroup, Context)
*/
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/report/CoordinateReferenceSystems.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -689,7 +689,7 @@ public final strictfp class CoordinateRe
row.remark = "Projected";
((ByName) row).setup(CommonCRS.WGS84.datum(), unusedDatumMapping);
} else {
- row.remark = exception.getMessage();
+ row.remark = exception.getLocalizedMessage();
((ByName) row).setup(null, unusedDatumMapping);
}
return row;
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -48,7 +48,7 @@ public final class TM_Primitive extends
/**
* Wraps a Temporal Primitive value at marshalling-time.
*
- * @param metadata The metadata value to marshal.
+ * @param metadata the metadata value to marshal.
*/
private TM_Primitive(final TemporalPrimitive metadata) {
super(metadata);
@@ -57,8 +57,8 @@ public final class TM_Primitive extends
/**
* Returns the Vertical CRS value wrapped by a temporal primitive element.
*
- * @param value The value to marshal.
- * @return The adapter which wraps the metadata value.
+ * @param value the value to marshal.
+ * @return the adapter which wraps the metadata value.
*/
@Override
protected TM_Primitive wrap(final TemporalPrimitive value) {
@@ -79,7 +79,7 @@ public final class TM_Primitive extends
* Returns the {@code TimePeriod} generated from the metadata value.
* This method is systematically called at marshalling-time by JAXB.
*
- * @return The time period, or {@code null}.
+ * @return the time period, or {@code null}.
*/
@XmlElement(name = "TimePeriod")
public TimePeriod getTimePeriod() {
@@ -91,7 +91,7 @@ public final class TM_Primitive extends
* Returns the {@link TimeInstant} generated from the metadata value.
* This method is systematically called at marshalling-time by JAXB.
*
- * @return The time instant, or {@code null}.
+ * @return the time instant, or {@code null}.
*/
@XmlElement(name = "TimeInstant")
public TimeInstant getTimeInstant() {
@@ -103,10 +103,10 @@ public final class TM_Primitive extends
* Sets the value from the {@link TimePeriod}.
* This method is called at unmarshalling-time by JAXB.
*
- * @param period The wrapper to set.
+ * @param period the wrapper to set.
*/
public void setTimePeriod(final TimePeriod period) {
- metadata = null; // Cleaned first in case of failure.
+ metadata = null; // Cleaned first in case of failure.
if (period != null) {
final Context context = Context.current();
final Date begin = toDate(context, period.begin);
@@ -135,10 +135,10 @@ public final class TM_Primitive extends
* Sets the value from the {@link TimeInstant}.
* This method is called at unmarshalling-time by JAXB.
*
- * @param instant The wrapper to set.
+ * @param instant the wrapper to set.
*/
public void setTimeInstant(final TimeInstant instant) {
- metadata = null; // Cleaned first in case of failure.
+ metadata = null; // Cleaned first in case of failure.
if (instant != null) {
final Date position = XmlUtilities.toDate(Context.current(), instant.timePosition);
if (position != null) try {
@@ -160,7 +160,7 @@ public final class TM_Primitive extends
/**
* Reports a warning for the given exception.
*
- * @param method The name of the method to declare in the log record.
+ * @param method the name of the method to declare in the log record.
* @param e the exception.
*/
private static void warningOccured(final String method, final Exception e) {
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -19,15 +19,16 @@ package org.apache.sis.internal.util;
import java.util.Locale;
import java.text.ParsePosition;
import java.text.ParseException;
+import org.opengis.util.InternationalString;
import org.apache.sis.util.Workaround;
-import org.apache.sis.util.Localized;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.util.LocalizedException;
/**
- * A {@link ParseException} in which {@link #getLocalizedMessage()} returns the message in the
- * parser locale. This exception contains the error message in two languages:
+ * A {@link ParseException} in which {@link #getLocalizedMessage()} returns the message in the parser locale.
+ * This exception contains the error message in two languages:
*
*
*
{@link ParseException#getMessage()} returns the message in the default locale.
@@ -40,21 +41,16 @@ import org.apache.sis.util.resources.Err
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.7
+ * @version 0.8
* @module
*/
-public final class LocalizedParseException extends ParseException implements LocalizedException, Localized {
+public final class LocalizedParseException extends ParseException implements LocalizedException {
/**
* For cross-version compatibility.
*/
private static final long serialVersionUID = -1467571540435486742L;
/**
- * The locale to use for formatting the localized error message, or {@code null} for the default.
- */
- private final Locale locale;
-
- /**
* The resources key as one of the {@code Errors.Keys} constant.
*/
private final short key;
@@ -65,8 +61,8 @@ public final class LocalizedParseExcepti
private final Object[] arguments;
/**
- * Constructs a {@code ParseException} with a message formatted from the given resource key
- * and message arguments. This is the most generic constructor.
+ * Constructs a {@code ParseException} with a message formatted from the given resource key and message arguments.
+ * This is the most generic constructor.
*
* @param locale the locale for {@link #getLocalizedMessage()}, or {@code null} for the default.
* @param key the resource key as one of the {@code Errors.Keys} constant.
@@ -74,16 +70,15 @@ public final class LocalizedParseExcepti
* @param errorOffset the position where the error is found while parsing.
*/
public LocalizedParseException(final Locale locale, final short key, final Object[] arguments, final int errorOffset) {
- super(Errors.format(key, arguments), errorOffset);
- this.locale = locale;
+ super(Errors.getResources(locale).getString(key, arguments), errorOffset);
this.arguments = arguments;
this.key = key;
}
/**
- * Constructs a {@code ParseException} with a message formatted from the given resource key
- * and unparsable string. This convenience constructor fetches the word starting at the error
- * index, and uses that word as the single argument associated to the resource key.
+ * Constructs a {@code ParseException} with a message formatted from the given resource key and unparsable string.
+ * This convenience constructor fetches the word starting at the error index,
+ * and uses that word as the single argument associated to the resource key.
*
* @param locale the locale for {@link #getLocalizedMessage()}, or {@code null} for the default.
* @param key the resource key as one of the {@code Errors.Keys} constant.
@@ -95,9 +90,9 @@ public final class LocalizedParseExcepti
}
/**
- * Creates a {@link ParseException} with a localized message built from the given parsing
- * information. This convenience constructor creates a message of the kind "Can not
- * parse string "text" as an object of type 'type'".
+ * Creates a {@link ParseException} with a localized message built from the given parsing information.
+ * This convenience constructor creates a message of the kind "Can not parse string "text" as an
+ * object of type 'type'".
*
* @param locale the locale for {@link #getLocalizedMessage()}, or {@code null} for the default.
* @param type the type of objects parsed by the {@link java.text.Format}.
@@ -170,26 +165,32 @@ public final class LocalizedParseExcepti
}
/**
- * {@inheritDoc}
+ * Returns the exception message in the default locale, typically for system administrator.
+ *
+ * @return the message of this exception.
*/
@Override
- public Locale getLocale() {
- return (locale != null) ? locale : Locale.getDefault();
+ public String getMessage() {
+ return Errors.format(key, arguments);
}
/**
- * {@inheritDoc}
+ * Returns a localized version of the exception message, typically for final user.
+ *
+ * @return the localized message of this exception.
*/
@Override
public String getLocalizedMessage() {
- return Errors.getResources(locale).getString(key, arguments);
+ return super.getMessage();
}
/**
- * {@inheritDoc}
+ * Return the message in various locales.
+ *
+ * @return the exception message.
*/
@Override
- public String getLocalizedMessage(final Locale locale) {
- return Errors.getResources(locale).getString(key, arguments);
+ public InternationalString getInternationalMessage() {
+ return Errors.formatInternational(key, arguments);
}
}
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/measure/Angle.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -88,7 +88,7 @@ public class Angle implements Comparable
/**
* Constructs a new angle with the specified value in decimal degrees.
*
- * @param θ Angle in decimal degrees.
+ * @param θ angle in decimal degrees.
*/
public Angle(final double θ) {
this.θ = θ;
@@ -103,16 +103,16 @@ public class Angle implements Comparable
* locale. Developers should consider using {@link AngleFormat} for end-user applications
* instead than this constructor.
*
- * @param string A string to be converted to an {@code Angle}.
+ * @param text a string to be converted to an {@code Angle}.
* @throws NumberFormatException if the string does not contain a parsable angle.
*
* @see AngleFormat#parse(String)
*/
- public Angle(final String string) throws NumberFormatException {
+ public Angle(final String text) throws NumberFormatException {
final Object angle;
try {
synchronized (Angle.class) {
- angle = getAngleFormat().parseObject(string);
+ angle = getAngleFormat().parseObject(text);
}
} catch (ParseException exception) {
/*
@@ -129,14 +129,14 @@ public class Angle implements Comparable
if (type == Angle.class || getClass().isAssignableFrom(type)) {
this.θ = ((Angle) angle).θ;
} else {
- throw new NumberFormatException(string);
+ throw new NumberFormatException(text);
}
}
/**
* Returns the angle value in decimal degrees.
*
- * @return The angle value in decimal degrees.
+ * @return the angle value in decimal degrees.
*/
public double degrees() {
return θ;
@@ -145,7 +145,7 @@ public class Angle implements Comparable
/**
* Returns the angle value in radians.
*
- * @return The angle value in radians.
+ * @return the angle value in radians.
*/
public double radians() {
return Math.toRadians(θ);
@@ -163,7 +163,7 @@ public class Angle implements Comparable
/**
* Compares the specified object with this angle for equality.
*
- * @param object The object to compare with this angle for equality.
+ * @param object the object to compare with this angle for equality.
* @return {@code true} if the given object is equal to this angle.
*/
@Override
@@ -181,7 +181,7 @@ public class Angle implements Comparable
* Compares two {@code Angle} objects numerically. The comparison
* is done as if by the {@link Double#compare(double, double)} method.
*
- * @param that The angle to compare with this object for order.
+ * @param that the angle to compare with this object for order.
* @return -1 if this angle is smaller than the given one, +1 if greater or 0 if equals.
*/
@Override
@@ -217,11 +217,11 @@ public class Angle implements Comparable
public String toString() {
StringBuffer buffer = new StringBuffer();
double m = Math.abs(θ);
- final boolean isSmall = m <= (1 / 3600E+3); // 1E-3 arc-second.
+ final boolean isSmall = m <= (1 / 3600E+3); // 1E-3 arc-second.
if (isSmall || m > maximum()) {
final char h = hemisphere(isNegative(θ));
if (h == 0) {
- m = θ; // Restore the sign.
+ m = θ; // Restore the sign.
}
char symbol = '°';
if (isSmall) {
@@ -273,10 +273,10 @@ public class Angle implements Comparable
*
Otherwise the precision, if positive, is given to {@link AngleFormat#setMaximumWidth(int)}.
*
*
- * @param formatter The formatter in which to format this angle.
- * @param flags {@link FormattableFlags#LEFT_JUSTIFY} for left alignment, or 0 for right alignment.
- * @param width Minimal number of characters to write, padding with {@code ' '} if necessary.
- * @param precision Maximal number of characters to write, or -1 if no limit.
+ * @param formatter the formatter in which to format this angle.
+ * @param flags {@link FormattableFlags#LEFT_JUSTIFY} for left alignment, or 0 for right alignment.
+ * @param width minimal number of characters to write, padding with {@code ' '} if necessary.
+ * @param precision maximal number of characters to write, or -1 if no limit.
*/
@Override
public void formatTo(final Formatter formatter, final int flags, final int width, final int precision) {
@@ -285,7 +285,7 @@ public class Angle implements Comparable
value = "";
} else {
final char h;
- int w = precision; // To be decremented only if we may truncate and an hemisphere symbol exist.
+ int w = precision; // To be decremented only if we may truncate and an hemisphere symbol exist.
if (w > 0 && (h = hemisphere(isNegative(θ))) != 0 && --w == 0) {
value = Character.toString(h);
} else {
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -164,7 +164,7 @@ public enum About {
* return configuration(EnumSet.allOf(About.class), null, null);
* }
*
- * @return Configuration information, as a tree for grouping some configuration by sections.
+ * @return configuration information, as a tree for grouping some configuration by sections.
*/
public static TreeTable configuration() {
return configuration(EnumSet.allOf(About.class), null, null);
@@ -173,10 +173,10 @@ public enum About {
/**
* Returns a subset of the information about the current Apache SIS running environment.
*
- * @param sections The section for which information are desired.
- * @param locale The locale to use for formatting the texts in the tree, or {@code null} for the default.
- * @param timezone The timezone to use for formatting the dates, or {@code null} for the default.
- * @return Configuration information, as a tree for grouping some configuration by sections.
+ * @param sections the section for which information are desired.
+ * @param locale the locale to use for formatting the texts in the tree, or {@code null} for the default.
+ * @param timezone the timezone to use for formatting the dates, or {@code null} for the default.
+ * @return configuration information, as a tree for grouping some configuration by sections.
*/
public static TreeTable configuration(final Set sections, Locale locale, final TimeZone timezone) {
ArgumentChecks.ensureNonNull("sections", sections);
@@ -499,9 +499,9 @@ pathTree: for (int j=0; ; j++) {
* Returns a map of all JAR files or class directories found in the given paths,
* associated to a description obtained from their {@code META-INF/MANIFEST.MF}.
*
- * @param paths The paths using the {@link File#pathSeparatorChar} separator.
- * @param asDirectories {@code true} if the paths are directories, or {@code false} for JAR files.
- * @return The paths, or {@code null} if none.
+ * @param paths the paths using the {@link File#pathSeparatorChar} separator.
+ * @param asDirectories {@code true} if the paths are directories, or {@code false} for JAR files.
+ * @return the paths, or {@code null} if none.
*/
private static Map classpath(final String paths, final boolean asDirectories) {
final Map files = new LinkedHashMap<>();
@@ -520,10 +520,10 @@ pathTree: for (int j=0; ; j++) {
* a {@code MANIFEST.MF} attribute using space as the path separator.
*
*
- * @param paths The paths using the separator described above.
- * @param directory The directory of {@code MANIFEST.MF} classpath, or {@code null}.
- * @param asDirectories {@code true} if the paths are directories, or {@code false} for JAR files.
- * @param files Where to add the paths.
+ * @param paths the paths using the separator described above.
+ * @param directory the directory of {@code MANIFEST.MF} classpath, or {@code null}.
+ * @param asDirectories {@code true} if the paths are directories, or {@code false} for JAR files.
+ * @param files where to add the paths.
* @return {@code true} if the given map has been changed as a result of this method call.
*/
private static boolean classpath(final String paths, final File directory,
@@ -650,9 +650,9 @@ pathTree: for (int j=0; ; j++) {
* In particular, note that this implementation assumes that children collections are {@link List} (this is
* guaranteed for {@link DefaultTreeTable.Node} implementations).
*
- * @param node The root of the node to simplify.
- * @param skip {@code true} for disabling concatenation of root node.
- * @return The root of the simplified tree. May be the given {@code node} or a child.
+ * @param node the root of the node to simplify.
+ * @param skip {@code true} for disabling concatenation of root node.
+ * @return the root of the simplified tree. May be the given {@code node} or a child.
*/
private static TreeTable.Node concatenateSingletons(final TreeTable.Node node, final boolean skip) {
// DefaultTreeTable.Node instances are known to handle their children in a List.
@@ -679,10 +679,10 @@ pathTree: for (int j=0; ; j++) {
* Concatenates the given strings in the format "main (complement)".
* Any of the given strings can be null.
*
- * @param main The main string to show first, or {@code null}.
- * @param complement The string to show after the main one, or {@code null}.
- * @param parenthesis {@code true} for writing the complement between parenthesis, or {@code null}.
- * @return The concatenated string, or {@code null} if all components are null.
+ * @param main the main string to show first, or {@code null}.
+ * @param complement the string to show after the main one, or {@code null}.
+ * @param parenthesis {@code true} for writing the complement between parenthesis, or {@code null}.
+ * @return the concatenated string, or {@code null} if all components are null.
*/
private static CharSequence concatenate(final CharSequence main, final CharSequence complement, final boolean parenthesis) {
if (main != null && main.length() != 0) {
@@ -725,10 +725,10 @@ pathTree: for (int j=0; ; j++) {
* Formats the given value preceded by a plus or minus sign.
* This method is used for formatting timezone offset.
*
- * @param df The {@link DateFormat} to use for formatting the offset.
- * @param offset The offset to format, as a positive or negative value.
- * @param buffer The buffer where to format the offset.
- * @return The given buffer, returned for convenience.
+ * @param df the {@link DateFormat} to use for formatting the offset.
+ * @param offset the offset to format, as a positive or negative value.
+ * @param buffer the buffer where to format the offset.
+ * @return the given buffer, returned for convenience.
*/
private static StringBuffer format(final Format df, final int offset, final StringBuffer buffer) {
return df.format(Math.abs(offset), buffer.append(offset < 0 ? '-' : '+').append(' '), new FieldPosition(0));
@@ -747,9 +747,9 @@ pathTree: for (int j=0; ; j++) {
* Returns the given file relative to the given root, or {@code null} if the root is not
* a parent of that file.
*
- * @param root The root directory (typically Java home or user home directory).
- * @param file The file to make relative to the root.
- * @return The file relative to the given root, or {@code null} if none.
+ * @param root the root directory (typically Java home or user home directory).
+ * @param file the file to make relative to the root.
+ * @return the file relative to the given root, or {@code null} if none.
*/
private static File relativize(final File root, final File file) {
File parent = file.getParentFile();
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Exceptions.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -20,10 +20,8 @@ import java.util.List;
import java.util.ArrayList;
import java.util.Locale;
import java.sql.SQLException;
-import org.apache.sis.internal.util.LocalizedException;
-
+import org.opengis.util.InternationalString;
import org.apache.sis.util.resources.Vocabulary;
-import static org.apache.sis.util.CharSequences.trimWhitespaces;
/**
@@ -31,7 +29,7 @@ import static org.apache.sis.util.CharSe
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.7
+ * @version 0.8
* @module
*/
public final class Exceptions extends Static {
@@ -44,21 +42,43 @@ public final class Exceptions extends St
/**
* Returns the message of the given exception, localized in the given locale if possible.
* Some exceptions created by SIS can format a message in different locales. This method
- * will return such localized message if possible, or fallback on the standard
- * {@link Throwable#getLocalizedMessage()} method otherwise. Note that by default,
- * {@code getLocalizedMessage()} itself fallback on {@link Throwable#getMessage()}.
- *
- * @param exception The exception from which to get the localize message, or {@code null}.
- * @param locale The locale for the message, or {@code null} for the default locale.
- * @return The message in the given locale if possible, or {@code null} if the {@code exception}
- * argument was {@code null} or the exception does not contain a message.
+ * returns such localized message if possible, or fallback on the standard JDK methods otherwise.
+ * More specifically:
+ *
+ *
+ *
If the given {@code exception} is null, then this method returns {@code null}.
+ *
Otherwise if the given {@code locale} is null, then this method returns {@link Exception#getMessage()}.
+ * This is consistent with the {@link Localized} policy saying that null locale stands for "unlocalized"
+ * message (usually in English) or message in the JVM {@linkplain Locale#getDefault() default locale}.
+ *
Otherwise if the given {@code exception} is an instance of {@link LocalizedException} providing
+ * a non-null {@linkplain LocalizedException#getInternationalMessage() international message},
+ * then this method returns the result of {@link InternationalString#toString(Locale)}.
+ *
Otherwise this method returns {@link Exception#getLocalizedMessage()}.
+ *
+ *
+ * @param exception the exception from which to get the localize message, or {@code null}.
+ * @param locale the preferred locale for the message, or {@code null} for the JVM default locale.
+ * This locale is honored on a best-effort basis only.
+ * @return the message in the given locale if possible, or {@code null} if the {@code exception}
+ * argument was {@code null} or if the exception does not contain a message.
+ *
+ * @see LocalizedException#getLocalizedMessage()
*/
public static String getLocalizedMessage(final Throwable exception, final Locale locale) {
if (exception == null) {
return null;
}
- if (locale != null && exception instanceof LocalizedException) {
- return ((LocalizedException) exception).getLocalizedMessage(locale);
+ if (locale == null) {
+ return exception.getMessage(); // See the policy documented in LocalizedException.getMessage()
+ }
+ if (exception instanceof LocalizedException) {
+ final InternationalString i18n = ((LocalizedException) exception).getInternationalMessage();
+ if (i18n != null) {
+ final String message = i18n.toString(locale);
+ if (message != null) {
+ return message;
+ }
+ }
}
return exception.getLocalizedMessage();
}
@@ -75,20 +95,20 @@ public final class Exceptions extends St
* exception class does not provide such constructor, then the given exception is returned
* unchanged.
*
- * @param The type of the exception.
- * @param exception The exception to copy with a different message.
- * @param message The message to set in the exception to be returned.
- * @param append If {@code true}, the existing message in the original exception (if any)
- * will be happened after the provided message.
- * @return A new exception with the given message, or the given exception if the exception
+ * @param the type of the exception.
+ * @param exception the exception to copy with a different message.
+ * @param message the message to set in the exception to be returned.
+ * @param append if {@code true}, the existing message in the original exception (if any)
+ * will be happened after the provided message.
+ * @return a new exception with the given message, or the given exception if the exception
* class does not provide public {@code Exception(String)} constructor.
*/
@SuppressWarnings("unchecked")
public static T setMessage(final T exception, String message, final boolean append) {
if (append) {
- final String em = trimWhitespaces(exception.getLocalizedMessage());
+ final String em = CharSequences.trimWhitespaces(exception.getLocalizedMessage());
if (em != null && !em.isEmpty()) {
- final StringBuilder buffer = new StringBuilder(trimWhitespaces(message));
+ final StringBuilder buffer = new StringBuilder(CharSequences.trimWhitespaces(message));
final int length = buffer.length();
if (length != 0 && Character.isLetterOrDigit(buffer.charAt(length-1))) {
buffer.append(". ");
@@ -108,7 +128,7 @@ public final class Exceptions extends St
/**
* Returns a string which contain the given message on the first line, followed by the
- * {@linkplain Throwable#getLocalizedMessage() localized message} of the given exception
+ * {@linkplain #getLocalizedMessage(Throwable, Locale) localized message} of the given exception
* on the next line. If the exception has a {@linkplain Throwable#getCause() causes}, then
* the class name and the localized message of the cause are formatted on the next line
* and the process is repeated for the whole cause chain, omitting duplicated messages.
@@ -118,36 +138,38 @@ public final class Exceptions extends St
*
*
This method does not format the stack trace.
*
- * @param locale The preferred locale for the exception message, or {@code null}.
- * @param header The message to insert on the first line, or {@code null} if none.
- * @param cause The exception, or {@code null} if none.
- * @return The formatted message, or {@code null} if both the header was {@code null}
+ * @param locale the preferred locale for the exception message, or {@code null}.
+ * @param header the message to insert on the first line, or {@code null} if none.
+ * @param cause the exception, or {@code null} if none.
+ * @return the formatted message, or {@code null} if both the header was {@code null}
* and no exception provide a message.
*/
- public static String formatChainedMessages(final Locale locale, String header, Throwable cause) {
+ public static String formatChainedMessages(final Locale locale, final String header, Throwable cause) {
final List previousLines = new ArrayList<>();
- final String lineSeparator = System.lineSeparator();
StringBuilder buffer = null;
Vocabulary resources = null;
while (cause != null) {
- final String message = trimWhitespaces(getLocalizedMessage(cause, locale));
+ final String message = CharSequences.trimWhitespaces(getLocalizedMessage(cause, locale));
if (message != null && !message.isEmpty()) {
if (buffer == null) {
buffer = new StringBuilder(128);
- header = trimWhitespaces(header);
- if (header != null && !header.isEmpty()) {
- buffer.append(header);
+ if (header != null) {
+ final int length = CharSequences.skipTrailingWhitespaces(header, 0, header.length());
+ if (length > 0) {
+ buffer.append(header, 0, length);
+ }
previousLines.add(header);
}
}
if (!contains(previousLines, message)) {
previousLines.add(message);
if (buffer.length() != 0) {
- buffer.append(lineSeparator);
if (resources == null) {
resources = Vocabulary.getResources(locale);
}
- buffer.append(resources.getString(Vocabulary.Keys.CausedBy_1, cause.getClass())).append(": ");
+ buffer.append(System.lineSeparator())
+ .append(resources.getString(Vocabulary.Keys.CausedBy_1, cause.getClass()))
+ .append(": ");
}
buffer.append(message);
}
@@ -161,17 +183,14 @@ public final class Exceptions extends St
}
cause = cause.getCause();
}
- if (buffer != null) {
- header = buffer.toString();
- }
- return header;
+ return (buffer != null) ? buffer.toString() : header;
}
/**
* Returns {@code true} if a previous line contains the given exception message.
*/
private static boolean contains(final List previousLines, final String message) {
- for (int i=previousLines.size(); --i>=0;) {
+ for (int i = previousLines.size(); --i >= 0;) {
if (previousLines.get(i).contains(message)) {
return true;
}
Copied: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/LocalizedException.java (from r1776530, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/LocalizedException.java?p2=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/LocalizedException.java&p1=sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java&r1=1776530&r2=1776531&rev=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/LocalizedException.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -14,58 +14,69 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.util;
+package org.apache.sis.util;
import java.util.Locale;
-import org.apache.sis.util.Localized;
+import org.opengis.util.InternationalString;
/**
- * An exception which can produce an error message in the given locale.
- * Exceptions implementing this interface use the following policy:
+ * An exception which can produce an error message in the client locale.
+ * Exceptions implementing this interface apply the following policy:
*
*
- *
{@link Throwable#getMessage()} returns the message in the {@linkplain Locale#getDefault() default locale}.
+ *
{@link #getMessage()} returns the message in the {@linkplain Locale#getDefault() default locale}.
* In a client-server architecture, this is often the locale on the server side.
- *
{@link Throwable#getLocalizedMessage()} returns the message in a locale that depends on the context
+ *
{@link #getLocalizedMessage()} returns the message in a locale that depends on the context
* in which the exception has been thrown. This is often the locale used by a {@link java.text.Format}
- * object for example, and can be presumed to be the locale on the client side.
- *
{@link #getLocalizedMessage(Locale)} returns the message in the given locale.
- * This method is specific to Apache SIS however.
+ * or {@link org.apache.sis.storage.DataStore} instance,
+ * and can be presumed to be the locale on the client side.
+ *
{@link #getInternationalMessage()} may return the message in arbitrary locale (optional operation).
+ * This method is specific to Apache SIS.
*
*
+ *
Example:
+ * if an error occurred while a Japanese client connected to an European server, the localized message may be sent
+ * to the client in Japanese language while the same error may be logged on the server side in the French language.
+ * This allows system administrator to analyze the issue without the need to understand client's language.
+ *
+ * The above policy is applied on a best-effort basis only. For example exceptions that
+ * do not implement {@code LocalizedException} may use any locale (not necessarily the default one),
+ * and {@code LocalizedException} used as {@linkplain Exception#Exception(Throwable) wrappers} around
+ * other exception usually lost their localization capability.
+ *
* @author Martin Desruisseaux (Geomatys)
- * @since 0.3
- * @version 0.7
+ * @since 0.8
+ * @version 0.8
* @module
*
- * @see org.apache.sis.util.Exceptions#getLocalizedMessage(Throwable, Locale)
+ * @see Exceptions#getLocalizedMessage(Throwable, Locale)
+ * @see org.apache.sis.storage.DataStore#setLocale(Locale)
*/
public interface LocalizedException {
/**
* Returns the message in the {@linkplain Locale#getDefault() default locale}.
+ * In a client-server architecture, this is usually the locale on the server side.
+ * This is the recommended language for logging messages to be read by system administrators.
*
- * @return the exception message in the default locale.
+ * @return the exception message in the JVM {@linkplain Locale#getDefault() default locale}.
*/
String getMessage();
/**
* Returns the message in the locale that depends on the context in which this exception has been thrown.
* For example it may be the local of a client application connected to a distant server.
+ * This is the recommended language to show in widgets.
*
- *
If the context locale is known, then this {@code LocalizedException} instance will also implement
- * the {@link Localized} interface and the context locale can be obtained by a call to
- * {@link Localized#getLocale()}.
- *
- * @return the localized exception message.
+ * @return the exception message in the locale of a service configured for a particular client.
*/
String getLocalizedMessage();
/**
- * Returns the message in the given locale.
+ * If this exception is capable to return the message in various locales, returns that message.
+ * Otherwise returns {@code null}.
*
- * @param locale the locale of the message to produce, or {@code null} for the default locale.
- * @return the exception message in the given locale.
+ * @return the exception message, or {@code null} if this exception can not produce international message.
*/
- String getLocalizedMessage(Locale locale);
+ InternationalString getInternationalMessage();
}
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java?rev=1776531&r1=1776530&r2=1776531&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/collection/TreeTableFormat.java [UTF-8] Fri Dec 30 09:23:24 2016
@@ -167,9 +167,9 @@ public class TreeTableFormat extends Tab
/**
* Creates a new tree table format.
*
- * @param locale The locale to use for numbers, dates and angles formatting,
- * or {@code null} for the {@linkplain Locale#ROOT root locale}.
- * @param timezone The timezone, or {@code null} for UTC.
+ * @param locale the locale to use for numbers, dates and angles formatting,
+ * or {@code null} for the {@linkplain Locale#ROOT root locale}.
+ * @param timezone the timezone, or {@code null} for UTC.
*/
public TreeTableFormat(final Locale locale, final TimeZone timezone) {
super(locale, timezone);
@@ -212,7 +212,7 @@ public class TreeTableFormat extends Tab
*
On formatting, {@linkplain TreeTable#getColumns() all TreeTable columns}.
*
*
- * @return The table columns to parse and format, or {@code null} for the default.
+ * @return the table columns to parse and format, or {@code null} for the default.
*/
public TableColumn>[] getColumns() {
return (columnIndices != null) ? DefaultTreeTable.getColumns(columnIndices) : null;
@@ -222,8 +222,8 @@ public class TreeTableFormat extends Tab
* Sets the table columns to parse and format. A {@code null} value means to use the default
* list of columns, as defined in the {@link #getColumns()} method.
*
- * @param columns The table columns to parse and format, or {@code null} for the default.
- * @throws IllegalArgumentException If the given array is empty, contains a null element
+ * @param columns the table columns to parse and format, or {@code null} for the default.
+ * @throws IllegalArgumentException if the given array is empty, contains a null element
* or a duplicated value.
*/
public void setColumns(final TableColumn>... columns) throws IllegalArgumentException {
@@ -241,7 +241,7 @@ public class TreeTableFormat extends Tab
* Returns the number of spaces to add on the left margin for each indentation level.
* The default value is 4.
*
- * @return The current indentation.
+ * @return the current indentation.
*/
public int getIndentation() {
return indentation;
@@ -252,8 +252,8 @@ public class TreeTableFormat extends Tab
* If the new indentation is smaller than the {@linkplain #getVerticalLinePosition()
* vertical line position}, then the later is also set to the given indentation value.
*
- * @param indentation The new indentation.
- * @throws IllegalArgumentException If the given value is negative.
+ * @param indentation the new indentation.
+ * @throws IllegalArgumentException if the given value is negative.
*/
public void setIndentation(final int indentation) throws IllegalArgumentException {
ArgumentChecks.ensurePositive("indentation", indentation);
@@ -269,7 +269,7 @@ public class TreeTableFormat extends Tab
* The default value is 2, which means that the vertical line is drawn below the third
* letter of the root label.
*
- * @return The current vertical line position.
+ * @return the current vertical line position.
*/
public int getVerticalLinePosition() {
return verticalLinePosition;
@@ -279,8 +279,8 @@ public class TreeTableFormat extends Tab
* Sets the position of the vertical line, relative to the position of the root label.
* The given value can not be greater than the {@linkplain #getIndentation() indentation}.
*
- * @param verticalLinePosition The new vertical line position.
- * @throws IllegalArgumentException If the given value is negative or greater than the indentation.
+ * @param verticalLinePosition the new vertical line position.
+ * @throws IllegalArgumentException if the given value is negative or greater than the indentation.
*/
public void setVerticalLinePosition(final int verticalLinePosition) throws IllegalArgumentException {
ArgumentChecks.ensureBetween("verticalLinePosition", 0, indentation, verticalLinePosition);
@@ -300,9 +300,9 @@ public class TreeTableFormat extends Tab
* The returned array may contain {@code null} elements, which means that the values
* in that column can be stored as {@code String}s.
*
- * @param mandatoy {@code true} if an exception shall be thrown for unrecognized types,
- * or {@code false} for storing a {@code null} value in the array instead.
- * @throws IllegalStateException If {@code mandatory} is {@code true} and a column
+ * @param mandatoy {@code true} if an exception shall be thrown for unrecognized types, or
+ * {@code false} for storing a {@code null} value in the array instead.
+ * @throws IllegalStateException if {@code mandatory} is {@code true} and a column
* contains values of an unsupported type.
*/
final Format[] getFormats(final TableColumn>[] columns, final boolean mandatory) throws IllegalStateException {
@@ -341,10 +341,10 @@ public class TreeTableFormat extends Tab
*
Parsing stops at first empty line (ignoring whitespaces), or at the end of the given text.
*
*
- * @param text The character sequence for the tree to parse.
- * @param pos The position where to start the parsing.
- * @return The parsed tree, or {@code null} if the given character sequence can not be parsed.
- * @throws ParseException If an error occurred while parsing a node value.
+ * @param text the character sequence for the tree to parse.
+ * @param pos the position where to start the parsing.
+ * @return the parsed tree, or {@code null} if the given character sequence can not be parsed.
+ * @throws ParseException if an error occurred while parsing a node value.
*/
@Override
@SuppressWarnings("null")
@@ -365,7 +365,7 @@ public class TreeTableFormat extends Tab
while (endOfLine > indexOfLineStart) {
final int c = text.charAt(endOfLine-1);
if (c != '\r' && c != '\n') break;
- endOfLine--; // Skip trailing '\r' and '\n'.
+ endOfLine--; // Skip trailing '\r' and '\n'.
}
/*
* Skip leading spaces using Character.isSpaceChar(…) instead than isWhitespace(…)
@@ -373,7 +373,7 @@ public class TreeTableFormat extends Tab
* need to consider line feeds since they were handled by the lines just above.
*/
boolean hasChar = false;
- int i; // The indentation of current line.
+ int i; // The indentation of current line.
for (i=indexOfLineStart; i void parseValue(final TreeTable.Node node, final TableColumn column,
final Format format, final String text) throws ParseException
@@ -607,9 +607,9 @@ public class TreeTableFormat extends Tab
/**
* Creates a new instance which will write to the given appendable.
*
- * @param out Where to format the tree.
- * @param column The columns of the tree table to format.
- * @param parentObjects An initially empty {@link IdentityHashMap}.
+ * @param out where to format the tree.
+ * @param column the columns of the tree table to format.
+ * @param parentObjects an initially empty {@link IdentityHashMap}.
*/
Writer(final Appendable out, final TableColumn>[] columns, final Map