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 2013/06/14 13:46:44 UTC
svn commit: r1493038 [1/2] - in /sis/trunk: ./
application/sis-console/src/main/java/org/apache/sis/console/
application/sis-console/src/main/resources/org/apache/sis/console/
application/sis-console/src/test/java/org/apache/sis/console/
core/sis-metad...
Author: desruisseaux
Date: Fri Jun 14 11:46:44 2013
New Revision: 1493038
URL: http://svn.apache.org/r1493038
Log:
Merge from the JDK6 branch.
Added:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java
- copied unchanged from r1493035, sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataTypes.java
sis/trunk/core/sis-metadata/src/main/resources/
- copied from r1493035, sis/branches/JDK6/core/sis-metadata/src/main/resources/
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/logging/MonolineFormatterTest.java
- copied unchanged from r1493035, sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/util/logging/MonolineFormatterTest.java
Modified:
sis/trunk/ (props changed)
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Option.java
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/PerformanceLevel.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/MarshallerPool.java
sis/trunk/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/internal/util/X364Test.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/trunk/core/sis-utility/src/test/java/org/apache/sis/xml/MarshallerPoolTest.java
sis/trunk/ide-project/NetBeans/build.xml
Propchange: sis/trunk/
------------------------------------------------------------------------------
Merged /sis/branches/JDK7:r1492272-1493029
Merged /sis/branches/JDK6:r1492279-1493035
Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Command.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -26,30 +26,30 @@ import org.opengis.referencing.operation
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.util.Exceptions;
import org.apache.sis.util.resources.Errors;
-import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.logging.MonolineFormatter;
/**
* Command line interface for Apache SIS. The {@link #main(String[])} method accepts the following commands:
*
- * <ul>
- * <li>{@code help} - Show a help overview.</li>
- * <li>{@code about} - Show information about Apache SIS and system configuration.</li>
- * <li>{@code metadata} - Show metadata information for the given file.</li>
- * </ul>
+ * <blockquote><table class="compact">
+ * <tr><td>{@code help} </td><td>Show a help overview.</td></tr>
+ * <tr><td>{@code about} </td><td>Show information about Apache SIS and system configuration.</td></tr>
+ * <tr><td>{@code metadata} </td><td>Show metadata information for the given file.</td></tr>
+ * </table></blockquote>
*
* Each command can accepts an arbitrary amount of the following options:
*
- * <ul>
- * <li>{@code --locale} - The locale to use for the command output.</li>
- * <li>{@code --timezone} - The timezone for the dates to be formatted.</li>
- * <li>{@code --encoding} - The encoding to use for the command output.</li>
- * <li>{@code --colors} - Whether colorized output shall be enabled.</li>
- * <li>{@code --brief} - Whether the output should contains only brief information.</li>
- * <li>{@code --verbose} - Whether the output should contains more detailed information.</li>
- * <li>{@code --help} - Lists the options available for a specific command.</li>
- * </ul>
+ * <blockquote><table class="compact">
+ * <tr><td>{@code --format} </td><td>The output format (XML or text).</td></tr>
+ * <tr><td>{@code --locale} </td><td>The locale to use for the command output.</td></tr>
+ * <tr><td>{@code --timezone} </td><td>The timezone for the dates to be formatted.</td></tr>
+ * <tr><td>{@code --encoding} </td><td>The encoding to use for the command output.</td></tr>
+ * <tr><td>{@code --colors} </td><td>Whether colorized output shall be enabled.</td></tr>
+ * <tr><td>{@code --brief} </td><td>Whether the output should contains only brief information.</td></tr>
+ * <tr><td>{@code --verbose} </td><td>Whether the output should contains more detailed information.</td></tr>
+ * <tr><td>{@code --help} </td><td>Lists the options available for a specific command.</td></tr>
+ * </table></blockquote>
*
* The {@code --locale}, {@code --timezone} and {@code --encoding} options apply to the command output sent
* to the {@linkplain System#out standard output stream}, but usually do not apply to the error messages sent
@@ -222,7 +222,7 @@ public final class Command {
* @param args Command-line options.
*/
public static void main(final String[] args) {
- MonolineFormatter.configureConsoleHandler(Logging.getLogger(""), null);
+ MonolineFormatter.install();
final Command c;
try {
c = new Command(args);
Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/MetadataSC.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -18,6 +18,8 @@ package org.apache.sis.console;
import java.util.EnumSet;
import java.io.IOException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.JAXBException;
import org.opengis.metadata.Metadata;
import org.apache.sis.metadata.MetadataStandard;
import org.apache.sis.metadata.ValueExistencePolicy;
@@ -27,6 +29,9 @@ import org.apache.sis.storage.netcdf.Net
import org.apache.sis.util.collection.TableColumn;
import org.apache.sis.util.collection.TreeTable;
import org.apache.sis.util.collection.TreeTableFormat;
+import org.apache.sis.util.resources.Errors;
+import org.apache.sis.xml.MarshallerPool;
+import org.apache.sis.xml.XML;
/**
@@ -42,7 +47,7 @@ final class MetadataSC extends SubComman
* Creates the {@code "metadata"} sub-command.
*/
MetadataSC(final int commandIndex, final String... args) throws InvalidOptionException {
- super(commandIndex, args, EnumSet.of(Option.LOCALE, Option.TIMEZONE, Option.ENCODING, Option.HELP));
+ super(commandIndex, args, EnumSet.of(Option.FORMAT, Option.LOCALE, Option.TIMEZONE, Option.ENCODING, Option.HELP));
}
/**
@@ -51,10 +56,26 @@ final class MetadataSC extends SubComman
* @todo NetCDF data store is hard-coded for now. Will need a dynamic mechanism in the future.
*
* @throws DataStoreException If an error occurred while reading the NetCDF file.
+ * @throws JAXBException If an error occurred while producing the XML output.
* @throws IOException Should never happen, since we are appending to a print writer.
*/
@Override
- public int run() throws DataStoreException, IOException {
+ public int run() throws InvalidOptionException, DataStoreException, JAXBException, IOException {
+ /*
+ * Output format can be either "text" (the default) or "xml".
+ */
+ boolean toXML = false;
+ final String format = options.get(Option.FORMAT);
+ if (format != null && !format.equalsIgnoreCase("text")) {
+ if (!format.equalsIgnoreCase("xml")) {
+ throw new InvalidOptionException(Errors.format(
+ Errors.Keys.IllegalOptionValue_2, "format", format), format);
+ }
+ toXML = true;
+ }
+ /*
+ * Read metadata from the data storage.
+ */
if (hasUnexpectedFileCount(1, 1)) {
return Command.INVALID_ARGUMENT_EXIT_CODE;
}
@@ -65,11 +86,22 @@ final class MetadataSC extends SubComman
} finally {
store.close();
}
+ /*
+ * Format metadata to the standard output stream.
+ */
if (metadata != null) {
- final TreeTable tree = MetadataStandard.ISO_19115.asTreeTable(metadata, ValueExistencePolicy.NON_EMPTY);
- final TreeTableFormat format = new TreeTableFormat(locale, timezone);
- format.setColumns(TableColumn.NAME, TableColumn.VALUE);
- format.format(tree, out);
+ if (toXML) {
+ final MarshallerPool pool = new MarshallerPool(null);
+ final Marshaller marshaller = pool.acquireMarshaller();
+ marshaller.setProperty(XML.LOCALE, locale);
+ marshaller.setProperty(XML.TIMEZONE, timezone);
+ marshaller.marshal(metadata, out);
+ } else {
+ final TreeTable tree = MetadataStandard.ISO_19115.asTreeTable(metadata, ValueExistencePolicy.NON_EMPTY);
+ final TreeTableFormat tf = new TreeTableFormat(locale, timezone);
+ tf.setColumns(TableColumn.NAME, TableColumn.VALUE);
+ tf.format(tree, out);
+ }
out.flush();
}
return 0;
Modified: sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Option.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Option.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Option.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/main/java/org/apache/sis/console/Option.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -30,6 +30,11 @@ import org.apache.sis.util.resources.Err
*/
enum Option {
/**
+ * The output format. Examples: {@code "xml"}, {@code "text"}.
+ */
+ FORMAT(true),
+
+ /**
* The locale for the output produced by the command.
*/
LOCALE(true),
Modified: sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties [ISO-8859-1] (original)
+++ sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options.properties [ISO-8859-1] Fri Jun 14 11:46:44 2013
@@ -1,4 +1,5 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
+format=The output format (for instance XML or text).
locale=The locale to use for the command output.
timezone=The timezone for the dates to be formatted.
encoding=The encoding to use for the command output.
Modified: sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties [ISO-8859-1] (original)
+++ sis/trunk/application/sis-console/src/main/resources/org/apache/sis/console/Options_fr.properties [ISO-8859-1] Fri Jun 14 11:46:44 2013
@@ -1,4 +1,5 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
+format=Le format de sortie (par exemple XML ou texte).
locale=Les paramètres régionaux à utiliser pour la sortie de la commande.
timezone=Le fuseau horaire des dates à écrire.
encoding=L\u2019encodage des caractères à utiliser pour la sortie de la commande.
Modified: sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java [UTF-8] (original)
+++ sis/trunk/application/sis-console/src/test/java/org/apache/sis/console/MetadataSCTest.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -17,6 +17,7 @@
package org.apache.sis.console;
import java.net.URL;
+import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
@@ -47,11 +48,33 @@ public final strictfp class MetadataSCTe
assertNotNull("NCEP-SST.nc", url);
final MetadataSC test = new MetadataSC(0, SubCommand.TEST, url.toString());
test.run();
- final String result = test.outputBuffer.toString();
- assertTrue("DefaultMetadata", result.startsWith("DefaultMetadata"));
- assertTrue("ISO 19115-2", result.contains ("ISO 19115-2"));
- assertTrue("Sea Surface Temperature Analysis Model", result.contains ("Sea Surface Temperature Analysis Model"));
- assertTrue("GCMD Science Keywords", result.contains ("GCMD Science Keywords"));
- assertTrue("NOAA/NWS/NCEP", result.contains ("NOAA/NWS/NCEP"));
+ verifyNetCDF("DefaultMetadata", test.outputBuffer.toString());
+ }
+
+ /**
+ * Verifies the NetCDF metadata. The given string can be either a text format or XML format.
+ * This method will check only for some keyword - this is not an extensive check of the result.
+ */
+ private static void verifyNetCDF(final String expectedHeader, final String result) {
+ assertTrue(expectedHeader, result.startsWith(expectedHeader));
+ assertTrue("ISO 19115-2", result.contains("ISO 19115-2"));
+ assertTrue("Sea Surface Temperature Analysis Model", result.contains("Sea Surface Temperature Analysis Model"));
+ assertTrue("GCMD Science Keywords", result.contains("GCMD Science Keywords"));
+ assertTrue("NOAA/NWS/NCEP", result.contains("NOAA/NWS/NCEP"));
+ }
+
+ /**
+ * Tests with the same file than {@link #testNetCDF()}, but producing a XML output.
+ *
+ * @throws Exception Should never happen.
+ */
+ @Test
+ @Ignore("Requires GeoAPI 3.1")
+ @DependsOnMethod("testNetCDF")
+ public void testFormatXML() throws Exception {
+ final URL url = MetadataSCTest.class.getResource("NCEP-SST.nc");
+ final MetadataSC test = new MetadataSC(0, SubCommand.TEST, url.toString(), "--format", "XML");
+ test.run();
+ verifyNetCDF("<?xml", test.outputBuffer.toString());
}
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -41,7 +41,7 @@ import org.apache.sis.xml.Namespaces;
* @module
*/
@XmlType(name = "MD_CoverageDescription_Type", propOrder = {
- "attributeDescription",
+// TODO "attributeDescription",
"contentType",
"dimensions",
"rangeElementDescriptions"
@@ -135,7 +135,7 @@ public class DefaultCoverageDescription
* Returns the description of the attribute described by the measurement value.
*/
@Override
- @XmlElement(name = "attributeDescription", required = true)
+ // TODO @XmlElement(name = "attributeDescription", required = true)
public RecordType getAttributeDescription() {
return attributeDescription;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -126,7 +126,7 @@ public class DefaultTemporalExtent exten
* @return The content date.
*/
@Override
- @XmlElement(name = "extent", required = true)
+ // TODO @XmlElement(name = "extent", required = true)
public TemporalPrimitive getExtent() {
return extent;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -45,7 +45,7 @@ import org.apache.sis.internal.metadata.
@XmlType(name = "EX_VerticalExtent_Type", propOrder = {
"minimumValue",
"maximumValue",
- "verticalCRS"
+// TODO "verticalCRS"
})
@XmlRootElement(name = "EX_VerticalExtent")
public class DefaultVerticalExtent extends ISOMetadata implements VerticalExtent {
@@ -178,7 +178,7 @@ public class DefaultVerticalExtent exten
* identification includes unit of measure.
*/
@Override
- @XmlElement(name = "verticalCRS", required = true)
+ // TODO @XmlElement(name = "verticalCRS", required = true)
public VerticalCRS getVerticalCRS() {
return verticalCRS;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -48,7 +48,7 @@ import org.apache.sis.internal.metadata.
*/
@XmlType(name = "MD_Resolution_Type", propOrder = {
"equivalentScale",
- "distance"
+// TODO "distance"
})
@XmlRootElement(name = "MD_Resolution")
public class DefaultResolution extends ISOMetadata implements Resolution {
@@ -170,7 +170,7 @@ public class DefaultResolution extends I
@Override
@ValueRange(minimum=0, isMinIncluded=false)
// @XmlJavaTypeAdapter(GO_Distance.class) // TODO
- @XmlElement(name = "distance")
+// @XmlElement(name = "distance")
public Double getDistance() {
return isDistance() ? (Double) scaleOrDistance : null;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -48,7 +48,7 @@ import static org.apache.sis.internal.me
@XmlType(name = "MD_MaintenanceInformation_Type", propOrder = {
"maintenanceAndUpdateFrequency",
"dateOfNextUpdate",
- "userDefinedMaintenanceFrequency",
+// TODO "userDefinedMaintenanceFrequency",
"updateScopes",
"updateScopeDescriptions",
"maintenanceNotes",
@@ -209,7 +209,7 @@ public class DefaultMaintenanceInformati
* @todo needs an implementation of org.opengis.temporal modules to anntote this parameter.
*/
@Override
- @XmlElement(name = "userDefinedMaintenanceFrequency")
+ // TODO @XmlElement(name = "userDefinedMaintenanceFrequency")
public PeriodDuration getUserDefinedMaintenanceFrequency() {
return userDefinedMaintenanceFrequency;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/quality/DefaultQuantitativeResult.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -37,7 +37,7 @@ import org.opengis.util.RecordType;
* @module
*/
@XmlType(name = "DQ_QuantitativeResult_Type", propOrder = {
- "valueType",
+// TODO "valueType",
"valueUnit",
"errorStatistic"
})
@@ -138,7 +138,7 @@ public class DefaultQuantitativeResult e
* Return the value type for reporting a data quality result, or {@code null} if none.
*/
@Override
- @XmlElement(name = "valueType")
+ // TODO @XmlElement(name = "valueType")
public RecordType getValueType() {
return valueType;
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/TypeRegistration.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -19,6 +19,11 @@ package org.apache.sis.internal.jaxb;
import java.util.ArrayList;
import java.util.Collection;
import java.util.ServiceLoader;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import org.apache.sis.internal.util.SystemListener;
/**
@@ -41,6 +46,18 @@ import java.util.ServiceLoader;
*/
public abstract class TypeRegistration {
/**
+ * The JAXB context, or {@code null} if not yet created.
+ */
+ private static Reference<JAXBContext> context;
+ static {
+ SystemListener.add(new SystemListener() {
+ @Override protected void classpathChanged() {
+ context = null;
+ }
+ });
+ }
+
+ /**
* For subclasses constructors.
*/
protected TypeRegistration() {
@@ -64,7 +81,7 @@ public abstract class TypeRegistration {
*
* @return The default set of classes to be bound to the {@code JAXBContext}.
*/
- public static Class<?>[] defaultClassesToBeBound() {
+ private static Class<?>[] defaultClassesToBeBound() {
/*
* Implementation note: do not keep the ServiceLoader in static field because:
*
@@ -77,4 +94,25 @@ public abstract class TypeRegistration {
}
return types.toArray(new Class<?>[types.size()]);
}
+
+ /**
+ * Returns the shared {@code JAXBContext} for the set of {@link #defaultClassesToBeBound()}.
+ * Note that the {@code JAXBContext} class is thread safe, but the {@code Marshaller},
+ * {@code Unmarshaller}, and {@code Validator} classes are not thread safe.
+ *
+ * @return The shared JAXB context.
+ * @throws JAXBException If an error occurred while creating the JAXB context.
+ */
+ public static synchronized JAXBContext getSharedContext() throws JAXBException {
+ final Reference<JAXBContext> ref = context; // Protect from changes by the listener.
+ if (ref != null) {
+ final JAXBContext instance = ref.get();
+ if (instance != null) {
+ return instance;
+ }
+ }
+ final JAXBContext instance = JAXBContext.newInstance(defaultClassesToBeBound());
+ context = new WeakReference<JAXBContext>(instance);
+ return instance;
+ }
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/Supervisor.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -16,8 +16,10 @@
*/
package org.apache.sis.internal.util;
+import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
+import java.util.TimeZone;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import javax.management.ObjectName;
@@ -34,7 +36,6 @@ import java.lang.management.ManagementFa
import org.apache.sis.setup.About;
import org.apache.sis.util.Localized;
-import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.collection.TreeTable;
@@ -79,7 +80,7 @@ public final class Supervisor extends St
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
try {
final ObjectName n = new ObjectName("org.apache.sis:type=Supervisor");
- server.registerMBean(new Supervisor(Locale.getDefault()), n);
+ server.registerMBean(new Supervisor(null, null), n);
name = n; // Store only on success.
} catch (Exception e) { // (SecurityException | JMException) on JDK7
Logging.unexpectedException(Logger.getLogger("org.apache.sis"), Supervisor.class, "register", e);
@@ -105,24 +106,30 @@ public final class Supervisor extends St
}
/**
- * The locale for producing the messages.
+ * The locale for producing the messages, or {@code null} for the default.
*/
private final Locale locale;
/**
+ * The timezone for formatting the dates, or {@code null} for the default.
+ */
+ private final TimeZone timezone;
+
+ /**
* Creates a new {@code Supervisor} which will report messages in the given locale.
*
- * @param locale The locale to use for reporting messages.
+ * @param locale The locale to use for reporting messages, or {@code null} for the default.
+ * @param timezone The timezone for formatting the dates, or {@code null} for the default.
* @throws NotCompliantMBeanException Should never happen.
*/
- public Supervisor(final Locale locale) throws NotCompliantMBeanException {
+ public Supervisor(final Locale locale, final TimeZone timezone) throws NotCompliantMBeanException {
super(SupervisorMBean.class);
- ArgumentChecks.ensureNonNull("locale", locale);
- this.locale = locale;
+ this.locale = locale;
+ this.timezone = timezone;
}
/**
- * Returns the supervisor locale.
+ * Returns the supervisor locale, or {@code null} for the default locale.
*/
@Override
public Locale getLocale() {
@@ -182,7 +189,8 @@ public final class Supervisor extends St
*/
private String getDescription(final String resourceKey) {
return ResourceBundle.getBundle("org.apache.sis.internal.util.Descriptions",
- locale, Supervisor.class.getClassLoader()).getString(resourceKey);
+ (locale != null) ? locale : Locale.getDefault(),
+ Supervisor.class.getClassLoader()).getString(resourceKey);
}
// -----------------------------------------------------------------------
@@ -194,7 +202,7 @@ public final class Supervisor extends St
*/
@Override
public TreeTable configuration() {
- return About.configuration(locale);
+ return About.configuration(EnumSet.allOf(About.class), locale, timezone);
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/util/X364.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -16,7 +16,9 @@
*/
package org.apache.sis.internal.util;
+import java.util.Arrays;
import org.apache.sis.util.CharSequences;
+import org.apache.sis.util.resources.Errors;
/**
@@ -37,18 +39,18 @@ import org.apache.sis.util.CharSequences
* @see org.apache.sis.io.wkt.Colors
*/
public enum X364 {
- /** Reset all attributes to their default value. */ RESET ((byte) 0),
- /** Normal intensity (not {@link #BOLD}). */ NORMAL ((byte) 22),
- /** Bold intensity. */ BOLD ((byte) 1),
- /** Faint intensity. */ FAINT ((byte) 2),
- /** Red foreground color, normal intensity. */ FOREGROUND_RED ((byte) 31),
- /** Green foreground color, normal intensity. */ FOREGROUND_GREEN ((byte) 32),
- /** Yellow foreground color, normal intensity. */ FOREGROUND_YELLOW ((byte) 33),
- /** Blue foreground color, normal intensity. */ FOREGROUND_BLUE ((byte) 34),
- /** Magenta foreground color, normal intensity. */ FOREGROUND_MAGENTA ((byte) 35),
- /** Cyan foreground color, normal intensity. */ FOREGROUND_CYAN ((byte) 36),
- /** Gray foreground color, normal intensity. */ FOREGROUND_GRAY ((byte) 37),
- /** Reset the foreground color. */ FOREGROUND_DEFAULT ((byte) 39),
+ /** Reset all attributes to their default value. */ RESET ((byte) 0, null),
+ /** Normal intensity (not {@link #BOLD}). */ NORMAL ((byte) 22, null),
+ /** Bold intensity. */ BOLD ((byte) 1, null),
+ /** Faint intensity. */ FAINT ((byte) 2, null),
+ /** Red foreground color, normal intensity. */ FOREGROUND_RED ((byte) 31, "red"),
+ /** Green foreground color, normal intensity. */ FOREGROUND_GREEN ((byte) 32, "green"),
+ /** Yellow foreground color, normal intensity. */ FOREGROUND_YELLOW ((byte) 33, "yellow"),
+ /** Blue foreground color, normal intensity. */ FOREGROUND_BLUE ((byte) 34, "blue"),
+ /** Magenta foreground color, normal intensity. */ FOREGROUND_MAGENTA ((byte) 35, "magenta"),
+ /** Cyan foreground color, normal intensity. */ FOREGROUND_CYAN ((byte) 36, "cyan"),
+ /** Gray foreground color, normal intensity. */ FOREGROUND_GRAY ((byte) 37, "gray"),
+ /** Reset the foreground color. */ FOREGROUND_DEFAULT ((byte) 39, null),
/** Red background color, normal intensity. */ BACKGROUND_RED (FOREGROUND_RED),
/** Green background color, normal intensity. */ BACKGROUND_GREEN (FOREGROUND_GREEN),
/** Yellow background color, normal intensity. */ BACKGROUND_YELLOW (FOREGROUND_YELLOW),
@@ -59,6 +61,17 @@ public enum X364 {
/** Reset the background color. */ BACKGROUND_DEFAULT (FOREGROUND_DEFAULT);
/**
+ * The list of codes having a non-null {@linkplain #color} name.
+ * They are the codes in the range 31 to 37 inclusive.
+ *
+ * @see #forColorName(String)
+ */
+ private static final X364[] NAMED;
+ static {
+ NAMED = Arrays.copyOfRange(values(), 4, 11);
+ }
+
+ /**
* The first character of the {@link #START} escape string.
*/
public static final char ESCAPE = '\u001B';
@@ -96,12 +109,19 @@ public enum X364 {
private transient X364 foreground, background;
/**
+ * The color name, or {@code null} if none.
+ */
+ public final String color;
+
+ /**
* Creates a new code.
*
- * @param code The X.364 code.
+ * @param code The X.364 numerical code.
+ * @param color The color name, or {@code null} if none.
*/
- private X364(final byte code) {
+ private X364(final byte code, final String color) {
this.code = code;
+ this.color = color;
foreground = this;
background = this;
}
@@ -112,7 +132,7 @@ public enum X364 {
* @param code The X.364 code.
*/
private X364(final X364 foreground) {
- this((byte) (foreground.code + 10));
+ this((byte) (foreground.code + 10), foreground.color);
this.foreground = foreground;
this.background = foreground.background = this;
}
@@ -230,6 +250,24 @@ search: do {
}
/**
+ * Returns the enumeration value for the given color name.
+ * The search is case-insensitive.
+ *
+ * @param color The color name.
+ * @return The code for the given color name.
+ * @throws IllegalArgumentException If no code has been found for the given color name.
+ */
+ public static X364 forColorName(String color) throws IllegalArgumentException {
+ color = CharSequences.trimWhitespaces(color);
+ for (final X364 code : NAMED) {
+ if (color.equalsIgnoreCase(code.color)) {
+ return code;
+ }
+ }
+ throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalArgumentValue_2, "color", color));
+ }
+
+ /**
* Returns {@code true} if we think that the operating system supports ANSI sequences.
* This method performs a very naive and approximative check. Result is just a hint and
* may be wrong.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/About.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -134,25 +134,37 @@ public enum About {
/**
* Returns all known information about the current Apache SIS running environment.
+ * The information are formatted using the system default locale and timezone.
+ *
+ * <p>This convenience method is equivalent to the following code:</p>
+ *
+ * {@preformat java
+ * return configuration(EnumSet.allOf(About.class), null, null);
+ * }
*
- * @param locale The locale to use for formatting the texts in the tree.
* @return Configuration information, as a tree for grouping some configuration by sections.
*/
- public static TreeTable configuration(final Locale locale) {
- return configuration(EnumSet.allOf(About.class), locale, null);
+ public static TreeTable configuration() {
+ return configuration(EnumSet.allOf(About.class), null, null);
}
/**
* Returns a subset of the information about the current Apache SIS running environment.
*
* @param sections The section for which information are desired.
- * @param locale The locale to use for formatting the texts in the tree.
+ * @param locale The locale to use for formatting the texts in the tree, or {@code null} for the default.
* @param timezone The timezone to use for formatting the dates, or {@code null} for the default.
* @return Configuration information, as a tree for grouping some configuration by sections.
*/
- public static TreeTable configuration(final Set<About> sections, final Locale locale, final TimeZone timezone) {
+ public static TreeTable configuration(final Set<About> sections, Locale locale, final TimeZone timezone) {
ArgumentChecks.ensureNonNull("sections", sections);
- ArgumentChecks.ensureNonNull("locale", locale);
+ final Locale formatLocale;
+ if (locale != null) {
+ formatLocale = locale;
+ } else {
+ locale = Locale.getDefault();
+ formatLocale = locale; // On the JDK7 branch, this is not necessarily the same.
+ }
String userHome = null;
String javaHome = null;
final Date now = new Date();
@@ -218,7 +230,7 @@ fill: for (int i=0; ; i++) {
nameKey = Vocabulary.Keys.Timezone;
final boolean inDaylightTime = current.inDaylightTime(now);
value = concatenate(current.getDisplayName(inDaylightTime, TimeZone.LONG, locale), current.getID(), true);
- final DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, locale);
+ final DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, formatLocale);
df.setTimeZone(TimeZone.getTimeZone("UTC"));
int offset = current.getOffset(now.getTime());
StringBuffer buffer = format(df, offset, new StringBuffer("UTC "));
@@ -235,7 +247,7 @@ fill: for (int i=0; ; i++) {
case 5: {
if (sections.contains(LOCALIZATION)) {
nameKey = Vocabulary.Keys.CurrentDateTime;
- final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
+ final DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, formatLocale);
if (timezone != null) {
df.setTimeZone(timezone);
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -62,63 +62,63 @@
* </tr>
*
* <tr align="center">
- * <td bgcolor="palegoldenrod" colspan="1"><font size="-1">{@linkplain org.apache.sis.util.iso.AbstractName#head() head}</font></td><td></td>
- * <td bgcolor="palegoldenrod" colspan="5"><font size="-1">{@linkplain org.apache.sis.util.iso.DefaultScopedName#tail() tail}</font></td>
+ * <td style="background:palegoldenrod" colspan="1"><font size="-1">{@linkplain org.apache.sis.util.iso.AbstractName#head() head}</font></td><td></td>
+ * <td style="background:palegoldenrod" colspan="5"><font size="-1">{@linkplain org.apache.sis.util.iso.DefaultScopedName#tail() tail}</font></td>
* <td rowspan="2"></td>
- * <td rowspan="2" bgcolor="beige" align="left">{@linkplain org.apache.sis.util.iso.DefaultNameSpace#isGlobal() global}</td>
- * <td rowspan="2" bgcolor="beige" align="right">{@code {"org", "opengis", "util", "Record"}}</td>
+ * <td rowspan="2" style="background:beige" align="left">{@linkplain org.apache.sis.util.iso.DefaultNameSpace#isGlobal() global}</td>
+ * <td rowspan="2" style="background:beige" align="right">{@code {"org", "opengis", "util", "Record"}}</td>
* <td rowspan="2"></td>
* <td rowspan="2">{@link org.apache.sis.util.iso.DefaultScopedName ScopedName}</td>
* </tr>
* <tr align="center">
- * <td bgcolor="wheat" colspan="5"><font size="-1">{@linkplain org.apache.sis.util.iso.DefaultScopedName#path() path}</font></td><td></td>
- * <td bgcolor="wheat" colspan="1"><font size="-1">{@linkplain org.apache.sis.util.iso.AbstractName#tip() tip}</font></td>
+ * <td style="background:wheat" colspan="5"><font size="-1">{@linkplain org.apache.sis.util.iso.DefaultScopedName#path() path}</font></td><td></td>
+ * <td style="background:wheat" colspan="1"><font size="-1">{@linkplain org.apache.sis.util.iso.AbstractName#tip() tip}</font></td>
* </tr>
*
* <tr><td colspan="9" height="2"></td></tr>
* <tr align="center">
- * <td bgcolor="palegoldenrod" colspan="1" rowspan="2"><font size="-1">{@linkplain org.apache.sis.util.iso.AbstractName#scope() scope}</font></td><td rowspan="2"></td>
- * <td bgcolor="palegoldenrod" colspan="1"><font size="-1">head</font></td><td></td>
- * <td bgcolor="palegoldenrod" colspan="3"><font size="-1">tail</font></td>
+ * <td style="background:palegoldenrod" colspan="1" rowspan="2"><font size="-1">{@linkplain org.apache.sis.util.iso.AbstractName#scope() scope}</font></td><td rowspan="2"></td>
+ * <td style="background:palegoldenrod" colspan="1"><font size="-1">head</font></td><td></td>
+ * <td style="background:palegoldenrod" colspan="3"><font size="-1">tail</font></td>
* <td rowspan="2"></td>
- * <td rowspan="2" bgcolor="beige" align="left">{@code "org"}</td>
- * <td rowspan="2" bgcolor="beige" align="right">{@code {"opengis", "util", "Record"}}</td>
+ * <td rowspan="2" style="background:beige" align="left">{@code "org"}</td>
+ * <td rowspan="2" style="background:beige" align="right">{@code {"opengis", "util", "Record"}}</td>
* <td rowspan="2"></td>
* <td rowspan="2">{@code ScopedName}</td>
* </tr>
* <tr align="center">
- * <td bgcolor="wheat" colspan="3"><font size="-1">path</font></td><td></td>
- * <td bgcolor="wheat" colspan="1"><font size="-1">tip</font></td>
+ * <td style="background:wheat" colspan="3"><font size="-1">path</font></td><td></td>
+ * <td style="background:wheat" colspan="1"><font size="-1">tip</font></td>
* </tr>
*
* <tr><td colspan="9" height="3"></td></tr>
* <tr align="center">
- * <td bgcolor="palegoldenrod" colspan="3" rowspan="2"><font size="-1">scope</font></td><td rowspan="2"></td>
- * <td bgcolor="palegoldenrod" colspan="1"><font size="-1">head</font></td><td></td>
- * <td bgcolor="palegoldenrod" colspan="1"><font size="-1">tail</font></td>
+ * <td style="background:palegoldenrod" colspan="3" rowspan="2"><font size="-1">scope</font></td><td rowspan="2"></td>
+ * <td style="background:palegoldenrod" colspan="1"><font size="-1">head</font></td><td></td>
+ * <td style="background:palegoldenrod" colspan="1"><font size="-1">tail</font></td>
* <td rowspan="2"></td>
- * <td rowspan="2" bgcolor="beige" align="left">{@code "org.opengis"}</td>
- * <td rowspan="2" bgcolor="beige" align="right">{@code {"util", "Record"}}</td>
+ * <td rowspan="2" style="background:beige" align="left">{@code "org.opengis"}</td>
+ * <td rowspan="2" style="background:beige" align="right">{@code {"util", "Record"}}</td>
* <td rowspan="2"></td>
* <td rowspan="2">{@code ScopedName}</td>
* </tr>
* <tr align="center">
- * <td bgcolor="wheat" colspan="1"><font size="-1">path</font></td><td></td>
- * <td bgcolor="wheat" colspan="1"><font size="-1">tip</font></td>
+ * <td style="background:wheat" colspan="1"><font size="-1">path</font></td><td></td>
+ * <td style="background:wheat" colspan="1"><font size="-1">tip</font></td>
* </tr>
*
* <tr><td colspan="9" height="3"></td></tr>
* <tr align="center">
- * <td bgcolor="palegoldenrod" colspan="5" rowspan="2"><font size="-1">scope</font></td><td rowspan="2"></td>
- * <td bgcolor="palegoldenrod" colspan="1"><font size="-1">head</font></td>
+ * <td style="background:palegoldenrod" colspan="5" rowspan="2"><font size="-1">scope</font></td><td rowspan="2"></td>
+ * <td style="background:palegoldenrod" colspan="1"><font size="-1">head</font></td>
* <td rowspan="2"></td>
- * <td rowspan="2" bgcolor="beige" align="left">{@code "org.opengis.util"}</td>
- * <td rowspan="2" bgcolor="beige" align="right">{@code {"Record"}}</td>
+ * <td rowspan="2" style="background:beige" align="left">{@code "org.opengis.util"}</td>
+ * <td rowspan="2" style="background:beige" align="right">{@code {"Record"}}</td>
* <td rowspan="2"></td>
* <td rowspan="2">{@link org.apache.sis.util.iso.DefaultLocalName LocalName}</td>
* </tr>
* <tr align="center">
- * <td bgcolor="wheat" colspan="1"><font size="-1">tip</font></td>
+ * <td style="background:wheat" colspan="1"><font size="-1">tip</font></td>
* </tr>
* </table></td></tr></table></blockquote>
*
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java?rev=1493038&r1=1493037&r2=1493038&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java [UTF-8] Fri Jun 14 11:46:44 2013
@@ -204,7 +204,7 @@ public final class Logging extends Stati
* @param logger Where to log the error.
* @param error The error that occurred.
* @return {@code true} if the error has been logged, or {@code false} if the logger
- * doesn't log anything at the {@link Level#WARNING WARNING} level.
+ * doesn't log anything at {@link Level#WARNING}.
*/
public static boolean unexpectedException(final Logger logger, final Throwable error) {
return unexpectedException(logger, null, null, error, Level.WARNING);
@@ -235,7 +235,7 @@ public final class Logging extends Stati
* @param method The method where the error occurred, or {@code null}.
* @param error The error.
* @return {@code true} if the error has been logged, or {@code false} if the logger
- * doesn't log anything at the {@link Level#WARNING WARNING} level.
+ * doesn't log anything at {@link Level#WARNING}.
*
* @see #recoverableException(Logger, Class, String, Throwable)
* @see #severeException(Logger, Class, String, Throwable)
@@ -255,7 +255,7 @@ public final class Logging extends Stati
* @param method The method where the error occurred, or {@code null}.
* @param error The error.
* @return {@code true} if the error has been logged, or {@code false} if the logger
- * doesn't log anything at the {@link Level#WARNING WARNING} level.
+ * doesn't log anything at {@link Level#WARNING}.
*
* @see #recoverableException(Class, String, Throwable)
*/
@@ -392,6 +392,27 @@ public final class Logging extends Stati
}
/**
+ * Invoked when an unexpected error occurred while configuring the system. The error shall not
+ * prevent the application from working, but may change the behavior in some minor aspects.
+ *
+ * {@example if the <code>org.apache.sis.util.logging.MonolineFormatter.time</code> pattern declared
+ * in the <code>jre/lib/logging.properties</code> file is illegal, then <code>MonolineFormatter</code>
+ * while log this problem and use a default time pattern.}
+ *
+ * @param classe The class where the error occurred.
+ * @param method The method name where the error occurred.
+ * @param error The error.
+ * @return {@code true} if the error has been logged, or {@code false} if the logger
+ * doesn't log anything at {@link Level#CONFIG}.
+ *
+ * @see #unexpectedException(Class, String, Throwable)
+ */
+ static boolean configurationException(final Class<?> classe, final String method, final Throwable error) {
+ final String classname = (classe != null) ? classe.getName() : null;
+ return unexpectedException(null, classname, method, error, Level.CONFIG);
+ }
+
+ /**
* Invoked when a recoverable error occurs. This method is similar to
* {@link #unexpectedException(Class,String,Throwable) unexpectedException}
* except that it doesn't log the stack trace and uses a lower logging level.
@@ -400,13 +421,11 @@ public final class Logging extends Stati
* @param method The method name where the error occurred.
* @param error The error.
* @return {@code true} if the error has been logged, or {@code false} if the logger
- * doesn't log anything at the {@link Level#FINE FINE} level.
+ * doesn't log anything at {@link Level#FINE}.
*
* @see #unexpectedException(Class, String, Throwable)
*/
- public static boolean recoverableException(final Class<?> classe, final String method,
- final Throwable error)
- {
+ public static boolean recoverableException(final Class<?> classe, final String method, final Throwable error) {
return recoverableException(null, classe, method, error);
}
@@ -420,7 +439,7 @@ public final class Logging extends Stati
* @param method The method name where the error occurred.
* @param error The error.
* @return {@code true} if the error has been logged, or {@code false} if the logger
- * doesn't log anything at the {@link Level#FINE FINE} level.
+ * doesn't log anything at {@link Level#FINE}.
*
* @see #unexpectedException(Logger, Class, String, Throwable)
* @see #severeException(Logger, Class, String, Throwable)
@@ -442,7 +461,7 @@ public final class Logging extends Stati
* @param method The method name where the error occurred.
* @param error The error.
* @return {@code true} if the error has been logged, or {@code false} if the logger
- * doesn't log anything at the {@link Level#SEVERE SEVERE} level.
+ * doesn't log anything at {@link Level#SEVERE}.
*
* @see #unexpectedException(Logger, Class, String, Throwable)
* @see #recoverableException(Logger, Class, String, Throwable)