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/06/12 13:33:12 UTC
svn commit: r1685067 - in /sis/branches/JDK8/core:
sis-metadata/src/main/java/org/apache/sis/internal/metadata/
sis-metadata/src/main/java/org/apache/sis/io/wkt/
sis-metadata/src/test/java/org/apache/sis/io/wkt/
sis-referencing/src/main/java/org/apache...
Author: desruisseaux
Date: Fri Jun 12 11:33:11 2015
New Revision: 1685067
URL: http://svn.apache.org/r1685067
Log:
WKT: Moved the Parser interface into the org.apache.sis.io.wkt package.
Added:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java
- copied, changed from r1685064, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java
- copied, changed from r1685038, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTParser.java
Removed:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTParser.java
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
Copied: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java (from r1685064, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java?p2=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java&p1=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java&r1=1685064&r2=1685067&rev=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/AbstractParser.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -29,7 +29,6 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.opengis.util.FactoryException;
import org.apache.sis.util.Workaround;
-import org.apache.sis.internal.metadata.WKTParser;
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
@@ -39,7 +38,7 @@ import static org.apache.sis.util.Argume
* Like the later, a parser is constructed with a given set of {@linkplain Symbols symbols}.
* Parsers also need a set of factories to be used for instantiating the parsed objects.
*
- * <p>In current version, parsers are usually not intended to be subclassed outside this package.</p>
+ * <p>In current version, parsers are not intended to be subclassed outside this package.</p>
*
* <p>Parsers are not synchronized. It is recommended to create separate parser instances for each thread.
* If multiple threads access a parser concurrently, it must be synchronized externally.</p>
@@ -50,7 +49,7 @@ import static org.apache.sis.util.Argume
* @version 0.6
* @module
*/
-abstract class Parser implements WKTParser {
+abstract class AbstractParser implements Parser {
/**
* Set to {@code true} if parsing of number in scientific notation is allowed.
* The way to achieve that is currently a hack, because {@link NumberFormat}
@@ -113,7 +112,7 @@ abstract class Parser implements WKTPars
* @param dateFormat The date format provided by {@link WKTFormat}, or {@code null} for a default format.
* @param errorLocale The locale for error messages (not for parsing), or {@code null} for the system default.
*/
- Parser(final Symbols symbols, NumberFormat numberFormat, final DateFormat dateFormat, final Locale errorLocale) {
+ AbstractParser(final Symbols symbols, NumberFormat numberFormat, final DateFormat dateFormat, final Locale errorLocale) {
ensureNonNull("symbols", symbols);
if (numberFormat == null) {
numberFormat = symbols.createNumberFormat();
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java?rev=1685067&r1=1685066&r2=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -113,7 +113,7 @@ final class Element {
* @param position On input, the position where to start parsing from.
* On output, the first character after the separator.
*/
- Element(final Parser parser, final String text, final ParsePosition position) throws ParseException {
+ Element(final AbstractParser parser, final String text, final ParsePosition position) throws ParseException {
/*
* Find the first keyword in the specified string. If a keyword is found, then
* the position is set to the index of the first character after the keyword.
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java?rev=1685067&r1=1685066&r2=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/MathTransformParser.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -58,7 +58,7 @@ import static org.apache.sis.util.Argume
*
* @see <a href="http://www.geoapi.org/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html">Well Know Text specification</a>
*/
-class MathTransformParser extends Parser {
+class MathTransformParser extends AbstractParser {
/**
* The factory to use for creating math transforms.
*/
@@ -313,7 +313,7 @@ class MathTransformParser extends Parser
/**
* Returns the operation method for the last math transform parsed. This is used by
- * {@link Parser} in order to built {@link org.opengis.referencing.crs.DerivedCRS}.
+ * {@link GeodeticObjectParser} in order to built {@link org.opengis.referencing.crs.DerivedCRS}.
*/
final OperationMethod getOperationMethod() {
if (lastMethod == null) {
Copied: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java (from r1685038, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTParser.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java?p2=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java&p1=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTParser.java&r1=1685038&r2=1685067&rev=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/WKTParser.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Parser.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -14,26 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.sis.internal.metadata;
+package org.apache.sis.io.wkt;
import org.opengis.util.FactoryException;
/**
* Interfaces of objects creating an object from a WKT.
- * {@link org.apache.sis.referencing.factory.GeodeticObjectFactory} and
- * {@link org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory}
- * could implement this interface if it was in a public package, but this is not yet
- * the purpose of that interface. But revisit this choice (which would imply moving
- * this interface in a public package) in a future SIS version if experience shows
- * that it would be useful.
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.6
* @version 0.6
* @module
*/
-public interface WKTParser {
+public interface Parser {
/**
* Creates the object from a string.
*
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1685067&r1=1685066&r2=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -186,7 +186,7 @@ public class WKTFormat extends CompoundF
/**
* The parser. Will be created when first needed.
*/
- private transient Parser parser;
+ private transient AbstractParser parser;
/**
* The factories needed by the parser. Will be created when first needed.
@@ -516,7 +516,7 @@ public class WKTFormat extends CompoundF
warnings = null;
ArgumentChecks.ensureNonNull("text", text);
ArgumentChecks.ensureNonNull("pos", pos);
- Parser parser = this.parser;
+ AbstractParser parser = this.parser;
if (parser == null) {
if (factories == null) {
factories = new HashMap<>();
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java?rev=1685067&r1=1685066&r2=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -40,7 +40,7 @@ public final strictfp class ElementTest
/**
* A dummy parser to be given to the {@link Element} constructor.
*/
- private final Parser parser = new Parser(Symbols.SQUARE_BRACKETS, null, null, Locale.ENGLISH) {
+ private final AbstractParser parser = new AbstractParser(Symbols.SQUARE_BRACKETS, null, null, Locale.ENGLISH) {
@Override Object parseObject(Element element) throws ParseException {
throw new UnsupportedOperationException();
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java?rev=1685067&r1=1685066&r2=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -43,12 +43,12 @@ import org.apache.sis.referencing.datum.
import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.internal.referencing.MergedProperties;
import org.apache.sis.internal.system.DefaultFactories;
-import org.apache.sis.internal.metadata.WKTParser;
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.util.collection.WeakHashSet;
import org.apache.sis.util.iso.AbstractFactory;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.io.wkt.Parser;
import org.apache.sis.xml.XML;
@@ -180,14 +180,14 @@ import org.apache.sis.xml.XML;
* @version 0.6
* @module
*/
-public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory, CSFactory, DatumFactory {
+public class GeodeticObjectFactory extends AbstractFactory implements CRSFactory, CSFactory, DatumFactory, Parser {
/**
* The constructor for WKT parsers, fetched when first needed. The WKT parser is defined in the
* same module than this class, so we will hopefully not have security issues. But we have to
* use reflection because the parser class is not yet public (because we do not want to commit
* its API yet).
*/
- private static volatile Constructor<? extends WKTParser> parserConstructor;
+ private static volatile Constructor<? extends Parser> parserConstructor;
/**
* The default properties, or an empty map if none. This map shall not change after construction in
@@ -214,7 +214,7 @@ public class GeodeticObjectFactory exten
* The <cite>Well Known Text</cite> parser for {@code CoordinateReferenceSystem} instances.
* This parser is not thread-safe, so we need to prevent two threads from using the same instance in same time.
*/
- private final AtomicReference<WKTParser> parser;
+ private final AtomicReference<Parser> parser;
/**
* Constructs a factory with no default properties.
@@ -1347,11 +1347,11 @@ public class GeodeticObjectFactory exten
*/
@Override
public CoordinateReferenceSystem createFromWKT(final String text) throws FactoryException {
- WKTParser p = parser.getAndSet(null);
+ Parser p = parser.getAndSet(null);
if (p == null) try {
- Constructor<? extends WKTParser> c = parserConstructor;
+ Constructor<? extends Parser> c = parserConstructor;
if (c == null) {
- c = Class.forName("org.apache.sis.io.wkt.GeodeticObjectParser").asSubclass(WKTParser.class)
+ c = Class.forName("org.apache.sis.io.wkt.GeodeticObjectParser").asSubclass(Parser.class)
.getConstructor(Map.class, ObjectFactory.class, MathTransformFactory.class);
c.setAccessible(true);
parserConstructor = c;
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1685067&r1=1685066&r2=1685067&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Fri Jun 12 11:33:11 2015
@@ -46,9 +46,9 @@ import org.opengis.referencing.operation
import org.opengis.util.FactoryException;
import org.opengis.util.NoSuchIdentifierException;
+import org.apache.sis.io.wkt.Parser;
import org.apache.sis.internal.util.LazySet;
import org.apache.sis.internal.util.Constants;
-import org.apache.sis.internal.metadata.WKTParser;
import org.apache.sis.internal.referencing.Formulas;
import org.apache.sis.internal.metadata.ReferencingServices;
import org.apache.sis.internal.referencing.ReferencingUtilities;
@@ -152,7 +152,7 @@ import org.apache.sis.util.resources.Mes
* @see MathTransformProvider
* @see AbstractMathTransform
*/
-public class DefaultMathTransformFactory extends AbstractFactory implements MathTransformFactory {
+public class DefaultMathTransformFactory extends AbstractFactory implements MathTransformFactory, Parser {
/*
* NOTE FOR JAVADOC WRITER:
* The "method" word is ambiguous here, because it can be "Java method" or "coordinate operation method".
@@ -174,7 +174,7 @@ public class DefaultMathTransformFactory
* use reflection because the parser class is not yet public (because we do not want to commit
* its API yet).
*/
- private static volatile Constructor<? extends WKTParser> parserConstructor;
+ private static volatile Constructor<? extends Parser> parserConstructor;
/**
* All methods specified at construction time or found on the classpath.
@@ -218,7 +218,7 @@ public class DefaultMathTransformFactory
* This parser is not thread-safe, so we need to prevent two threads from using
* the same instance in same time.
*/
- private final AtomicReference<WKTParser> parser;
+ private final AtomicReference<Parser> parser;
/**
* Creates a new factory which will discover operation methods with a {@link ServiceLoader}.
@@ -814,11 +814,11 @@ public class DefaultMathTransformFactory
@Override
public MathTransform createFromWKT(final String text) throws FactoryException {
lastMethod.remove();
- WKTParser p = parser.getAndSet(null);
+ Parser p = parser.getAndSet(null);
if (p == null) try {
- Constructor<? extends WKTParser> c = parserConstructor;
+ Constructor<? extends Parser> c = parserConstructor;
if (c == null) {
- c = Class.forName("org.apache.sis.io.wkt.MathTransformParser").asSubclass(WKTParser.class)
+ c = Class.forName("org.apache.sis.io.wkt.MathTransformParser").asSubclass(Parser.class)
.getConstructor(MathTransformFactory.class);
c.setAccessible(true);
parserConstructor = c;