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 2015/07/09 15:31:01 UTC
svn commit: r1690101 [1/3] - in /sis/branches/JDK7: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/io/wkt/
core/sis-metadata/src/main/java/org/apache/sis/metadata/
core/sis-metadata/s...
Author: desruisseaux
Date: Thu Jul 9 13:31:00 2015
New Revision: 1690101
URL: http://svn.apache.org/r1690101
Log:
Merge the WKT and logging consolidation from the JDK8 branch.
Added:
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
- copied unchanged from r1690098, sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Loggers.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/system/LoggersTest.java
- copied unchanged from r1690098, sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/internal/system/LoggersTest.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
- copied unchanged from r1690098, sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LogRecordCollector.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
- copied unchanged from r1690098, sis/branches/JDK8/core/sis-utility/src/test/java/org/apache/sis/test/LoggingWatcher.java
Removed:
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
Modified:
sis/branches/JDK7/ (props changed)
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultNominalResolution.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultDimension.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeometricObjects.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java
sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGridSpatialRepresentation.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescriptionTest.java
sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectifiedTest.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/SecondDefiningParameter.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ReferencingUtilities.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CommonCRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/AbstractCRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultDerivedCRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/crs/DefaultProjectedCRS.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DefaultCoordinateSystemAxis.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/cs/DirectionAlongMeridian.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultEllipsoid.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/datum/DefaultGeodeticDatum.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ContextualParameters.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/io/wkt/GeodeticObjectParserTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultProjectedCRSTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/HardCodedCRS.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
sis/branches/JDK7/core/sis-utility/pom.xml
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_CharacterString.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/Measure.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/ObjectReference.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/SC_VerticalCRS.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DelayedExecutor.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Modules.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/ReferenceQueueConsumer.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Shutdown.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Supervisor.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/Threads.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/CheckedArrayList.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/Locales.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/WeakEntry.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultInternationalString.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/Types.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages.properties
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Messages_fr.properties
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/LegacyCodes.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestRunner.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
sis/branches/JDK7/storage/sis-netcdf/src/test/java/org/apache/sis/internal/netcdf/TestCase.java
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 9 13:31:00 2015
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
/sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1689672
+/sis/branches/JDK8:1584960-1690098
/sis/trunk:1394364-1508466,1519089-1519674
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/AxisNames.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -20,6 +20,7 @@ import java.util.Map;
import java.util.HashMap;
import java.lang.reflect.Field;
import org.apache.sis.util.logging.Logging;
+import org.apache.sis.internal.system.Modules;
// Branch-specific imports
import org.apache.sis.internal.jdk8.JDK8;
@@ -156,7 +157,7 @@ public final class AxisNames {
* We will take the values that we have been able to map so far. The other values will
* just not have their case fixed.
*/
- Logging.unexpectedException(AxisNames.class, "<cinit>", e);
+ Logging.unexpectedException(Logging.getLogger(Modules.REFERENCING), AxisNames.class, "<cinit>", e);
}
VALUES = values;
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -182,7 +182,7 @@ public abstract class LegacyPropertyAdap
public static void warnIgnoredExtraneous(final Class<?> valueClass,
final Class<?> callerClass, final String callerMethod)
{
- Context.warningOccured(Context.current(), ISOMetadata.LOGGER, callerClass, callerMethod,
+ Context.warningOccured(Context.current(), callerClass, callerMethod,
Messages.class, Messages.Keys.IgnoredPropertiesAfterFirst_1, valueClass);
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -31,7 +31,7 @@ import org.apache.sis.internal.jaxb.Cont
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.5
+ * @version 0.6
* @module
*/
public final class MetadataUtilities extends Static {
@@ -85,66 +85,68 @@ public final class MetadataUtilities ext
}
/**
- * Convenience method invoked when an argument was expected to be positive, but the user gave a negative value
- * or (in some case) zero. This method logs a warning if we are in process of (un)marshalling a XML document,
- * or throw an exception otherwise.
- *
- * <p><b>When to use:</b></p>
- * <ul>
- * <li>This method is for setter methods that may be invoked by JAXB. Constructors or methods ignored
- * by JAXB should use the simpler {@link org.apache.sis.util.ArgumentChecks} class instead.</li>
- * <li>This method should be invoked only when ignoring the warning will not cause information lost.
- * The stored metadata value may be invalid, but not lost.</li>
- * </ul>
- * <div class="note"><b>Note:</b> the later point is the reason why problems during XML (un)marshalling
- * are only warnings for this method, while they are errors by default for
- * {@link org.apache.sis.xml.ValueConverter} (the later can not store the value in case of error).</div>
+ * Ensures that the given property value is positive. If the user gave a negative value or (in some case) zero,
+ * then this method logs a warning if we are in process of (un)marshalling a XML document or throw an exception
+ * otherwise.
*
- * @param classe The caller class.
+ * @param classe The class which invoke this method.
* @param property The property name. Method name will be inferred by the usual Java bean convention.
* @param strict {@code true} if the value was expected to be strictly positive, or {@code false} if 0 is accepted.
- * @param value The invalid argument value.
- * @throws IllegalArgumentException if we are not (un)marshalling a XML document.
+ * @param newValue The argument value to verify.
+ * @return {@code true} if the value is valid.
+ * @throws IllegalArgumentException if the given value is negative and the problem has not been logged.
*/
- public static void warnNonPositiveArgument(final Class<?> classe, final String property, final boolean strict,
- final Number value) throws IllegalArgumentException
+ public static boolean ensurePositive(final Class<?> classe,
+ final String property, final boolean strict, final Number newValue) throws IllegalArgumentException
{
- final String msg = logOrFormat(classe, property,
- strict ? Errors.Keys.ValueNotGreaterThanZero_2 : Errors.Keys.NegativeArgument_2, property, value);
- if (msg != null) {
- throw new IllegalArgumentException(msg);
+ if (newValue != null) {
+ final double value = newValue.doubleValue();
+ if (!(strict ? value > 0 : value >= 0)) { // Use '!' for catching NaN.
+ if (NilReason.forObject(newValue) == null) {
+ final String msg = logOrFormat(classe, property, strict
+ ? Errors.Keys.ValueNotGreaterThanZero_2
+ : Errors.Keys.NegativeArgument_2, property, newValue);
+ if (msg != null) {
+ throw new IllegalArgumentException(msg);
+ }
+ return false;
+ }
+ }
}
+ return true;
}
/**
- * Convenience method invoked when an argument is outside the expected range of values. This method logs
- * a warning if we are in process of (un)marshalling a XML document, or throw an exception otherwise.
+ * Ensures that the given argument is either null or between the given minimum and maximum values.
+ * If the user argument is outside the expected range of values, then this method logs a warning
+ * if we are in process of (un)marshalling a XML document or throw an exception otherwise.
*
- * <p><b>When to use:</b></p>
- * <ul>
- * <li>This method is for setter methods that may be invoked by JAXB. Constructors or methods ignored
- * by JAXB should use the simpler {@link org.apache.sis.util.ArgumentChecks} class instead.</li>
- * <li>This method should be invoked only when ignoring the warning will not cause information lost.
- * The stored metadata value may be invalid, but not lost.</li>
- * </ul>
- * <div class="note"><b>Note:</b> the later point is the reason why problems during XML (un)marshalling
- * are only warnings for this method, while they are errors by default for
- * {@link org.apache.sis.xml.ValueConverter} (the later can not store the value in case of error).</div>
- *
- * @param classe The caller class.
- * @param property The property name. Method name will be inferred by the usual Java bean convention.
+ * @param classe The class which invoke this method.
+ * @param property Name of the property to check.
* @param minimum The minimal legal value.
* @param maximum The maximal legal value.
- * @param value The invalid argument value.
- * @throws IllegalArgumentException if we are not (un)marshalling a XML document.
- */
- public static void warnOutOfRangeArgument(final Class<?> classe, final String property,
- final Number minimum, final Number maximum, final Number value) throws IllegalArgumentException
+ * @param newValue The value given by the user.
+ * @return {@code true} if the value is valid.
+ * @throws IllegalArgumentException if the given value is out of range and the problem has not been logged.
+ */
+ public static boolean ensureInRange(final Class<?> classe, final String property,
+ final Number minimum, final Number maximum, final Number newValue)
+ throws IllegalArgumentException
{
- final String msg = logOrFormat(classe, property, Errors.Keys.ValueOutOfRange_4, property, minimum, maximum, value);
- if (msg != null) {
- throw new IllegalArgumentException(msg);
+ if (newValue != null) {
+ final double value = newValue.doubleValue();
+ if (!(value >= minimum.doubleValue() && value <= maximum.doubleValue())) { // Use '!' for catching NaN.
+ if (NilReason.forObject(newValue) == null) {
+ final String msg = logOrFormat(classe, property,
+ Errors.Keys.ValueOutOfRange_4, property, minimum, maximum, newValue);
+ if (msg != null) {
+ throw new IllegalArgumentException(msg);
+ }
+ return false;
+ }
+ }
}
+ return true;
}
/**
@@ -164,7 +166,7 @@ public final class MetadataUtilities ext
} else {
final StringBuilder buffer = new StringBuilder(property.length() + 3).append("set").append(property);
buffer.setCharAt(3, Character.toUpperCase(buffer.charAt(3)));
- Context.warningOccured(context, ISOMetadata.LOGGER, classe, buffer.toString(), Errors.class, key, arguments);
+ Context.warningOccured(context, classe, buffer.toString(), Errors.class, key, arguments);
return null;
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -33,6 +33,7 @@ import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import org.opengis.util.FactoryException;
import org.opengis.util.InternationalString;
+import org.apache.sis.internal.system.Loggers;
import org.apache.sis.internal.util.StandardDateFormat;
import org.apache.sis.measure.Units;
import org.apache.sis.util.Workaround;
@@ -93,7 +94,7 @@ abstract class AbstractParser implements
* This happen most often when the user invoke the {@link org.apache.sis.referencing.CRS#fromWKT(String)}
* convenience method.
*/
- private static final Logger LOGGER = Logging.getLogger(AbstractParser.class);
+ private static final Logger LOGGER = Logging.getLogger(Loggers.WKT);
/**
* The locale for error messages (not for number parsing), or {@code null} for the system default.
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -79,14 +79,18 @@ public enum Convention {
* <ul>
* <li>{@code PrimeMeridian} element omitted if the meridian is Greenwich.</li>
* <li>{@code Axis} element omits the {@code Order} sub-element.</li>
- * <li>{@code VerticalExtent} element omits the {@code LengthUnit} sub-element
- * if the unit is {@link javax.measure.unit.SI#METRE}.</li>
- * <li>{@code Ellipsoid} element omits the {@code LengthUnit} sub-element
- * if the unit is {@link javax.measure.unit.SI#METRE}.</li>
- * <li>{@code PrimeMeridian} element omits the {@code AngleUnit} sub-element
- * if the unit is as defined by the enclosing {@code GeodeticCRS} element.</li>
- * <li>{@code AngleUnit}, {@code LengthUnit}, {@code ScaleUnit}, {@code ParametricUnit}
- * and {@code TimeUnit} are formatted as plain {@code Unit} elements.</li>
+ * <li>{@code Unit} elements are less verbose:<ul>
+ * <li>{@code Ellipsoid} and {@code VerticalExtent} elements omit the {@code LengthUnit} sub-element
+ * if that unit is {@link javax.measure.unit.SI#METRE}.</li>
+ * <li>{@code Parameter} elements omit the {@code LengthUnit} sub-element
+ * if that unit is the same than the unit of the {@code ProjectedCRS} axes.</li>
+ * <li>{@code Parameter} and {@code PrimeMeridian} elements omit the {@code AngleUnit} sub-element
+ * if that unit is the same than the unit of the {@code GeodeticCRS} axes.</li>
+ * <li>Axes unit is declared only once after the axes instead than repeated for each axis
+ * if the unit is the same for all axes.</li>
+ * <li>{@code AngleUnit}, {@code LengthUnit}, {@code ScaleUnit}, {@code ParametricUnit}
+ * and {@code TimeUnit} are formatted as plain {@code Unit} elements.</li>
+ * </ul></li>
* <li>{@code Id} is formatted only for the root element
* (omit parameters and operation methods {@code Id}).</li>
* </ul>
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -47,6 +47,7 @@ import org.opengis.parameter.GeneralPara
import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.ReferenceSystem;
import org.opengis.referencing.datum.Datum;
+import org.opengis.referencing.crs.CompoundCRS;
import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.operation.OperationMethod;
import org.opengis.referencing.operation.CoordinateOperation;
@@ -285,7 +286,7 @@ public class Formatter implements Locali
* {@code ID} (previously known as {@code AUTHORITY}) and {@code REMARKS}, and have a special treatment: they
* are written by {@link #append(FormattableObject)} after the {@code formatTo(Formatter)} method returned.
*
- * @see #appendComplement(IdentifiedObject, boolean)
+ * @see #appendComplement(IdentifiedObject, FormattableObject)
*/
private boolean isComplement;
@@ -614,7 +615,7 @@ public class Formatter implements Locali
* GEOGCS[...etc...],
* ...etc...
*/
- final IdentifiedObject info = (object instanceof IdentifiedObject) ? (IdentifiedObject) object : null;
+ IdentifiedObject info = (object instanceof IdentifiedObject) ? (IdentifiedObject) object : null;
String keyword = object.formatTo(this);
if (keyword == null) {
if (info != null) {
@@ -640,10 +641,11 @@ public class Formatter implements Locali
* Format the SCOPE["…"], AREA["…"] and other elements. Some of those information
* are available only for Datum, CoordinateOperation and ReferenceSystem objects.
*/
+ if (info == null && convention.majorVersion() != 1 && object instanceof GeneralParameterValue) {
+ info = ((GeneralParameterValue) object).getDescriptor();
+ }
if (info != null) {
- appendComplement(info, stackDepth == 0);
- } else if (convention.majorVersion() != 1 && object instanceof GeneralParameterValue) {
- appendComplement(((GeneralParameterValue) object).getDescriptor(), false);
+ appendComplement(info, (stackDepth != 0) ? enclosingElements.get(stackDepth - 1) : null);
}
buffer.appendCodePoint(symbols.getClosingBracket(0));
indent(-1);
@@ -681,7 +683,7 @@ public class Formatter implements Locali
* A {@code <remark>} can be included within the descriptions of source and target CRS embedded within
* a coordinate transformation as well as within the coordinate transformation itself.</blockquote>
*/
- private void appendComplement(final IdentifiedObject object, final boolean isRoot) {
+ private void appendComplement(final IdentifiedObject object, final FormattableObject parent) {
isComplement = true;
final boolean showIDs; // Whether to format ID[…] elements.
final boolean filterID; // Whether we shall limit to a single ID[…] element.
@@ -693,23 +695,34 @@ public class Formatter implements Locali
showOthers = true;
showRemarks = true;
} else {
- if (convention == Convention.WKT2_SIMPLIFIED) {
- showIDs = isRoot;
+ /*
+ * Except for the special cases of OperationMethod and Parameters, ISO 19162 recommends to format the
+ * ID only for the root element. But Apache SIS adds an other exception to this rule by handling the
+ * components of CompoundCRS as if they were root elements. The reason is that users often create their
+ * own CompoundCRS from standard components, for example by adding a time axis to some standard CRS like
+ * "WGS84". The resulting CompoundCRS usually have no identifier. Then the users often need to extract a
+ * particular component of a CompoundCRS, most often the horizontal part, and will need its identifier
+ * for example in a Web Map Service (WMS). Those ID are lost if we do not format them here.
+ */
+ if (parent == null || parent instanceof CompoundCRS) {
+ showIDs = true;
+ } else if (convention == Convention.WKT2_SIMPLIFIED) {
+ showIDs = false;
} else {
- showIDs = isRoot || (object instanceof OperationMethod) || (object instanceof GeneralParameterDescriptor);
+ showIDs = (object instanceof OperationMethod) || (object instanceof GeneralParameterDescriptor);
}
if (convention.majorVersion() == 1) {
filterID = true;
showOthers = false;
showRemarks = false;
} else {
- filterID = !isRoot;
+ filterID = (parent != null);
if (object instanceof CoordinateOperation) {
showOthers = true;
showRemarks = true;
} else if (object instanceof ReferenceSystem) {
- showOthers = isRoot;
- showRemarks = isRoot || (getEnclosingElement(2) instanceof CoordinateOperation);
+ showOthers = (parent == null);
+ showRemarks = (parent == null) || (getEnclosingElement(2) instanceof CoordinateOperation);
} else {
showOthers = false; // Mandated by ISO 19162.
showRemarks = false;
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -232,19 +232,22 @@ final class GeodeticObjectParser extends
csFactory = getFactory(CSFactory.class, factories);
datumFactory = getFactory(DatumFactory.class, factories);
referencing = ReferencingServices.getInstance();
- opFactory = referencing.getCoordinateOperationFactory(null, mtFactory);
usesCommonUnits = convention.usesCommonUnits;
ignoreAxes = convention == Convention.WKT1_IGNORE_AXES;
+ final Factory f = factories.get(CoordinateOperationFactory.class);
+ if (f != null) {
+ opFactory = (CoordinateOperationFactory) f;
+ } else {
+ opFactory = referencing.getCoordinateOperationFactory(null, mtFactory);
+ factories.put(CoordinateOperationFactory.class, opFactory);
+ }
}
/**
- * Returns the factory of the given type. This method will fetch the factory from the given
- * map if non-null. The factory actually used is stored in the map, unless the map is null.
+ * Returns the factory of the given type. This method fetches the factory from the given map.
+ * The factory actually used is stored in the map.
*/
- private static <T extends Factory> T getFactory(final Class<T> type, final Map<Class<?>,Factory> factories) {
- if (factories == null) {
- return DefaultFactories.forBuildin(type);
- }
+ static <T extends Factory> T getFactory(final Class<T> type, final Map<Class<?>,Factory> factories) {
T factory = type.cast(factories.get(type));
if (factory == null) {
factory = DefaultFactories.forBuildin(type);
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -19,6 +19,7 @@ package org.apache.sis.io.wkt;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
+import java.util.Set;
import java.util.Map;
import java.util.HashMap;
import java.util.TreeMap;
@@ -34,6 +35,11 @@ import org.opengis.util.Factory;
import org.opengis.util.InternationalString;
import org.opengis.metadata.citation.Citation;
import org.opengis.referencing.IdentifiedObject;
+import org.opengis.referencing.cs.CSFactory;
+import org.opengis.referencing.crs.CRSFactory;
+import org.opengis.referencing.datum.DatumFactory;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.referencing.operation.CoordinateOperationFactory;
import org.apache.sis.io.CompoundFormat;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.ArgumentChecks;
@@ -177,6 +183,8 @@ public class WKTFormat extends CompoundF
/**
* WKT fragments that can be inserted in longer WKT strings, or {@code null} if none. Keys are short identifiers
* and values are WKT subtrees to substitute to the identifiers when they are found in a WKT to parse.
+ *
+ * @see #fragments()
*/
private Map<String,Element> fragments;
@@ -203,7 +211,11 @@ public class WKTFormat extends CompoundF
private transient AbstractParser parser;
/**
- * The factories needed by the parser. Will be created when first needed.
+ * The factories needed by the parser. Those factories are currently not serialized (because usually not
+ * serializable), so any value that users may have specified with {@link #setFactory(Class, Factory)}
+ * will be lost at serialization time.
+ *
+ * @see #factories()
*/
private transient Map<Class<?>,Factory> factories;
@@ -230,6 +242,26 @@ public class WKTFormat extends CompoundF
}
/**
+ * Returns the {@link #fragments} map, creating it when first needed.
+ */
+ private Map<String,Element> fragments() {
+ if (fragments == null) {
+ fragments = new TreeMap<>();
+ }
+ return fragments;
+ }
+
+ /**
+ * Returns the {@link #factories} map, creating it when first needed.
+ */
+ private Map<Class<?>,Factory> factories() {
+ if (factories == null) {
+ factories = new HashMap<>(8);
+ }
+ return factories;
+ }
+
+ /**
* Returns the locale for the given category. This method implements the following mapping:
*
* <ul>
@@ -513,6 +545,68 @@ public class WKTFormat extends CompoundF
}
/**
+ * Verifies if the given type is a valid key for the {@link #factories} map.
+ */
+ private void ensureValidFactoryType(final Class<?> type) throws IllegalArgumentException {
+ ArgumentChecks.ensureNonNull("type", type);
+ if (type != CRSFactory.class &&
+ type != CSFactory.class &&
+ type != DatumFactory.class &&
+ type != MathTransformFactory.class &&
+ type != CoordinateOperationFactory.class)
+ {
+ throw new IllegalArgumentException(Errors.getResources(getLocale())
+ .getString(Errors.Keys.IllegalArgumentValue_2, "type", type));
+ }
+ }
+
+ /**
+ * Returns one of the factories used by this {@code WKTFormat} for parsing WKT.
+ * The given {@code type} argument can be one of the following values:
+ *
+ * <ul>
+ * <li><code>{@linkplain CRSFactory}.class</code></li>
+ * <li><code>{@linkplain CSFactory}.class</code></li>
+ * <li><code>{@linkplain DatumFactory}.class</code></li>
+ * <li><code>{@linkplain MathTransformFactory}.class</code></li>
+ * <li><code>{@linkplain CoordinateOperationFactory}.class</code></li>
+ * </ul>
+ *
+ * @param <T> The compile-time type of the {@code type} argument.
+ * @param type The factory type.
+ * @return The factory used by this {@code WKTFormat} for the given type.
+ * @throws IllegalArgumentException if the {@code type} argument is not one of the valid values.
+ */
+ public <T extends Factory> T getFactory(final Class<T> type) {
+ ensureValidFactoryType(type);
+ return GeodeticObjectParser.getFactory(type, factories());
+ }
+
+ /**
+ * Sets one of the factories to be used by this {@code WKTFormat} for parsing WKT.
+ * The given {@code type} argument can be one of the following values:
+ *
+ * <ul>
+ * <li><code>{@linkplain CRSFactory}.class</code></li>
+ * <li><code>{@linkplain CSFactory}.class</code></li>
+ * <li><code>{@linkplain DatumFactory}.class</code></li>
+ * <li><code>{@linkplain MathTransformFactory}.class</code></li>
+ * <li><code>{@linkplain CoordinateOperationFactory}.class</code></li>
+ * </ul>
+ *
+ * @param <T> The compile-time type of the {@code type} argument.
+ * @param type The factory type.
+ * @param factory The factory to be used by this {@code WKTFormat} for the given type.
+ * @throws IllegalArgumentException if the {@code type} argument is not one of the valid values.
+ */
+ public <T extends Factory> void setFactory(final Class<T> type, final T factory) {
+ ensureValidFactoryType(type);
+ if (factories().put(type, factory) != factory) {
+ parser = null;
+ }
+ }
+
+ /**
* Returns the type of objects formatted by this class. This method has to return {@code Object.class}
* since it is the only common parent to all object types accepted by this formatter.
*
@@ -524,27 +618,17 @@ public class WKTFormat extends CompoundF
}
/**
- * Creates an object from the given character sequence.
- * The parsing begins at the index given by the {@code pos} argument.
+ * Returns the name of all WKT fragments known to this {@code WKTFormat}.
+ * The returned collection is initially empty.
+ * WKT fragments can be added by call to {@link #addFragment(String, String)}.
*
- * @param wkt The character sequence for the object to parse.
- * @param pos The position where to start the parsing.
- * @return The parsed object.
- * @throws ParseException If an error occurred while parsing the WKT.
+ * <p>The returned collection is modifiable. In particular, a call to {@link Set#clear()}
+ * removes all fragments from this {@code WKTFormat}.</p>
+ *
+ * @return The name of all fragments known to this {@code WKTFormat}.
*/
- @Override
- public Object parse(final CharSequence wkt, final ParsePosition pos) throws ParseException {
- warnings = null;
- sharedValues = null;
- ArgumentChecks.ensureNonEmpty("wkt", wkt);
- ArgumentChecks.ensureNonNull ("pos", pos);
- final AbstractParser parser = parser();
- Object object = null;
- try {
- return object = parser.parseObject(wkt.toString(), pos);
- } finally {
- warnings = parser.getAndClearWarnings(object);
- }
+ public Set<String> getFragmentNames() {
+ return fragments().keySet();
}
/**
@@ -566,16 +650,18 @@ public class WKTFormat extends CompoundF
* }
* </div>
*
- * @param identifier The name to assign to the WKT fragment. Identifiers are case-sensitive.
+ * For removing a fragment, use <code>{@linkplain #getFragmentNames()}.remove(name)</code>.
+ *
+ * @param name The name to assign to the WKT fragment. Identifiers are case-sensitive.
* @param wkt The Well Know Text (WKT) fragment represented by the given identifier.
* @throws IllegalArgumentException if the name is invalid or if a fragment is already present for that name.
* @throws ParseException If an error occurred while parsing the given WKT.
*/
- public void addFragment(final String identifier, final String wkt) throws IllegalArgumentException, ParseException {
+ public void addFragment(final String name, final String wkt) throws IllegalArgumentException, ParseException {
ArgumentChecks.ensureNonEmpty("wkt", wkt);
- ArgumentChecks.ensureNonEmpty("identifier", identifier);
+ ArgumentChecks.ensureNonEmpty("name", name);
short error = Errors.Keys.NotAUnicodeIdentifier_1;
- if (CharSequences.isUnicodeIdentifier(identifier)) {
+ if (CharSequences.isUnicodeIdentifier(name)) {
if (sharedValues == null) {
sharedValues = new HashMap<>();
}
@@ -584,22 +670,38 @@ public class WKTFormat extends CompoundF
final int index = CharSequences.skipLeadingWhitespaces(wkt, pos.getIndex(), wkt.length());
if (index < wkt.length()) {
throw new LocalizedParseException(getLocale(), Errors.Keys.UnexpectedCharactersAfter_2,
- new Object[] {identifier + " = " + element.keyword + "[…]", CharSequences.token(wkt, index)}, index);
+ new Object[] {name + " = " + element.keyword + "[…]", CharSequences.token(wkt, index)}, index);
}
- if (JDK8.putIfAbsent(fragments, identifier, element) == null) {
+ // 'fragments' map has been created by 'parser()'.
+ if (JDK8.putIfAbsent(fragments, name, element) == null) {
return;
}
error = Errors.Keys.ElementAlreadyPresent_1;
}
- throw new IllegalArgumentException(Errors.getResources(getLocale()).getString(error, identifier));
+ throw new IllegalArgumentException(Errors.getResources(getLocale()).getString(error, name));
}
/**
- * Removes all fragments previously added by {@link #addFragment(String, String)}.
+ * Creates an object from the given character sequence.
+ * The parsing begins at the index given by the {@code pos} argument.
+ *
+ * @param wkt The character sequence for the object to parse.
+ * @param pos The position where to start the parsing.
+ * @return The parsed object.
+ * @throws ParseException If an error occurred while parsing the WKT.
*/
- public void removeAllFragments() {
- if (fragments != null) {
- fragments.clear();
+ @Override
+ public Object parse(final CharSequence wkt, final ParsePosition pos) throws ParseException {
+ warnings = null;
+ sharedValues = null;
+ ArgumentChecks.ensureNonEmpty("wkt", wkt);
+ ArgumentChecks.ensureNonNull ("pos", pos);
+ final AbstractParser parser = parser();
+ Object object = null;
+ try {
+ return object = parser.parseObject(wkt.toString(), pos);
+ } finally {
+ warnings = parser.getAndClearWarnings(object);
}
}
@@ -609,20 +711,14 @@ public class WKTFormat extends CompoundF
private AbstractParser parser() {
AbstractParser parser = this.parser;
if (parser == null) {
- if (fragments == null) {
- fragments = new TreeMap<>();
- }
- if (factories == null) {
- factories = new HashMap<>();
- }
- this.parser = parser = new GeodeticObjectParser(symbols, fragments,
+ this.parser = parser = new GeodeticObjectParser(symbols, fragments(),
(NumberFormat) getFormat(Number.class),
(DateFormat) getFormat(Date.class),
(UnitFormat) getFormat(Unit.class),
convention,
(transliterator != null) ? transliterator : Transliterator.DEFAULT,
getLocale(),
- factories);
+ factories());
}
return parser;
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/AbstractMetadata.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -17,14 +17,12 @@
package org.apache.sis.metadata;
import java.util.Map;
-import java.util.logging.Logger;
import javax.xml.bind.annotation.XmlTransient;
import org.apache.sis.internal.system.Semaphores;
import org.apache.sis.util.Emptiable;
import org.apache.sis.util.ComparisonMode;
import org.apache.sis.util.LenientComparable;
import org.apache.sis.util.collection.TreeTable;
-import org.apache.sis.util.logging.Logging;
/**
@@ -81,18 +79,6 @@ import org.apache.sis.util.logging.Loggi
@XmlTransient
public abstract class AbstractMetadata implements LenientComparable, Emptiable {
/**
- * The logger for messages related to metadata implementations.
- *
- * Note that another logger is provided with public access in the {@code iso} sub-package:
- * {@link org.apache.sis.metadata.iso.ISOMetadata#LOGGER}. This {@code LOGGER} instance is
- * kept package-privated for avoiding confusion (other sub-packages like {@code sql} should
- * create their own logger). This logger is declared in a static field because otherwise,
- * any configuration done by the user may be lost when the garbage-collector collects the
- * logger.
- */
- static final Logger LOGGER = Logging.getLogger(AbstractMetadata.class);
-
- /**
* Creates an initially empty metadata.
*/
protected AbstractMetadata() {
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/ModifiableMetadata.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -34,6 +34,7 @@ import org.apache.sis.util.collection.Co
import org.apache.sis.internal.util.CheckedHashSet;
import org.apache.sis.internal.util.CheckedArrayList;
import org.apache.sis.internal.system.Semaphores;
+import org.apache.sis.internal.system.Modules;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -191,7 +192,7 @@ public abstract class ModifiableMetadata
* (for example it may be backed by some external database).
* Assumes that the metadata is unmodifiable.
*/
- Logging.unexpectedException(LOGGER, getClass(), "unmodifiable", exception);
+ Logging.unexpectedException(Logging.getLogger(Modules.METADATA), getClass(), "unmodifiable", exception);
return this;
}
candidate.freeze();
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyInformation.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -29,6 +29,7 @@ import org.opengis.metadata.citation.Res
import org.opengis.util.CodeList;
import org.opengis.util.InternationalString;
import org.apache.sis.internal.simple.SimpleIdentifier;
+import org.apache.sis.internal.system.Modules;
import org.apache.sis.measure.ValueRange;
import org.apache.sis.util.iso.Types;
import org.apache.sis.util.Numbers;
@@ -289,7 +290,8 @@ final class PropertyInformation<E> exten
* to have an IllegalArgumentException while he didn't provided any argument.
* Returning null as a fallback is compliant with the method contract.
*/
- Logging.unexpectedException(PropertyInformation.class, "getDomainValue", e);
+ Logging.unexpectedException(Logging.getLogger(Modules.METADATA),
+ PropertyInformation.class, "getDomainValue", e);
domain = null;
}
domainValue = domain;
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -23,6 +23,7 @@ import org.opengis.annotation.Classifier
import org.opengis.annotation.Stereotype;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.logging.Logging;
+import org.apache.sis.internal.system.Modules;
/**
@@ -156,7 +157,8 @@ final class StandardImplementation exten
implementations.put(type, candidate);
return candidate.asSubclass(type);
} catch (ClassNotFoundException e) {
- Logging.recoverableException(MetadataStandard.class, "getImplementation", e);
+ Logging.recoverableException(Logging.getLogger(Modules.METADATA),
+ MetadataStandard.class, "getImplementation", e);
}
implementations.put(type, Void.TYPE); // Marker for "class not found".
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -31,7 +31,7 @@ import org.apache.sis.measure.ValueRange
import org.apache.sis.util.iso.Types;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -440,10 +440,9 @@ public class DefaultExtendedElementInfor
*/
public void setMaximumOccurrence(final Integer newValue) {
checkWritePermission();
- if (newValue != null && newValue < 0) {
- warnNonPositiveArgument(DefaultExtendedElementInformation.class, "maximumOccurrence", false, newValue);
+ if (ensurePositive(DefaultExtendedElementInformation.class, "maximumOccurrence", false, newValue)) {
+ maximumOccurrence = newValue;
}
- maximumOccurrence = newValue;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -31,6 +31,7 @@ import org.apache.sis.xml.IdentifiedObje
import org.apache.sis.metadata.MetadataStandard;
import org.apache.sis.metadata.ModifiableMetadata;
import org.apache.sis.internal.jaxb.IdentifierMapWithSpecialCases;
+import org.apache.sis.internal.system.Loggers;
import org.apache.sis.util.collection.Containers;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.CharSequences;
@@ -68,8 +69,11 @@ public class ISOMetadata extends Modifia
* Warnings are emitted when an action causes the lost of data. For example the {@code "distance"} and
* {@code "equivalentScale"} properties in {@link org.apache.sis.metadata.iso.identification.DefaultResolution}
* are mutually exclusive: setting one discards the other. In such case, a warning is logged.
+ *
+ * @deprecated Messages related to XML (un)marshalling are now logged to the {@code "org.apache.sis.xml"} logger.
*/
- public static final Logger LOGGER = Logging.getLogger(ISOMetadata.class);
+ @Deprecated
+ public static final Logger LOGGER = Logging.getLogger(Loggers.ISO_19115);
/**
* All identifiers associated with this metadata, or {@code null} if none.
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -24,7 +24,7 @@ import org.opengis.util.InternationalStr
import org.apache.sis.measure.ValueRange;
import org.apache.sis.metadata.iso.ISOMetadata;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnOutOfRangeArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensureInRange;
/**
@@ -176,10 +176,9 @@ public class DefaultEnvironmentalRecord
*/
public void setMaxRelativeHumidity(final Double newValue) {
checkWritePermission();
- if (newValue != null && !(newValue >= 0 && newValue <= 100)) { // Use '!' for catching NaN.
- warnOutOfRangeArgument(DefaultEnvironmentalRecord.class, "maxRelativeHumidity", 0, 100, newValue);
+ if (ensureInRange(DefaultEnvironmentalRecord.class, "maxRelativeHumidity", 0, 100, newValue)) {
+ maxRelativeHumidity = newValue;
}
- maxRelativeHumidity = newValue;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -232,7 +232,7 @@ public class DefaultContact extends ISOM
}
}
if (ignored != null) {
- Context.warningOccured(Context.current(), LOGGER, DefaultContact.class, "getPhone",
+ Context.warningOccured(Context.current(), DefaultContact.class, "getPhone",
Messages.class, Messages.Keys.IgnoredPropertyAssociatedTo_1, ignored.toString());
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -29,7 +29,7 @@ import org.opengis.metadata.content.Tran
import org.apache.sis.xml.Namespaces;
import org.apache.sis.measure.ValueRange;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -199,8 +199,9 @@ public class DefaultBand extends Default
*/
public void setBoundMin(final Double newValue) {
checkWritePermission();
- ensurePositive("boundMin", false, newValue);
- boundMin = newValue;
+ if (ensurePositive(DefaultBand.class, "boundMin", false, newValue)) {
+ boundMin = newValue;
+ }
}
/**
@@ -229,8 +230,9 @@ public class DefaultBand extends Default
*/
public void setBoundMax(final Double newValue) {
checkWritePermission();
- ensurePositive("boundMax", false, newValue);
- boundMax = newValue;
+ if (ensurePositive(DefaultBand.class, "boundMax", false, newValue)) {
+ boundMax = newValue;
+ }
}
/**
@@ -300,8 +302,9 @@ public class DefaultBand extends Default
*/
public void setPeakResponse(final Double newValue) {
checkWritePermission();
- ensurePositive("peakResponse", false, newValue);
- peakResponse = newValue;
+ if (ensurePositive(DefaultBand.class, "peakResponse", false, newValue)) {
+ peakResponse = newValue;
+ }
}
/**
@@ -341,10 +344,9 @@ public class DefaultBand extends Default
*/
public void setToneGradation(final Integer newValue) {
checkWritePermission();
- if (newValue != null && newValue < 0) {
- warnNonPositiveArgument(DefaultBand.class, "toneGradation", false, newValue);
+ if (ensurePositive(DefaultBand.class, "toneGradation", false, newValue)) {
+ toneGradation = newValue;
}
- toneGradation = newValue;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureTypeInfo.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -24,7 +24,7 @@ import org.opengis.metadata.content.Feat
import org.apache.sis.measure.ValueRange;
import org.apache.sis.metadata.iso.ISOMetadata;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -173,9 +173,8 @@ public class DefaultFeatureTypeInfo exte
*/
public void setFeatureInstanceCount(final Integer newValue) {
checkWritePermission();
- if (newValue != null && newValue < 0) {
- warnNonPositiveArgument(DefaultFeatureTypeInfo.class, "featureInstanceCount", true, newValue);
+ if (ensurePositive(DefaultFeatureTypeInfo.class, "featureInstanceCount", true, newValue)) {
+ featureInstanceCount = newValue;
}
- featureInstanceCount = newValue;
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultImageDescription.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -25,8 +25,8 @@ import org.opengis.metadata.content.Imag
import org.opengis.metadata.content.ImagingCondition;
import org.apache.sis.measure.ValueRange;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnOutOfRangeArgument;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensureInRange;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -198,26 +198,6 @@ public class DefaultImageDescription ext
}
/**
- * Ensures that the given argument is either null or between the given minimum and maximum values.
- *
- * @param property Name of the property to check.
- * @param min The minimal legal value.
- * @param max The maximal legal value.
- * @param newValue The value given by the user.
- * @throws IllegalArgumentException if the given value is out of range and the problem has not been logged.
- */
- private static void ensureInRange(final String property, final double min, final double max, final Double newValue)
- throws IllegalArgumentException
- {
- if (newValue != null) {
- final double v = newValue;
- if (!(v >= min && v <= max)) { // Use '!' for catching NaN.
- warnOutOfRangeArgument(DefaultImageDescription.class, property, min, max, v);
- }
- }
- }
-
- /**
* Returns the illumination elevation measured in degrees clockwise from the target plane at
* intersection of the optical line of sight with the Earth's surface.
* For images from a scanning device, refer to the centre pixel of the image.
@@ -243,8 +223,9 @@ public class DefaultImageDescription ext
*/
public void setIlluminationElevationAngle(final Double newValue) {
checkWritePermission();
- ensureInRange("illuminationElevationAngle", -90, +90, newValue);
- illuminationElevationAngle = newValue;
+ if (ensureInRange(DefaultImageDescription.class, "illuminationElevationAngle", -90, +90, newValue)) {
+ illuminationElevationAngle = newValue;
+ }
}
/**
@@ -269,8 +250,9 @@ public class DefaultImageDescription ext
*/
public void setIlluminationAzimuthAngle(final Double newValue) {
checkWritePermission();
- ensureInRange("illuminationAzimuthAngle", 0, 360, newValue);
- illuminationAzimuthAngle = newValue;
+ if (ensureInRange(DefaultImageDescription.class, "illuminationAzimuthAngle", 0, 360, newValue)) {
+ illuminationAzimuthAngle = newValue;
+ }
}
/**
@@ -335,8 +317,9 @@ public class DefaultImageDescription ext
*/
public void setCloudCoverPercentage(final Double newValue) {
checkWritePermission();
- ensureInRange("cloudCoverPercentage", 0, 100, newValue);
- cloudCoverPercentage = newValue;
+ if (ensureInRange(DefaultImageDescription.class, "cloudCoverPercentage", 0, 100, newValue)) {
+ cloudCoverPercentage = newValue;
+ }
}
/**
@@ -384,10 +367,9 @@ public class DefaultImageDescription ext
*/
public void setCompressionGenerationQuantity(final Integer newValue) {
checkWritePermission();
- if (newValue != null && newValue < 0) {
- warnNonPositiveArgument(DefaultImageDescription.class, "compressionGenerationQuantity", false, newValue);
+ if (ensurePositive(DefaultImageDescription.class, "compressionGenerationQuantity", false, newValue)) {
+ compressionGenerationQuantity = newValue;
}
- compressionGenerationQuantity = newValue;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -29,7 +29,7 @@ import org.opengis.util.Record;
import org.opengis.util.RecordType;
import org.apache.sis.measure.ValueRange;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -212,22 +212,6 @@ public class DefaultSampleDimension exte
}
/**
- * Ensures that the given property value is positive.
- *
- * @param property Name of the property to check.
- * @param strict {@code false} is zero is a legal value.
- * @param newValue The property value to verify.
- * @throws IllegalArgumentException if the given value is negative and the problem has not been logged.
- */
- static void ensurePositive(final String property, final boolean strict, final Number newValue)
- throws IllegalArgumentException
- {
- if (newValue != null && !(strict ? newValue.doubleValue() > 0 : newValue.doubleValue() >= 0)) { // Use '!' for catching NaN.
- warnNonPositiveArgument(DefaultSampleDimension.class, property, strict, newValue);
- }
- }
-
- /**
* Returns the minimum value of data values in each dimension included in the resource.
*
* @return Minimum value of data values in each dimension included in the resource, or {@code null} if unspecified.
@@ -310,8 +294,9 @@ public class DefaultSampleDimension exte
*/
public void setNumberOfValues(final Integer newValue) {
checkWritePermission();
- ensurePositive("numberOfValues", false, newValue);
- numberOfValues = newValue;
+ if (ensurePositive(DefaultSampleDimension.class, "numberOfValues", false, newValue)) {
+ numberOfValues = newValue;
+ }
}
/**
@@ -441,8 +426,9 @@ public class DefaultSampleDimension exte
*/
public void setBitsPerValue(final Integer newValue) {
checkWritePermission();
- ensurePositive("bitsPerValue", true, newValue);
- bitsPerValue = newValue;
+ if (ensurePositive(DefaultSampleDimension.class, "bitsPerValue", true, newValue)) {
+ bitsPerValue = newValue;
+ }
}
/**
@@ -466,8 +452,9 @@ public class DefaultSampleDimension exte
*/
public void setNominalSpatialResolution(final Double newValue) {
checkWritePermission();
- ensurePositive("nominalSpatialResolution", true, newValue);
- nominalSpatialResolution = newValue;
+ if (ensurePositive(DefaultSampleDimension.class, "nominalSpatialResolution", true, newValue)) {
+ nominalSpatialResolution = newValue;
+ }
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -30,7 +30,7 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.measure.ValueRange;
import org.apache.sis.metadata.iso.ISOMetadata;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -198,10 +198,9 @@ public class DefaultDigitalTransferOptio
*/
public void setTransferSize(final Double newValue) {
checkWritePermission();
- if (newValue != null && !(newValue >= 0)) { // Use '!' for catching NaN.
- warnNonPositiveArgument(DefaultDigitalTransferOptions.class, "transferSize", true, newValue);
+ if (ensurePositive(DefaultDigitalTransferOptions.class, "transferSize", true, newValue)) {
+ transferSize = newValue;
}
- transferSize = newValue;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -33,7 +33,7 @@ import org.apache.sis.metadata.iso.ISOMe
import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -207,10 +207,9 @@ public class DefaultMedium extends ISOMe
*/
public void setDensity(final Double newValue) {
checkWritePermission();
- if (newValue != null && !(newValue > 0)) { // Use '!' for catching NaN.
- warnNonPositiveArgument(DefaultMedium.class, "density", true, newValue);
+ if (ensurePositive(DefaultMedium.class, "density", true, newValue)) {
+ density = newValue;
}
- density = newValue;
}
/**
@@ -297,10 +296,9 @@ public class DefaultMedium extends ISOMe
*/
public void setVolumes(final Integer newValue) {
checkWritePermission();
- if (newValue != null && newValue < 0) {
- warnNonPositiveArgument(DefaultMedium.class, "volumes", false, newValue);
+ if (ensurePositive(DefaultMedium.class, "volumes", false, newValue)) {
+ volumes = newValue;
}
- volumes = newValue;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -39,7 +39,7 @@ import org.apache.sis.util.Emptiable;
import org.apache.sis.util.resources.Errors;
import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -161,10 +161,9 @@ public class DefaultRepresentativeFracti
* @throws IllegalArgumentException if the given value is negative.
*/
public void setDenominator(final long denominator) {
- if (denominator < 0) {
- warnNonPositiveArgument(DefaultRepresentativeFraction.class, "denominator", false, denominator);
+ if (ensurePositive(DefaultRepresentativeFraction.class, "denominator", false, denominator)) {
+ this.denominator = denominator;
}
- this.denominator = denominator;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -29,7 +29,7 @@ import org.apache.sis.metadata.iso.ISOMe
import org.apache.sis.measure.ValueRange;
import org.apache.sis.util.resources.Messages;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -199,19 +199,6 @@ public class DefaultResolution extends I
}
/**
- * Ensures that the given property is greater than zero.
- *
- * @param property The name of the property to verify.
- * @param value The property value, or {@code null}.
- * @throws IllegalArgumentException if the property is zero or negative and the problem has not been logged.
- */
- private static void ensurePositive(final String property, final Double value) throws IllegalArgumentException {
- if (value != null && !(value > 0)) { // Use '!' for catching NaN.
- warnNonPositiveArgument(DefaultResolution.class, property, true, value);
- }
- }
-
- /**
* Sets the properties identified by the {@code code} argument, if non-null.
* This discards any other properties.
*
@@ -224,7 +211,7 @@ public class DefaultResolution extends I
if (newValue == null) {
return; // Do not erase the other property.
}
- Context.warningOccured(Context.current(), LOGGER, DefaultResolution.class, SETTERS[code-1],
+ Context.warningOccured(Context.current(), DefaultResolution.class, SETTERS[code-1],
Messages.class, Messages.Keys.DiscardedExclusiveProperty_2, NAMES[property-1], NAMES[code-1]);
}
value = newValue;
@@ -279,8 +266,9 @@ public class DefaultResolution extends I
* @throws IllegalArgumentException if the given value is NaN, zero or negative.
*/
public void setDistance(final Double newValue) {
- ensurePositive("distance", newValue);
- setProperty(DISTANCE, newValue);
+ if (ensurePositive(DefaultResolution.class, "distance", true, newValue)) {
+ setProperty(DISTANCE, newValue);
+ }
}
/**
@@ -309,8 +297,9 @@ public class DefaultResolution extends I
* @since 0.5
*/
public void setVertical(final Double newValue) {
- ensurePositive("vertical", newValue);
- setProperty(VERTICAL, newValue);
+ if (ensurePositive(DefaultResolution.class, "vertical", true, newValue)) {
+ setProperty(VERTICAL, newValue);
+ }
}
/**
@@ -339,8 +328,9 @@ public class DefaultResolution extends I
* @since 0.5
*/
public void setAngularDistance(final Double newValue) {
- ensurePositive("angular", newValue);
- setProperty(ANGULAR, newValue);
+ if (ensurePositive(DefaultResolution.class, "angular", true, newValue)) {
+ setProperty(ANGULAR, newValue);
+ }
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultNominalResolution.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultNominalResolution.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultNominalResolution.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultNominalResolution.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -24,7 +24,7 @@ import org.apache.sis.metadata.iso.ISOMe
import org.apache.sis.measure.ValueRange;
import org.apache.sis.xml.Namespaces;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -124,19 +124,6 @@ public class DefaultNominalResolution ex
}
/**
- * Ensures that the given property is greater than zero.
- *
- * @param property The name of the property to verify.
- * @param value The property value, or {@code null}.
- * @throws IllegalArgumentException if the property is zero or negative and the problem has not been logged.
- */
- private static void ensurePositive(final String property, final Double value) throws IllegalArgumentException {
- if (value != null && !(value > 0)) { // Use '!' for catching NaN.
- warnNonPositiveArgument(DefaultNominalResolution.class, property, true, value);
- }
- }
-
- /**
* Returns the distance between consistent parts of (centre, left side, right side)
* adjacent pixels in the scan plane.
*
@@ -158,8 +145,9 @@ public class DefaultNominalResolution ex
*/
public void setScanningResolution(final Double newValue) {
checkWritePermission();
- ensurePositive("scanningResolution", newValue);
- scanningResolution = newValue;
+ if (ensurePositive(DefaultNominalResolution.class, "scanningResolution", true, newValue)) {
+ scanningResolution = newValue;
+ }
}
/**
@@ -184,7 +172,8 @@ public class DefaultNominalResolution ex
*/
public void setGroundResolution(final Double newValue) {
checkWritePermission();
- ensurePositive("groundResolution", newValue);
- groundResolution = newValue;
+ if (ensurePositive(DefaultNominalResolution.class, "groundResolution", true, newValue)) {
+ groundResolution = newValue;
+ }
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScopeDescription.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -250,7 +250,7 @@ public class DefaultScopeDescription ext
*/
private void warningOnOverwrite(final byte code) {
if (value != null && property != code) {
- Context.warningOccured(Context.current(), LOGGER, DefaultScopeDescription.class, SETTERS[code-1],
+ Context.warningOccured(Context.current(), DefaultScopeDescription.class, SETTERS[code-1],
Messages.class, Messages.Keys.DiscardedExclusiveProperty_2, NAMES[property-1], NAMES[code-1]);
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultDimension.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultDimension.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultDimension.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultDimension.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -28,7 +28,7 @@ import org.apache.sis.metadata.iso.ISOMe
import org.apache.sis.measure.ValueRange;
import org.apache.sis.util.ArgumentChecks;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -204,10 +204,9 @@ public class DefaultDimension extends IS
*/
public void setDimensionSize(final Integer newValue) {
checkWritePermission();
- if (newValue != null && newValue < 0) {
- warnNonPositiveArgument(DefaultDimension.class, "dimensionSize", false, newValue);
+ if (ensurePositive(DefaultDimension.class, "dimensionSize", false, newValue)) {
+ dimensionSize = newValue;
}
- dimensionSize = newValue;
}
/**
@@ -231,10 +230,9 @@ public class DefaultDimension extends IS
*/
public void setResolution(final Double newValue) {
checkWritePermission();
- if (newValue != null && !(newValue > 0)) { // Use '!' for catching NaN.
- warnNonPositiveArgument(DefaultDimension.class, "dimensionSize", true, newValue);
+ if (ensurePositive(DefaultDimension.class, "dimensionSize", true, newValue)) {
+ resolution = newValue;
}
- resolution = newValue;
}
/**
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeometricObjects.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeometricObjects.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeometricObjects.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeometricObjects.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -24,7 +24,7 @@ import org.opengis.metadata.spatial.Geom
import org.apache.sis.measure.ValueRange;
import org.apache.sis.metadata.iso.ISOMetadata;
-import static org.apache.sis.internal.metadata.MetadataUtilities.warnNonPositiveArgument;
+import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
/**
@@ -173,9 +173,8 @@ public class DefaultGeometricObjects ext
*/
public void setGeometricObjectCount(final Integer newValue) {
checkWritePermission();
- if (newValue != null && newValue <= 0) {
- warnNonPositiveArgument(DefaultGeometricObjects.class, "geometricObjectCount", true, newValue);
+ if (ensurePositive(DefaultGeometricObjects.class, "geometricObjectCount", true, newValue)) {
+ geometricObjectCount = newValue;
}
- geometricObjectCount = newValue;
}
}
Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java?rev=1690101&r1=1690100&r2=1690101&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/DefaultGeorectified.java [UTF-8] Thu Jul 9 13:31:00 2015
@@ -211,7 +211,7 @@ public class DefaultGeorectified extends
booleans |= CHECK_POINT_MASK;
} else {
if (checkPointDescription != null && (booleans & CHECK_POINT_MASK) != 0) {
- Context.warningOccured(Context.current(), LOGGER, DefaultGeorectified.class, "setCheckPointAvailable",
+ Context.warningOccured(Context.current(), DefaultGeorectified.class, "setCheckPointAvailable",
Messages.class, Messages.Keys.PropertyHiddenBy_2, "checkPointDescription", "checkPointAvailability");
}
booleans &= ~CHECK_POINT_MASK;