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/04/13 18:03:41 UTC
svn commit: r1738964 - in /sis/branches/JDK8/core:
sis-feature/src/main/java/org/apache/sis/feature/
sis-feature/src/test/java/org/apache/sis/feature/
sis-feature/src/test/java/org/apache/sis/test/suite/
sis-referencing/src/main/java/org/apache/sis/ref...
Author: desruisseaux
Date: Wed Apr 13 16:03:41 2016
New Revision: 1738964
URL: http://svn.apache.org/viewvc?rev=1738964&view=rev
Log:
Javadoc, code formatting, factorisation of validate(Feature) code,
localization of error message, make a test independent of builder,
support validation for non-SIS property implementations.
Added:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/InvalidFeatureException.java (with props)
Modified:
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeaturesTest.java
sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedException.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/LocalizedParseException.java
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java?rev=1738964&r1=1738963&r2=1738964&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/AbstractFeature.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -74,7 +74,7 @@ import org.opengis.feature.Operation;
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.6
+ * @version 0.7
* @module
*
* @see DefaultFeatureType#newInstance()
@@ -270,8 +270,8 @@ public abstract class AbstractFeature im
if (pt instanceof AttributeType<?>) {
return getDefaultValue((AttributeType<?>) pt);
} else if (pt instanceof FeatureAssociationRole) {
- final int maxOcc = ((FeatureAssociationRole)pt).getMaximumOccurs();
- return maxOcc>1 ? Collections.EMPTY_LIST : null; // No default value for associations.
+ final int maximumOccurs = ((FeatureAssociationRole) pt).getMaximumOccurs();
+ return maximumOccurs > 1 ? Collections.EMPTY_LIST : null; // No default value for associations.
} else {
throw unsupportedPropertyType(pt.getName());
}
@@ -646,20 +646,7 @@ public abstract class AbstractFeature im
*/
public DataQuality quality() {
final Validator v = new Validator(ScopeCode.FEATURE);
- for (final PropertyType pt : type.getProperties(true)) {
- final Property property = getProperty(pt.getName().toString());
- final DataQuality quality;
- if (property instanceof AbstractAttribute<?>) {
- quality = ((AbstractAttribute<?>) property).quality();
- } else if (property instanceof AbstractAssociation) {
- quality = ((AbstractAssociation) property).quality();
- } else {
- continue;
- }
- if (quality != null) { // Should not be null, but let be safe.
- v.quality.getReports().addAll(quality.getReports());
- }
- }
+ v.validate(type, this);
return v.quality;
}
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java?rev=1738964&r1=1738963&r2=1738964&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/FeatureFormat.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -236,12 +236,12 @@ header: for (int i=0; ; i++) {
if (propertyType instanceof AttributeType &&
((AttributeType) propertyType).getMinimumOccurs() == 0)
{
- continue; // If no value, skip the full row.
+ continue; // If no value, skip the full row.
}
if (propertyType instanceof FeatureAssociationRole &&
((FeatureAssociationRole) propertyType).getMinimumOccurs() == 0)
{
- continue; // If no value, skip the full row.
+ continue; // If no value, skip the full row.
}
}
} else if (propertyType instanceof AttributeType<?>) {
@@ -339,7 +339,7 @@ header: for (int i=0; ; i++) {
Object c = attribute.getDefaultValue();
if (feature != null) {
final Property p = feature.getProperty(propertyType.getName().toString());
- if (p instanceof Attribute<?>) { // Should always be true, but we are paranoiac.
+ if (p instanceof Attribute<?>) { // Should always be true, but we are paranoiac.
c = ((Attribute<?>) p).characteristics().get(attribute.getName().toString());
}
}
@@ -360,11 +360,11 @@ header: for (int i=0; ; i++) {
* Returns the display name for the given {@code GenericName}.
*/
private String toString(final GenericName name) {
- if (name == null) { // Should not be null, but let be safe.
+ if (name == null) { // Should not be null, but let be safe.
return "";
}
final InternationalString i18n = name.toInternationalString();
- if (i18n != null) { // Should not be null, but let be safe.
+ if (i18n != null) { // Should not be null, but let be safe.
final String s = i18n.toString(displayLocale);
if (s != null) {
return s;
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java?rev=1738964&r1=1738963&r2=1738964&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Features.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -16,6 +16,12 @@
*/
package org.apache.sis.feature;
+import org.opengis.util.InternationalString;
+import org.opengis.metadata.maintenance.ScopeCode;
+import org.opengis.metadata.quality.ConformanceResult;
+import org.opengis.metadata.quality.DataQuality;
+import org.opengis.metadata.quality.Element;
+import org.opengis.metadata.quality.Result;
import org.apache.sis.util.Static;
import org.apache.sis.util.resources.Errors;
@@ -23,15 +29,7 @@ import org.apache.sis.util.resources.Err
import org.opengis.feature.Attribute;
import org.opengis.feature.AttributeType;
import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
import org.opengis.feature.InvalidPropertyValueException;
-import org.opengis.feature.Property;
-import org.opengis.feature.PropertyType;
-import org.opengis.metadata.maintenance.ScopeCode;
-import org.opengis.metadata.quality.ConformanceResult;
-import org.opengis.metadata.quality.DataQuality;
-import org.opengis.metadata.quality.Element;
-import org.opengis.metadata.quality.Result;
/**
@@ -108,66 +106,55 @@ public final class Features extends Stat
return (Attribute<V>) attribute;
}
-
/**
- * Validate feature state.
- * <br>
- * This method is a shortcut to loop on feature data quality results.
- * <br>
- * If one ConformanceResult is false then an IllegalArgumentException is throw,
- * otherwise the function return doing nothing.
+ * Ensures that all characteristics and property values in the given feature are valid.
+ * An attribute is valid if it contains a number of values between the
+ * {@linkplain DefaultAttributeType#getMinimumOccurs() minimum} and
+ * {@linkplain DefaultAttributeType#getMaximumOccurs() maximum number of occurrences} (inclusive),
+ * all values are instances of the expected {@linkplain DefaultAttributeType#getValueClass() value class},
+ * and the attribute is compliant with any other restriction that the implementation may add.
*
- * @param feature tested feature.
- * @throws InvalidPropertyValueException if feature do not pass validation
+ * <p>This method gets a quality report as documented in the {@link AbstractFeature#quality()} method
+ * and verifies that all {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#pass()
+ * conformance tests pass}. If at least one {@code ConformanceResult.pass} attribute is false, then an
+ * {@code InvalidPropertyValueException} is thrown. Otherwise this method returns doing nothing.
+ *
+ * @param feature the feature to validate, or {@code null}.
+ * @throws InvalidPropertyValueException if the given feature is non-null and does not pass validation.
+ *
+ * @since 0.7
*/
- public static void validate(Feature feature) throws InvalidPropertyValueException {
-
- //Get data quality of the feature
- final DataQuality quality;
- if(feature instanceof AbstractFeature){
- quality = ((AbstractFeature)feature).quality();
- }else{
- //use default validator
- final Validator v = new Validator(ScopeCode.FEATURE);
- final FeatureType type = feature.getType();
- for (final PropertyType pt : type.getProperties(true)) {
- final Property property = feature.getProperty(pt.getName().toString());
- final DataQuality pq;
- if (property instanceof AbstractAttribute<?>) {
- pq = ((AbstractAttribute<?>) property).quality();
- } else if (property instanceof AbstractAssociation) {
- pq = ((AbstractAssociation) property).quality();
- } else {
- continue;
- }
- if (pq != null) { // Should not be null, but let be safe.
- v.quality.getReports().addAll(pq.getReports());
- }
+ public static void validate(final Feature feature) throws InvalidPropertyValueException {
+ if (feature != null) {
+ /*
+ * Delegate to AbstractFeature.quality() if possible because the user may have overridden the method.
+ * Otherwise fallback on the same code than AbstractFeature.quality() default implementation.
+ */
+ final DataQuality quality;
+ if (feature instanceof AbstractFeature) {
+ quality = ((AbstractFeature) feature).quality();
+ } else {
+ final Validator v = new Validator(ScopeCode.FEATURE);
+ v.validate(feature.getType(), feature);
+ quality = v.quality;
}
- quality = v.quality;
- }
-
- //loop on quality elements and check conformance results
- boolean valid = true;
- search:
- for(Element element : quality.getReports()){
- for(Result result : element.getResults()){
- //NOTE : other type of result are ignored for now
- // other results may requiere threshold and other informations
- // to be evaluated
- if(result instanceof ConformanceResult){
- final Boolean pass = ((ConformanceResult)result).pass();
- if(Boolean.FALSE.equals(pass)){
- valid = false;
- break search;
+ /*
+ * Loop on quality elements and check conformance results.
+ * NOTE: other types of result are ignored for now, since those other
+ * types may require threshold and other informations to be evaluated.
+ */
+ for (Element element : quality.getReports()) {
+ for (Result result : element.getResults()) {
+ if (result instanceof ConformanceResult) {
+ if (Boolean.FALSE.equals(((ConformanceResult) result).pass())) {
+ final InternationalString message = ((ConformanceResult) result).getExplanation();
+ if (message != null) {
+ throw new InvalidFeatureException(message);
+ }
+ }
}
}
}
}
-
- if(!valid){
- throw new InvalidPropertyValueException(quality.toString());
- }
}
-
}
Added: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/InvalidFeatureException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/InvalidFeatureException.java?rev=1738964&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/InvalidFeatureException.java (added)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/InvalidFeatureException.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.feature;
+
+import java.util.Locale;
+import org.opengis.util.InternationalString;
+import org.apache.sis.internal.util.LocalizedException;
+
+// Branch-dependent imports
+import org.opengis.feature.Feature;
+import org.opengis.feature.InvalidPropertyValueException;
+
+
+/**
+ * Thrown when a feature fails at least one conformance test.
+ *
+ * <div class="note"><b>Note:</b>
+ * this exception extends {@link InvalidPropertyValueException} because an Apache SIS feature
+ * can be invalid only if a property is invalid.</div>
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.7
+ * @version 0.7
+ * @module
+ *
+ * @see Features#validate(Feature)
+ */
+final class InvalidFeatureException extends InvalidPropertyValueException implements LocalizedException {
+ /**
+ * For cross-version compatibility.
+ */
+ private static final long serialVersionUID = 7288810679876346027L;
+
+ /**
+ * A description of the negative conformance result.
+ */
+ private final InternationalString message;
+
+ /**
+ * Creates a new exception with the given explanation message.
+ *
+ * @param message a description of the negative conformance result.
+ */
+ InvalidFeatureException(final InternationalString message) {
+ super(message.toString());
+ this.message = message;
+ }
+
+ /**
+ * Returns the message localized in the given language, or in a default language if the requested
+ * localization is not available.
+ *
+ * @param locale the desired language.
+ * @return the message in the given locale, or in a default locale if the requested localization is not available.
+ */
+ @Override
+ public String getLocalizedMessage(final Locale locale) {
+ return message.toString(locale);
+ }
+}
Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/InvalidFeatureException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/InvalidFeatureException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java?rev=1738964&r1=1738963&r2=1738964&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/Validator.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -22,6 +22,7 @@ import org.opengis.util.GenericName;
import org.opengis.util.InternationalString;
import org.opengis.metadata.Identifier;
import org.opengis.metadata.maintenance.ScopeCode;
+import org.opengis.metadata.quality.DataQuality;
import org.opengis.metadata.quality.EvaluationMethodType;
import org.apache.sis.metadata.iso.quality.AbstractElement;
import org.apache.sis.metadata.iso.quality.DefaultDataQuality;
@@ -32,10 +33,13 @@ import org.apache.sis.referencing.NamedI
import org.apache.sis.util.resources.Errors;
// Branch-dependent imports
+import org.opengis.feature.Property;
import org.opengis.feature.PropertyType;
+import org.opengis.feature.Attribute;
import org.opengis.feature.AttributeType;
import org.opengis.feature.Feature;
import org.opengis.feature.FeatureType;
+import org.opengis.feature.FeatureAssociation;
import org.opengis.feature.FeatureAssociationRole;
@@ -44,7 +48,7 @@ import org.opengis.feature.FeatureAssoci
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.7
* @module
*/
final class Validator {
@@ -109,6 +113,35 @@ final class Validator {
}
}
+ /**
+ * Implementation of {@link AbstractFeature#quality()}, also shared by {@link Features} static method.
+ *
+ * @param type the type of the {@code feature} argument, provided explicitely for protecting from user overriding.
+ * @param feature the feature to validate.
+ */
+ void validate(final FeatureType type, final Feature feature) {
+ for (final PropertyType pt : type.getProperties(true)) {
+ final Property property = feature.getProperty(pt.getName().toString());
+ final DataQuality pq;
+ if (property instanceof AbstractAttribute<?>) {
+ pq = ((AbstractAttribute<?>) property).quality();
+ } else if (property instanceof AbstractAssociation) {
+ pq = ((AbstractAssociation) property).quality();
+ } else if (property instanceof Attribute<?>) {
+ validateAny(((Attribute<?>) property).getType(), ((Attribute<?>) property).getValues());
+ continue;
+ } else if (property instanceof FeatureAssociation) {
+ validateAny(((FeatureAssociation) property).getRole(), ((FeatureAssociation) property).getValues());
+ continue;
+ } else {
+ continue;
+ }
+ if (pq != null) { // Should not be null, but let be safe.
+ quality.getReports().addAll(pq.getReports());
+ }
+ }
+ }
+
/**
* Verifies if the given value is valid for the given attribute type.
* This method delegates to one of the {@code validate(…)} methods depending of the value type.
Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeaturesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeaturesTest.java?rev=1738964&r1=1738963&r2=1738964&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeaturesTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/FeaturesTest.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -16,14 +16,14 @@
*/
package org.apache.sis.feature;
-import org.apache.sis.internal.feature.FeatureTypeBuilder;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
import static org.junit.Assert.*;
+
+// Branch-dependent imports
import org.opengis.feature.Feature;
-import org.opengis.feature.FeatureType;
import org.opengis.feature.InvalidPropertyValueException;
@@ -75,30 +75,24 @@ public final strictfp class FeaturesTest
}
/**
- * Tests {@link Features#validate(org.opengis.feature.Feature) }.
+ * Tests {@link Features#validate(Feature)}.
*/
@Test
- public void testValidate(){
-
- final FeatureTypeBuilder ftb = new FeatureTypeBuilder();
- ftb.setName("myScope","myName");
- ftb.addProperty("name", String.class,1,1,null);
- final FeatureType type = ftb.build();
-
- final Feature feature = type.newInstance();
+ public void testValidate() {
+ final Feature feature = DefaultFeatureTypeTest.city().newInstance();
- //should not pass validation
- try{
+ // Should not pass validation.
+ try {
Features.validate(feature);
- fail("Feature is unvalid, property name is missing, validation should have raised an exception.");
- }catch(InvalidPropertyValueException ex){
- //ok
+ fail("Feature is invalid because of missing property “population”. Validation should have raised an exception.");
+ } catch (InvalidPropertyValueException ex) {
+ String message = ex.getMessage();
+ assertTrue(message, message.contains("city") || message.contains("population"));
}
- //should pass validation
- feature.setPropertyValue("name", "hubert");
+ // Should pass validation.
+ feature.setPropertyValue("city", "Utopia");
+ feature.setPropertyValue("population", 10);
Features.validate(feature);
-
}
-
}
Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java?rev=1738964&r1=1738963&r2=1738964&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -25,8 +25,9 @@ import org.junit.BeforeClass;
* All tests from the {@code sis-feature} module, in approximative dependency order.
*
* @author Martin Desruisseaux (Geomatys)
+ * @author Johann Sorel (Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.7
* @module
*/
@Suite.SuiteClasses({
@@ -50,8 +51,8 @@ import org.junit.BeforeClass;
org.apache.sis.filter.DefaultLiteralTest.class,
org.apache.sis.filter.DefaultPropertyNameTest.class,
org.apache.sis.internal.feature.AttributeConventionTest.class,
- org.apache.sis.internal.feature.FeatureTypeBuilderTest.class,
- org.apache.sis.internal.feature.AttributeTypeBuilderTest.class
+ org.apache.sis.internal.feature.AttributeTypeBuilderTest.class,
+ org.apache.sis.internal.feature.FeatureTypeBuilderTest.class
})
public final strictfp class FeatureTestSuite extends TestSuite {
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java?rev=1738964&r1=1738963&r2=1738964&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/CoordinateOperationFinder.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -939,9 +939,9 @@ public class CoordinateOperationFinder e
* @return A concatenated operation, or {@code null} if all arguments were null.
* @throws FactoryException if the operation can not be constructed.
*/
- protected CoordinateOperation concatenate(final CoordinateOperation step1,
- final CoordinateOperation step2,
- final CoordinateOperation step3)
+ private CoordinateOperation concatenate(final CoordinateOperation step1,
+ final CoordinateOperation step2,
+ final CoordinateOperation step3)
throws FactoryException
{
if (isIdentity(step1)) return concatenate(step2, step3);
Modified: 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/internal/util/LocalizedException.java?rev=1738964&r1=1738963&r2=1738964&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/internal/util/LocalizedException.java [UTF-8] Wed Apr 13 16:03:41 2016
@@ -22,13 +22,13 @@ import org.apache.sis.util.Localized;
/**
* An exception which can produce an error message in the given locale.
- * Exceptions implementing this interface uses the following policy:
+ * Exceptions implementing this interface use the following policy:
*
* <ul>
* <li>{@link Throwable#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.</li>
- * <li>{@link Throwable#getLocalizedMessage()} returns the message in the locale returned by the
- * {@link #getLocale()} method. This is often the locale used by a {@link java.text.Format}
+ * <li>{@link Throwable#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.</li>
* <li>{@link #getLocalizedMessage(Locale)} returns the message in the given locale.
* This method is specific to Apache SIS however.</li>
@@ -36,29 +36,26 @@ import org.apache.sis.util.Localized;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.7
* @module
*
* @see org.apache.sis.util.Exceptions#getLocalizedMessage(Throwable, Locale)
*/
-public interface LocalizedException extends Localized {
+public interface LocalizedException {
/**
- * The locale of the string returned by {@link #getLocalizedMessage()}.
- *
- * @return The locale of the localized exception message.
- */
- @Override
- Locale getLocale();
-
- /**
- * Returns the message in the default locale.
+ * Returns the message in the {@linkplain Locale#getDefault() default locale}.
*
* @return The exception message in the default locale.
*/
String getMessage();
/**
- * Returns the message in the locale specified by {@link #getLocale()}.
+ * 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.
+ *
+ * <p>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()}.</p>
*
* @return The localized exception message.
*/
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=1738964&r1=1738963&r2=1738964&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] Wed Apr 13 16:03:41 2016
@@ -20,6 +20,7 @@ import java.util.Locale;
import java.text.ParsePosition;
import java.text.ParseException;
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;
@@ -39,10 +40,10 @@ import org.apache.sis.util.resources.Err
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.7
* @module
*/
-public final class LocalizedParseException extends ParseException implements LocalizedException {
+public final class LocalizedParseException extends ParseException implements LocalizedException, Localized {
/**
* For cross-version compatibility.
*/