Author: desruisseaux
Date: Tue May 20 14:53:16 2014
New Revision: 1596278
URL: http://svn.apache.org/r1596278
Log:
Document better the Feature.quality() contract and fix a hole in their implementation.
The new implementation can now invoke the user-overridden methods, if any.
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/DefaultAssociation.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java
sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.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/DefaultAttributeTest.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.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=1596278&r1=1596277&r2=1596278&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] Tue May 20 14:53:16 2014
@@ -84,8 +84,8 @@ public abstract class AbstractFeature im
}
/**
- * Return the type name as a non-null string. This is used mostly for formatting error
message.
- * This method should not be used when a null name should be considered as an error.
+ * Return the {@linkplain #type} name as a non-null string. This is used mostly for formatting
error message.
+ * This method shall not be invoked when a null name should be considered as an error.
*/
final String getName() {
return String.valueOf(type.getName());
@@ -211,7 +211,7 @@ public abstract class AbstractFeature im
* The amount of validation performed by this method is implementation dependent.
* Usually, only the most basic constraints are verified. This is so for performance
reasons
* and also because some rules may be temporarily broken while constructing a feature.
- * A more exhaustive verification can be performed by invoking the {@link #validate()}
method.
+ * A more exhaustive verification can be performed by invoking the {@link #quality()}
method.
*
* @param name The attribute name.
* @param value The new value for the given attribute (may be {@code null}).
@@ -309,13 +309,33 @@ public abstract class AbstractFeature im
}
/**
- * Verifies if all current properties met the constraints defined by the feature type.
- * This method returns {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
- * reports} for all constraint violations found, if any.
+ * Evaluates the quality of this feature at this method invocation time. The data quality
reports
+ * may include information about whether the property values met the constraints defined
by the
+ * property types, or any other criterion at implementation choice.
+ *
+ * <p>The default implementation reports data quality with at least the following
information:</p>
+ * <ul>
+ * <li>
+ * The {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getScope()
scope}
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultScope#getLevel() level}
is set to
+ * {@link org.opengis.metadata.maintenance.ScopeCode#FEATURE}.
+ * </li><li>
+ * The {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
reports} list contains
+ * at most one {@linkplain org.apache.sis.metadata.iso.quality.DefaultDomainConsistency
domain consistency}
+ * element per property. Implementations are free to omit element for properties
having nothing to report.
+ * </li><li>
+ * Each report may have one or more {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult
+ * conformance result}, as documented on {@link DefaultAttribute#quality()} javadoc.
+ * </li>
+ * </ul>
+ *
+ * This feature is valid if this method does not report any
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance
result} having a
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#pass() pass}
value of {@code false}.
*
* <div class="note"><b>Example:</b> given a feature with an attribute
named “population”.
* If this attribute is mandatory ([1 … 1] cardinality) but no value has been assigned
to it,
- * then this {@code validate()} method will return the following data quality report:
+ * then this {@code quality()} method will return the following data quality report:
*
* {@preformat text
* Data quality
@@ -331,24 +351,27 @@ public abstract class AbstractFeature im
* }
* </div>
*
- * This feature is valid if this method does not report any
- * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance
result} having a
- * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#pass() pass}
value of {@code false}.
- *
* @return Reports on all constraint violations found.
*
- * @see DefaultAttribute#validate()
- * @see DefaultAssociation#validate()
- */
- /*
- * API NOTE: this method is final for now because if we allowed users to override it,
users would
- * expect their method to be invoked by DefaultAssociation.validate(). But this is not
yet the case.
+ * @see DefaultAttribute#quality()
+ * @see DefaultAssociation#quality()
*/
- public final DataQuality validate() {
+ public DataQuality quality() {
final Validator v = new Validator(ScopeCode.FEATURE);
-// for (final Map.Entry<String, Object> entry : properties.entrySet()) {
-// v.validateAny(getPropertyType(entry.getKey()), entry.getValue());
-// }
+ for (final String name : type.indices().keySet()) {
+ final Property property = (Property) getProperty(name);
+ final DataQuality quality;
+ if (property instanceof DefaultAttribute<?>) {
+ quality = ((DefaultAttribute<?>) property).quality();
+ } else if (property instanceof DefaultAssociation) {
+ quality = ((DefaultAssociation) property).quality();
+ } else {
+ continue;
+ }
+ if (quality != null) { // Should not be null, but let be safe.
+ v.quality.getReports().addAll(quality.getReports());
+ }
+ }
return v.quality;
}
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAssociation.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -129,7 +129,7 @@ public class DefaultAssociation extends
* The amount of validation performed by this method is implementation dependent.
* Usually, only the most basic constraints are verified. This is so for performance
reasons
* and also because some rules may be temporarily broken while constructing a feature.
- * A more exhaustive verification can be performed by invoking the {@link #validate()}
method.
+ * A more exhaustive verification can be performed by invoking the {@link #quality()}
method.
*
* @param value The new value, or {@code null}.
* @throws IllegalArgumentException If the given feature is not valid for this association.
@@ -156,9 +156,10 @@ public class DefaultAssociation extends
/**
* Verifies if the current association value mets the constraints defined by the association
role.
- * This method returns {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
- * reports} for all constraint violations found, if any.
- * See {@link DefaultAttribute#validate()} for an example.
+ * This method returns at most one {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
+ * report} with a {@linkplain org.apache.sis.metadata.iso.quality.DefaultDomainConsistency#getResults()
result} for
+ * each constraint violations found, if any.
+ * See {@link DefaultAttribute#quality()} for an example.
*
* <p>This association is valid if this method does not report any
* {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance
result} having a
@@ -166,13 +167,9 @@ public class DefaultAssociation extends
*
* @return Reports on all constraint violations found.
*
- * @see AbstractFeature#validate()
+ * @see AbstractFeature#quality()
*/
- /*
- * API NOTE: this method is final for now because if we allowed users to override it,
users would
- * expect their method to be invoked by AbstractFeature.validate(). But this is not yet
the case.
- */
- public final DataQuality validate() {
+ public DataQuality quality() {
final Validator v = new Validator(null);
v.validate(role, value);
return v.quality;
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DefaultAttribute.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -134,7 +134,7 @@ public class DefaultAttribute<T> extends
* The amount of validation performed by this method is implementation dependent.
* Usually, only the most basic constraints are verified. This is so for performance
reasons
* and also because some rules may be temporarily broken while constructing a feature.
- * A more exhaustive verification can be performed by invoking the {@link #validate()}
method.
+ * A more exhaustive verification can be performed by invoking the {@link #quality()}
method.
*
* @param value The new value.
*
@@ -145,12 +145,53 @@ public class DefaultAttribute<T> extends
}
/**
- * Verifies if the current attribute value mets the constraints defined by the attribute
type.
- * This method returns {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
- * reports} for all constraint violations found, if any.
+ * Evaluates the quality of this attribute at this method invocation time. The data quality
reports
+ * may include information about whether the attribute value mets the constraints defined
by the
+ * {@linkplain DefaultAttributeType attribute type}, or any other criterion at implementation
choice.
+ *
+ * <p>The default implementation reports data quality with at least the following
information:</p>
+ * <ul>
+ * <li>
+ * The {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getScope()
scope}
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultScope#getLevel() level}
is set to
+ * {@link org.opengis.metadata.maintenance.ScopeCode#ATTRIBUTE}.
+ * </li><li>
+ * At most one {@linkplain org.apache.sis.metadata.iso.quality.DefaultDomainConsistency
domain consistency}
+ * element is added to the {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports()
+ * reports} list (implementations are free to omit that element if they have nothing
to report).
+ * If a report is provided, then it will contain at least the following information:
+ * <ul>
+ * <li>
+ * The {@linkplain #getName() attribute name} as the data quality
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultDomainConsistency#getMeasureIdentification()
+ * measure identification}.
+ *
+ * <div class="note"><b>Note:</b> strictly speaking, {@code
measureIdentification} identifies the
+ * <em>quality measurement</em>, not the “real” measurement itself.
However this implementation
+ * uses the same set of identifiers for both for simplicity.</div>
+ * </li><li>
+ * If the attribute {@linkplain #getValue() value} is not an {@linkplain Class#isInstance
instance}
+ * of the expected {@linkplain DefaultAttributeType#getValueClass() value class},
or if the number
+ * of occurrences is not inside the cardinality range, or if any other constraint
is violated, then
+ * a {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult
conformance result} is
+ * added for each violation with an
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#getExplanation()
explanation}
+ * set to the error message.
+ *
+ * <div class="warning"><b>Note:</b> this is a departure from
ISO intend, since {@code explanation}
+ * should be a statement about what a successful conformance means. This point
may be reformulated
+ * in a future SIS version.</div>
+ * </li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * This attribute is valid if this method does not report any
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance
result} having a
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#pass() pass}
value of {@code false}.
*
* <div class="note"><b>Example:</b> given an attribute named “population”
with [1 … 1] cardinality,
- * if no value has been assigned to that attribute, then this {@code validate()} method
will return
+ * if no value has been assigned to that attribute, then this {@code quality()} method
will return
* the following data quality report:
*
* {@preformat text
@@ -167,19 +208,11 @@ public class DefaultAttribute<T> extends
* }
* </div>
*
- * This attribute is valid if this method does not report any
- * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult conformance
result} having a
- * {@linkplain org.apache.sis.metadata.iso.quality.DefaultConformanceResult#pass() pass}
value of {@code false}.
- *
* @return Reports on all constraint violations found.
*
- * @see AbstractFeature#validate()
- */
- /*
- * API NOTE: this method is final for now because if we allowed users to override it,
users would
- * expect their method to be invoked by AbstractFeature.validate(). But this is not yet
the case.
+ * @see AbstractFeature#quality()
*/
- public final DataQuality validate() {
+ public DataQuality quality() {
final Validator v = new Validator(ScopeCode.ATTRIBUTE);
v.validate(type, value);
return v.quality;
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/DenseFeature.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -18,6 +18,8 @@ package org.apache.sis.feature;
import java.util.Map;
import java.util.Arrays;
+import org.opengis.metadata.maintenance.ScopeCode;
+import org.opengis.metadata.quality.DataQuality;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
@@ -190,6 +192,26 @@ final class DenseFeature extends Abstrac
}
/**
+ * Verifies if all current properties met the constraints defined by the feature type.
This method returns
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports() reports}
for all invalid
+ * properties, if any.
+ */
+ @Override
+ public DataQuality quality() {
+ if (properties != null && !(properties instanceof Property[])) {
+ final Validator v = new Validator(ScopeCode.FEATURE);
+ for (final Map.Entry<String, Integer> entry : indices.entrySet()) {
+ v.validateAny(getPropertyType(entry.getKey()), properties[entry.getValue()]);
+ }
+ return v.quality;
+ }
+ /*
+ * Slower path when there is a possibility that user overridden the Property.quality()
methods.
+ */
+ return super.quality();
+ }
+
+ /**
* Returns a hash code value for this feature.
*
* @return A hash code value.
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/PropertySingleton.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -136,7 +136,7 @@ final class PropertySingleton<V> extends
*
* This method does not checks if the removal is allowed by the
* {@linkplain DefaultAttributeType#getMinimumOccurs() cardinality}.
- * Such check can be performed by {@link AbstractFeature#validate()}.
+ * Such check can be performed by {@link AbstractFeature#quality()}.
*/
@Override
public V remove(final int index) {
@@ -168,7 +168,7 @@ final class PropertySingleton<V> extends
*
* This method does not checks if the removal is allowed by the
* {@linkplain DefaultAttributeType#getMinimumOccurs() cardinality}.
- * Such check can be performed by {@link AbstractFeature#validate()}.
+ * Such check can be performed by {@link AbstractFeature#quality()}.
*/
@Override
public void clear() {
Modified: sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/feature/SparseFeature.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -19,6 +19,8 @@ package org.apache.sis.feature;
import java.util.Map;
import java.util.HashMap;
import java.util.ConcurrentModificationException;
+import org.opengis.metadata.maintenance.ScopeCode;
+import org.opengis.metadata.quality.DataQuality;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.CorruptedObjectException;
@@ -214,6 +216,26 @@ final class SparseFeature extends Abstra
}
/**
+ * Verifies if all current properties met the constraints defined by the feature type.
This method returns
+ * {@linkplain org.apache.sis.metadata.iso.quality.DefaultDataQuality#getReports() reports}
for all invalid
+ * properties, if any.
+ */
+ @Override
+ public DataQuality quality() {
+ if (valuesKind == VALUES) {
+ final Validator v = new Validator(ScopeCode.FEATURE);
+ for (final Map.Entry<String, Object> entry : properties.entrySet()) {
+ v.validateAny(getPropertyType(entry.getKey()), entry.getValue());
+ }
+ return v.quality;
+ }
+ /*
+ * Slower path when there is a possibility that user overridden the Property.quality()
methods.
+ */
+ return super.quality();
+ }
+
+ /**
* Returns a hash code value for this feature.
*
* @return A hash code value.
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=1596278&r1=1596277&r2=1596278&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] Tue May 20 14:53:16 2014
@@ -21,6 +21,7 @@ import org.opengis.util.InternationalStr
import org.opengis.metadata.Identifier;
import org.opengis.metadata.maintenance.ScopeCode;
import org.opengis.metadata.quality.EvaluationMethodType;
+import org.apache.sis.metadata.iso.quality.AbstractElement;
import org.apache.sis.metadata.iso.quality.DefaultDataQuality;
import org.apache.sis.metadata.iso.quality.DefaultDomainConsistency;
import org.apache.sis.metadata.iso.quality.DefaultConformanceResult;
@@ -57,19 +58,35 @@ final class Validator {
}
/**
- * Adds a report for a constraint violation.
+ * Adds a report for a constraint violation. If the given {@code report} is {@code null},
then this method creates
+ * a new {@link DefaultDomainConsistency} instance with the measure identification set
to the property name.
*
- * @param type Description of the property for which a constraint violation has
been found.
- * @param explanation Explanation of the constraint violation.
+ * <div class="note"><b>Note:</b>
+ * setting {@code measureIdentification} to the property name may look like a departure
from ISO intend,
+ * since the former should be an identification of the <em>quality measurement</em>
rather then the measure itself.
+ * (setting {@code measureDescription} to {@code type.getDescription()} would probably
be wrong for that reason).
+ * However {@code measureIdentification} is only an identifier, not a full description
of the quality measurement
+ * We are not strictly forbidden to use the same identifier for both the quality measurement
than the measurement
+ * itself. However strictly speaking, maybe we should use a different scope.</div>
+ *
+ * @param report Where to add the result, or {@code null} if not yet created.
+ * @param type Description of the property for which a constraint violation has
been found.
+ * @param explanation Explanation of the constraint violation.
+ * @return The {@code report}, or a new report if {@code report} was null.
*/
- void addViolationReport(final AbstractIdentifiedType type, final InternationalString
explanation) {
- final DefaultDomainConsistency report = new DefaultDomainConsistency();
- final GenericName name = type.getName();
- report.setMeasureIdentification(name instanceof Identifier ? (Identifier) name :
new NamedIdentifier(name));
- report.setMeasureDescription(type.getDescription());
- report.setEvaluationMethodType(EvaluationMethodType.DIRECT_INTERNAL);
+ private AbstractElement addViolationReport(AbstractElement report,
+ final AbstractIdentifiedType type, final InternationalString explanation)
+ {
+ if (report == null) {
+ final GenericName name = type.getName();
+ report = new DefaultDomainConsistency();
+ // Do not invoke report.setMeasureDescription(type.getDescription()) - see above
javadoc.
+ report.setMeasureIdentification(name instanceof Identifier ? (Identifier) name
: new NamedIdentifier(name));
+ report.setEvaluationMethodType(EvaluationMethodType.DIRECT_INTERNAL);
+ quality.getReports().add(report);
+ }
report.getResults().add(new DefaultConformanceResult(null, explanation, false));
- quality.getReports().add(report);
+ return report;
}
/**
@@ -89,6 +106,7 @@ final class Validator {
* Verifies if the given value is valid for the given attribute type.
*/
void validate(final DefaultAttributeType<?> type, final Object value) {
+ AbstractElement report = null;
if (value != null) {
/*
* In theory, the following check is unnecessary since the type was constrained
by the Attribute.setValue(T)
@@ -96,41 +114,44 @@ final class Validator {
* so we are better to check.
*/
if (!type.getValueClass().isInstance(value)) {
- addViolationReport(type, Errors.formatInternational(
+ report = addViolationReport(report, type, Errors.formatInternational(
Errors.Keys.IllegalPropertyClass_2, type.getName(), value.getClass()));
}
}
- verifyCardinality(type, type.getMinimumOccurs(), type.getMaximumOccurs(), value);
+ verifyCardinality(report, type, type.getMinimumOccurs(), type.getMaximumOccurs(),
value);
}
/**
* Verifies if the given value is valid for the given association role.
*/
void validate(final DefaultAssociationRole role, final AbstractFeature value) {
+ AbstractElement report = null;
if (value != null) {
final DefaultFeatureType type = value.getType();
if (!role.getValueType().isAssignableFrom(type)) {
- addViolationReport(role, Errors.formatInternational(
+ report = addViolationReport(report, role, Errors.formatInternational(
Errors.Keys.IllegalPropertyClass_2, role.getName(), type.getName()));
}
}
- verifyCardinality(role, role.getMinimumOccurs(), role.getMaximumOccurs(), value);
+ verifyCardinality(report, role, role.getMinimumOccurs(), role.getMaximumOccurs(),
value);
}
/**
* Verifies if the given value mets the cardinality constraint.
+ *
+ * @param report Where to add the result, or {@code null} if not yet created.
*/
- private void verifyCardinality(final AbstractIdentifiedType type,
+ private void verifyCardinality(final AbstractElement report, final AbstractIdentifiedType
type,
final int minimumOccurs, final int maximumOccurs, final Object value)
{
if (value == null) {
if (minimumOccurs != 0) {
- addViolationReport(type, Errors.formatInternational(
+ addViolationReport(report, type, Errors.formatInternational(
Errors.Keys.MissingValueForProperty_1, type.getName()));
}
} else {
if (maximumOccurs == 0) {
- addViolationReport(type, Errors.formatInternational(
+ addViolationReport(report, type, Errors.formatInternational(
Errors.Keys.ForbiddenProperty_1, type.getName()));
}
}
Modified: sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-feature/src/test/java/org/apache/sis/feature/DefaultAttributeTest.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -71,14 +71,14 @@ public final strictfp class DefaultAttri
}
/**
- * Tests {@link DefaultAttribute#validate()}.
+ * Tests {@link DefaultAttribute#quality()}.
*/
@Test
@DependsOnMethod("testValue")
@SuppressWarnings("unchecked")
- public void testValidate() {
+ public void testQuality() {
final DefaultAttribute<Integer> attribute = population();
- DataQuality quality = attribute.validate();
+ DataQuality quality = attribute.quality();
assertEquals("scope.level", ScopeCode.ATTRIBUTE, quality.getScope().getLevel());
assertDomainConsistencyEquals("population", "Missing value for “population” property.",
(DomainConsistency) getSingleton(quality.getReports()));
@@ -86,7 +86,7 @@ public final strictfp class DefaultAttri
* Intentionally store a value of the wrong type, and test again.
*/
((DefaultAttribute) attribute).setValue(4.5f);
- quality = attribute.validate();
+ quality = attribute.quality();
assertEquals("scope.level", ScopeCode.ATTRIBUTE, quality.getScope().getLevel());
assertDomainConsistencyEquals("population", "Property “population” does not accept
instances of ‘Float’.",
(DomainConsistency) getSingleton(quality.getReports()));
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterDescriptorGroup.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -156,6 +156,8 @@ public class DefaultParameterDescriptorG
* @param maximumOccurs The {@linkplain #getMaximumOccurs() maximum number of times}
* that values for this parameter group are required.
* @param parameters The {@linkplain #descriptors() parameter descriptors} for this
group.
+ *
+ * @throws InvalidParameterNameException If a parameter name is duplicated.
*/
public DefaultParameterDescriptorGroup(final Map<String,?> properties,
final int minimumOccurs, final int maximumOccurs, GeneralParameterDescriptor...
parameters)
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java?rev=1596278&r1=1596277&r2=1596278&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/package-info.java
[UTF-8] Tue May 20 14:53:16 2014
@@ -67,7 +67,7 @@
* }
* </div>
*
- * Calls to {@code parameter(…)} throw a {@link org.opengis.parameter.InvalidParameterNameException}
+ * Calls to {@code parameter(…)} throw a {@link org.opengis.parameter.ParameterNotFoundException}
* if the given name is unknown to the group.
* Calls to {@code setValue(…)} throw a {@link org.opengis.parameter.InvalidParameterValueException}
* if the given value is not assignable to the expected class or is not inside the value
domain.
|