Author: desruisseaux
Date: Sat Feb 17 13:46:34 2018
New Revision: 1824589
URL: http://svn.apache.org/viewvc?rev=1824589&view=rev
Log:
Rename FilteredXML and related classes as Transformer, for closer analogy with
javax.xml.transform.Transformer (for XSLT).
Added:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java
- copied, changed from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformedEvent.java
- copied, changed from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredEvent.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java
- copied, changed from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredXML.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java
- copied, changed from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredNamespaces.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java
- copied, changed from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredReader.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java
- copied, changed from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredWriter.java
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/TransformingNamespacesTest.java
- copied, changed from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/FilteredNamespacesTest.java
Removed:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredEvent.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredNamespaces.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredReader.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredWriter.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredXML.java
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/FilteredNamespacesTest.java
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/xml/NamespaceContent.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -70,8 +70,7 @@ final strictfp class PackageVerifier {
* wrappers. For example in {@code SV_CoupledResource}, {@code
<gco:ScopedName>} was marshalled without its
* {@code <srv:scopedName>} wrapper — note the upper and lower-case "s".
Because {@code ScopedName} is a type,
* we had to keep the namespace declared in {@link
org.apache.sis.util.iso.DefaultScopedName}
- * (the replacement is performed by {@code
org.apache.sis.xml.FilteredWriter}).
- * </p>
+ * (the replacement is performed by {@code
org.apache.sis.xml.TransformingWriter}).</p>
*/
private static final Map<String, Set<String>> LEGACY_NAMESPACES;
static {
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/xml/NamespaceContent.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/xml/NamespaceContent.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/xml/NamespaceContent.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/xml/NamespaceContent.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -37,7 +37,7 @@ import org.apache.sis.internal.jaxb.Lega
/**
- * Creates the {@value FilteredReader#FILENAME} file. This class needs to be
executed only when the content
+ * Creates the {@value TransformingReader#FILENAME} file. This class needs to
be executed only when the content
* has changed, or for verifying the current file. Output format contains
namespaces first, then classes,
* then properties. Example:
*
@@ -74,7 +74,7 @@ public final class NamespaceContent {
private final Map<String, Map<String, Set<String>>> content;
/**
- * Creates a new {@value FilteredReader#FILENAME} generator for classes
under the given directory.
+ * Creates a new {@value TransformingReader#FILENAME} generator for
classes under the given directory.
* The given directory shall be the root of {@code "*.class"} files.
*
* @param classRootDirectory the root of compiled class files.
@@ -136,7 +136,7 @@ public final class NamespaceContent {
*/
final String topLevelTypeName = root.name();
String classNS = namespace(classe, root.namespace());
- add(classNS, topLevelTypeName, FilteredReader.TYPE_KEY);
+ add(classNS, topLevelTypeName, TransformingReader.TYPE_KEY);
for (;; classNS = namespace(classe, root.namespace())) {
for (final Method method : classe.getDeclaredMethods()) {
if (!method.isBridge()) {
@@ -170,7 +170,7 @@ public final class NamespaceContent {
}
}
if (singleton != null) {
- add(namespace(classe, singleton.namespace()),
singleton.name(), FilteredReader.TYPE_KEY);
+ add(namespace(classe, singleton.namespace()),
singleton.name(), TransformingReader.TYPE_KEY);
}
}
}
@@ -198,7 +198,7 @@ public final class NamespaceContent {
}
/**
- * Prints the {@value FilteredReader#FILENAME} file.
+ * Prints the {@value TransformingReader#FILENAME} file.
*
* @param out where to print the content.
* @throws IOException if an error occurred while printing the content.
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Namespaces.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -632,8 +632,8 @@ public final class Namespaces extends St
*/
public static String guessForType(final String type) {
/*
- * Implementation note: we could invoke FilteredReader.namespace(type)
unconditionally,
- * but that method may be removed in a future SIS version if we
replace FilteredReader
+ * Implementation note: we could invoke
TransformingReader.namespace(type) unconditionally,
+ * but that method may be removed in a future SIS version if we
replace TransformingReader
* by XSD
(https://issues.apache.org/jira/projects/SIS/issues/SIS-381). By using a switch
now,
* we reduce the behavioral change is SIS-381 is applied. It can also
reduce classes loading.
*/
@@ -647,7 +647,7 @@ public final class Namespaces extends St
case ('L' << Character.SIZE) | 'I': return MRL;
case ('D' << Character.SIZE) | 'S': // Usually MDA except
for DS_InitiativeTypeCode
case ('M' << Character.SIZE) | 'D':
- case ('M' << Character.SIZE) | 'I': return
FilteredReader.namespace(type);
+ case ('M' << Character.SIZE) | 'I': return
TransformingReader.namespace(type);
case ('M' << Character.SIZE) | 'X': return MDT;
case ('P' << Character.SIZE) | 'T': return LAN;
case ('S' << Character.SIZE) | 'V': return SRV;
@@ -657,7 +657,7 @@ public final class Namespaces extends St
}
} else {
// Needs to handle at least DCPList
- return FilteredReader.namespace(type);
+ return TransformingReader.namespace(type);
}
}
return null;
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -241,15 +241,14 @@ abstract class Pooled {
protected abstract void reset(final Object key, final Object value) throws
JAXBException;
/**
- * Returns the {@code FilterVersion} enumeration value to use for the
current GML or metadata version,
- * or {@code null} if the SIS native versions are suitable. If this method
returns a non-null value,
- * then the output generated by JAXB will need to go through a {@link
FilteredWriter} in order to
- * replace the namespace of versions implemented by SIS by the namespace
of versions requested by
- * the user.
+ * Returns the {@code TransformVersion} enumeration value to use for the
current GML or metadata version,
+ * or {@code null} if the SIS native versions are suitable. If this method
returns a non-null value, then
+ * the output generated by JAXB will need to go through a {@link
TransformingWriter} in order to replace
+ * the namespace of versions implemented by SIS by the namespace of
versions requested by the user.
*
- * @see FilteredNamespaces
+ * @see TransformingNamespaces
*/
- final FilterVersion getFilterVersion() {
+ final TransformVersion getTransformVersion() {
/*
* If no version is specified, then the default behavior will be:
* - enable namespace replacement on unmarshalling (in order to
accept all versions)
@@ -266,9 +265,9 @@ abstract class Pooled {
if (versionMetadata == null ? byDefault :
versionMetadata.compareTo(LegacyNamespaces.VERSION_2014) < 0) combine |= 2;
switch (combine) {
case 0: return null;
- case 1: return FilterVersion.GML31;
- case 2: return FilterVersion.ISO19139;
- case 3: return FilterVersion.ALL;
+ case 1: return TransformVersion.GML31;
+ case 2: return TransformVersion.ISO19139;
+ case 3: return TransformVersion.ALL;
default: throw new AssertionError(combine); // Should never
happen.
}
}
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledMarshaller.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -48,7 +48,7 @@ import org.apache.sis.internal.jaxb.Type
* when the marshaller is recycled.</li>
* <li>Constructs a SIS {@link Context} object on marshalling, in order to
give
* additional information to the SIS object being marshalled.</li>
- * <li>Wraps the output stream in a {@link FilteredWriter} if the desired
GML version
+ * <li>Wraps the output stream in a {@link TransformingWriter} if the
desired GML version
* in not the SIS native GML version.</li>
* </ul>
*
@@ -132,18 +132,17 @@ final class PooledMarshaller extends Poo
/**
* Marshals to the given output with on-the-fly substitution of namespaces.
- * This method is invoked only when the user asked to marshal to a
different GML version
- * than the one supported natively by SIS, i.e. when {@link
#getFilterVersion()} returns
- * a non-null value.
+ * This method is invoked when the user asked to marshal to a different
GML or metadata version than the
+ * one supported natively by SIS, i.e. when {@link #getTransformVersion()}
returns a non-null value.
*
* @param object the object to marshal.
* @param output the writer created by SIS (<b>not</b> the writer given
by the user).
* @param version identifies the namespace substitutions to perform.
*/
- private void marshal(final Object object, XMLEventWriter output, final
FilterVersion version)
+ private void marshal(final Object object, XMLEventWriter output, final
TransformVersion version)
throws XMLStreamException, JAXBException
{
- output = new FilteredWriter(output, version);
+ output = new TransformingWriter(output, version);
final Context context = begin();
try {
marshaller.marshal(toImplementation(object), output);
@@ -158,7 +157,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, final Result output) throws
JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
marshal(object, OutputFactory.createXMLEventWriter(output),
version);
} catch (XMLStreamException e) {
@@ -179,7 +178,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, final OutputStream output) throws
JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
marshal(object, OutputFactory.createXMLEventWriter(output,
getEncoding()), version);
} catch (XMLStreamException e) {
@@ -200,7 +199,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, final File output) throws
JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
try (OutputStream s = new BufferedOutputStream(new
FileOutputStream(output))) {
marshal(object, OutputFactory.createXMLEventWriter(s,
getEncoding()), version);
@@ -223,7 +222,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, final Writer output) throws
JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
marshal(object, OutputFactory.createXMLEventWriter(output),
version);
} catch (XMLStreamException e) {
@@ -244,7 +243,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, final ContentHandler output)
throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
marshal(object, OutputFactory.createXMLEventWriter(output),
version);
} catch (XMLStreamException e) {
@@ -265,7 +264,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, final Node output) throws
JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
marshal(object, OutputFactory.createXMLEventWriter(output),
version);
} catch (XMLStreamException e) {
@@ -286,7 +285,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, final XMLStreamWriter output)
throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
marshal(object, OutputFactory.createXMLEventWriter(output),
version);
} catch (XMLStreamException e) {
@@ -307,9 +306,9 @@ final class PooledMarshaller extends Poo
*/
@Override
public void marshal(final Object object, XMLEventWriter output) throws
JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) {
- output = new FilteredWriter(output, version);
+ output = new TransformingWriter(output, version);
}
final Context context = begin();
try {
@@ -324,7 +323,7 @@ final class PooledMarshaller extends Poo
*/
@Override
public Node getNode(final Object object) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) {
// This exception is thrown by
javax.xml.bind.helpers.AbstractMarshallerImpl anyway.
throw new UnsupportedOperationException();
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/PooledUnmarshaller.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -50,7 +50,7 @@ import org.apache.sis.internal.jaxb.Cont
* when the unmarshaller is recycled.</li>
* <li>Constructs a SIS {@link Context} object on unmarshalling, in order to
give
* additional information to the SIS object being unmarshalled.</li>
- * <li>Wraps the input stream in a {@link FilteredReader} if the document
GML version
+ * <li>Wraps the input stream in a {@link TransformingReader} if the
document GML version
* in not the SIS native GML version.</li>
* </ul>
*
@@ -109,18 +109,17 @@ final class PooledUnmarshaller extends P
/**
* Unmarshals to the given input with on-the-fly substitution of
namespaces.
- * This method is invoked only when the user asked to marshal from a
different GML version
- * than the one supported natively by SIS, i.e. when {@link
#getFilterVersion()} returns a
- * non-null value.
+ * This method is invoked when we may marshal a different GML or metadata
version than the one
+ * supported natively by SIS, i.e. when {@link #getTransformVersion()}
returns a non-null value.
*
* @param input the reader created by SIS (<b>not</b> the reader given
by the user).
* @param version identify the namespace substitutions to perform.
* @return the unmarshalled object.
*/
- private Object unmarshal(XMLEventReader input, final FilterVersion version)
+ private Object unmarshal(XMLEventReader input, final TransformVersion
version)
throws XMLStreamException, JAXBException
{
- input = new FilteredReader(input, version);
+ input = new TransformingReader(input, version);
final Context context = begin();
final Object object;
try {
@@ -133,13 +132,13 @@ final class PooledUnmarshaller extends P
}
/**
- * Same as {@link #unmarshal(XMLEventReader, FilterVersion)}, but
delegating to the unmarshaller
+ * Same as {@link #unmarshal(XMLEventReader, TransformVersion)}, but
delegating to the unmarshaller
* methods returning a JAXB element instead than the one returning the
object.
*/
- private <T> JAXBElement<T> unmarshal(XMLEventReader input, final
FilterVersion version, final Class<T> declaredType)
+ private <T> JAXBElement<T> unmarshal(XMLEventReader input, final
TransformVersion version, final Class<T> declaredType)
throws XMLStreamException, JAXBException
{
- input = new FilteredReader(input, version);
+ input = new TransformingReader(input, version);
final Context context = begin();
final JAXBElement<T> object;
try {
@@ -156,7 +155,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final InputStream input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version);
} catch (XMLStreamException e) {
@@ -176,7 +175,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final URL input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
try (InputStream s = input.openStream()) {
return unmarshal(InputFactory.createXMLEventReader(s),
version);
@@ -198,7 +197,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final File input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
try (InputStream s = new BufferedInputStream(new
FileInputStream(input))) {
return unmarshal(InputFactory.createXMLEventReader(s),
version);
@@ -220,7 +219,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final Reader input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version);
} catch (XMLStreamException e) {
@@ -240,7 +239,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final InputSource input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version);
} catch (XMLStreamException e) {
@@ -260,7 +259,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final Node input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version);
} catch (XMLStreamException e) {
@@ -280,7 +279,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public <T> JAXBElement<T> unmarshal(final Node input, final Class<T>
declaredType) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version, declaredType);
} catch (XMLStreamException e) {
@@ -300,7 +299,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final Source input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version);
} catch (XMLStreamException e) {
@@ -320,7 +319,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public <T> JAXBElement<T> unmarshal(final Source input, final Class<T>
declaredType) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version, declaredType);
} catch (XMLStreamException e) {
@@ -340,7 +339,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(final XMLStreamReader input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version);
} catch (XMLStreamException e) {
@@ -360,7 +359,7 @@ final class PooledUnmarshaller extends P
*/
@Override
public <T> JAXBElement<T> unmarshal(final XMLStreamReader input, final
Class<T> declaredType) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) try {
return unmarshal(InputFactory.createXMLEventReader(input),
version, declaredType);
} catch (XMLStreamException e) {
@@ -380,9 +379,9 @@ final class PooledUnmarshaller extends P
*/
@Override
public Object unmarshal(XMLEventReader input) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) {
- input = new FilteredReader(input, version);
+ input = new TransformingReader(input, version);
}
final Context context = begin();
try {
@@ -397,9 +396,9 @@ final class PooledUnmarshaller extends P
*/
@Override
public <T> JAXBElement<T> unmarshal(XMLEventReader input, final Class<T>
declaredType) throws JAXBException {
- final FilterVersion version = getFilterVersion();
+ final TransformVersion version = getTransformVersion();
if (version != null) {
- input = new FilteredReader(input, version);
+ input = new TransformingReader(input, version);
}
final Context context = begin();
try {
Copied:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java
(from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java)
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java&p1=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java&r1=1824588&r2=1824589&rev=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformVersion.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -25,9 +25,9 @@ import org.apache.sis.internal.jaxb.Lega
/**
- * The target version of standards for {@link FilteredNamespaces}.
+ * The target version of standards for {@link TransformingNamespaces}.
*
- * See {@link FilteredNamespaces} for more information.
+ * See {@link TransformingNamespaces} for more information.
*
* @author Martin Desruisseaux (Geomatys)
* @author Cullen Rombach (Image Matters)
@@ -35,11 +35,11 @@ import org.apache.sis.internal.jaxb.Lega
* @since 0.4
* @module
*/
-final class FilterVersion {
+final class TransformVersion {
/**
* Metadata using the legacy ISO 19139:2007 schema (replaced by ISO
19115-3).
*/
- static final FilterVersion ISO19139 = new FilterVersion(42, 2);
+ static final TransformVersion ISO19139 = new TransformVersion(42, 2);
static {
ISO19139.addSurjectives(new String[] {
Namespaces.CAT,
@@ -92,11 +92,10 @@ final class FilterVersion {
r = new Replacement(LegacyNamespaces.GMD, "objectiveOccurence",
"objectiveOccurance");
ISO19139.exports.put(Namespaces.MAC, r);
/*
- * For the way back from legacy ISO 19139:2007 to new ISO
19115-3:2016, we must rely on
- * FilteredReader (do NOT declare entries in 'imports', because some
namespaces must be
- * left unchanged). An exception to this rule is the "gco" namespace
because our reader
- * renames only element namespaces while we need to rename also
attributes in "gco"
- * namespace (e.g. "gco:nilReason").
+ * For the way back from legacy ISO 19139:2007 to new ISO
19115-3:2016, we must rely on TransformingReader
+ * (do NOT declare entries in 'imports', because some namespaces must
be left unchanged). An exception to
+ * this rule is the "gco" namespace, because our reader renames only
element namespaces while we need to
+ * rename also attributes in "gco" namespace (e.g. "gco:nilReason").
*/
ISO19139.addSurjective(Namespaces.GCX, LegacyNamespaces.GMX);
ISO19139.addBijective (Namespaces.GCO, LegacyNamespaces.GCO);
@@ -106,7 +105,7 @@ final class FilterVersion {
* GML using the legacy {@code "http://www.opengis.net/gml"} namespace.
* Note that the use of GML 3.2 implies the use of ISO 19139:2007.
*/
- static final FilterVersion GML31 = new FilterVersion(ISO19139);
+ static final TransformVersion GML31 = new TransformVersion(ISO19139);
static {
GML31.addBijective(Namespaces.GML, LegacyNamespaces.GML);
}
@@ -115,7 +114,7 @@ final class FilterVersion {
* Apply all known namespace replacements. This can be used only at
unmarshalling time,
* for replacing all namespaces by the namespaces declared in Apache SIS
JAXB annotations.
*/
- static final FilterVersion ALL = GML31;
+ static final TransformVersion ALL = GML31;
/**
* The exported namespace used in the XML file instead then the namespaces
used by JAXB annotations.
@@ -184,7 +183,7 @@ final class FilterVersion {
/**
* The URI replacements to apply when going from the model implemented by
Apache SIS
- * to the filtered reader/writer. Keys are the URIs as declared in JAXB
annotations,
+ * to the transforming reader/writer. Keys are the URIs as declared in
JAXB annotations,
* and values are the URIs to write instead of the actual ones.
*
* <p>This map shall not be modified after construction.
@@ -195,10 +194,10 @@ final class FilterVersion {
private final Map<String, Replacement> exports;
/**
- * The URI replacements to apply when going from the filtered
reader/writer to the
- * model implemented by Apache SIS. This map is the converse of {@link
#exports}.
+ * The URI replacements to apply when going from the transforming
reader/writer to
+ * the model implemented by Apache SIS. This map is the converse of {@link
#exports}.
* It does not contain the map of properties to rename because that map is
handled
- * by {@link FilteredReader} instead, as part of {@code
NamespaceContent.lst} file.
+ * by {@link TransformingReader} instead, as part of {@code
NamespaceContent.lst} file.
*
* <p>This map shall not be modified after construction.
* We do not wrap in {@link Collections#unmodifiableMap(Map)} for
efficiency.</p>
@@ -211,7 +210,7 @@ final class FilterVersion {
* @param ec exports capacity.
* @param ic imports capacity.
*/
- private FilterVersion(final int ec, final int ic) {
+ private TransformVersion(final int ec, final int ic) {
exports = new HashMap<>(ec);
imports = new HashMap<>(ic);
}
@@ -220,7 +219,7 @@ final class FilterVersion {
* Creates an enumeration initialized to a copy of the given enumeration.
* This construction should be followed by calls to {@code add(…)} methods.
*/
- private FilterVersion(final FilterVersion first) {
+ private TransformVersion(final TransformVersion first) {
exports = new HashMap<>(first.exports);
imports = new HashMap<>(first.imports);
}
@@ -260,7 +259,7 @@ final class FilterVersion {
* Returns the same URI if there is no replacement.
*/
final String exportNS(final String uri) {
- final FilterVersion.Replacement r = exports.get(uri);
+ final TransformVersion.Replacement r = exports.get(uri);
return (r != null) ? r.namespace : uri;
}
@@ -283,7 +282,7 @@ final class FilterVersion {
/**
* Returns the URI replacements to apply when going from the model
implemented by Apache SIS to the
- * filtered reader/writer. Used only for more sophisticated work than what
{@link #exportNS(String)} does.
+ * transforming reader/writer. Used only for more sophisticated work than
what {@link #exportNS(String)} does.
* Returned as an iterator for avoiding to expose modifiable map; do not
invoke {@link Iterator#remove()}.
*/
final Iterator<Map.Entry<String, Replacement>> exports() {
Copied:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformedEvent.java
(from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredEvent.java)
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformedEvent.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformedEvent.java&p1=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredEvent.java&r1=1824588&r2=1824589&rev=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredEvent.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformedEvent.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -42,7 +42,7 @@ import javax.xml.namespace.QName;
* @since 1.0
* @module
*/
-abstract class FilteredEvent<E extends XMLEvent> implements XMLEvent {
+abstract class TransformedEvent<E extends XMLEvent> implements XMLEvent {
/**
* The event to be exported in a different namespace.
*/
@@ -60,7 +60,7 @@ abstract class FilteredEvent<E extends X
* @param event the event to be exported in a different namespace.
* @param name the exported name of the attribute or element.
*/
- FilteredEvent(final E event, final QName name) {
+ TransformedEvent(final E event, final QName name) {
this.event = event;
this.name = name;
}
@@ -130,7 +130,7 @@ abstract class FilteredEvent<E extends X
* Wrapper over a namespace emitted during the reading or writing of an
XML document.
* This wrapper is used for changing the namespace URI.
*/
- static final class NS extends FilteredEvent<Namespace> implements
Namespace {
+ static final class NS extends TransformedEvent<Namespace> implements
Namespace {
/** The URI of the namespace. */
private final String namespaceURI;
@@ -157,7 +157,7 @@ abstract class FilteredEvent<E extends X
* Wrapper over an attribute emitted during the reading or writing of an
XML document.
* This wrapper is used for changing the namespace of the attribute.
*/
- static final class Attr extends FilteredEvent<Attribute> implements
Attribute {
+ static final class Attr extends TransformedEvent<Attribute> implements
Attribute {
/** Wraps the given event with a different name. */
Attr(final Attribute event, final QName name) {
super(event, name);
@@ -183,7 +183,7 @@ abstract class FilteredEvent<E extends X
* Wrapper over an element emitted during the reading or writing of an XML
document.
* This wrapper is used for changing the namespace and sometime the name
of the element.
*/
- static final class End extends FilteredEvent<EndElement> implements
EndElement {
+ static final class End extends TransformedEvent<EndElement> implements
EndElement {
/** The namespaces, may or may not be the same than the wrapped event.
*/
private final List<Namespace> namespaces;
@@ -207,7 +207,7 @@ abstract class FilteredEvent<E extends X
* This wrapper is used for changing the namespace and sometime the name
of the element.
* The attributes may also be modified.
*/
- static class Start extends FilteredEvent<StartElement> implements
StartElement {
+ static class Start extends TransformedEvent<StartElement> implements
StartElement {
/** The namespaces, may or may not be the same than the wrapped event.
*/
private final List<Namespace> namespaces;
@@ -215,10 +215,10 @@ abstract class FilteredEvent<E extends X
private final List<Attribute> attributes;
/** The version to export, used for wrapping namespace context. */
- final FilterVersion version;
+ final TransformVersion version;
/** Wraps the given event with potentially different name, namespaces
and attributes. */
- Start(StartElement event, QName name, List<Namespace> namespaces,
List<Attribute> attributes, FilterVersion version) {
+ Start(StartElement event, QName name, List<Namespace> namespaces,
List<Attribute> attributes, TransformVersion version) {
super(event, name);
this.namespaces = namespaces;
this.attributes = attributes;
@@ -256,12 +256,12 @@ abstract class FilteredEvent<E extends X
* this method returns {@code null}.</div>
*
* <p>At unmarshalling time, events are created by an arbitrary {@link
javax.xml.stream.XMLEventReader}
- * with namespaces used in the XML document. {@link FilteredReader}
wraps those events using this class
- * for converting the XML namespaces to the namespaces used by JAXB
annotations.</p>
+ * with namespaces used in the XML document. {@link
TransformingReader} wraps those events using this
+ * class for converting the XML namespaces to the namespaces used by
JAXB annotations.</p>
*
* <p>At marshalling time, events are created by JAXB using namespaces
used in JAXB annotations.
- * {@link FilteredWriter} wraps those events for converting those
namespaces to the ones used in
- * the XML document. This is the opposite than the work performed by
this default implementation
+ * {@link TransformingWriter} wraps those events for converting those
namespaces to the ones used
+ * in the XML document. This is the opposite than the work performed
by this default implementation
* and must be handled by a {@code Start} subclass.</p>
*/
@Override
@@ -271,12 +271,12 @@ abstract class FilteredEvent<E extends X
/**
* Returns a context mapping prefixes used in XML document to
namespaces used in JAXB annotations.
- * The {@code FilteredNamespaces.Inverse.getNamespaceURI(String)}
method in that context shall do
+ * The {@code TransformingNamespaces.Inverse.getNamespaceURI(String)}
method in that context shall do
* the same work than {@link #getNamespaceURI(String)} in this event.
*/
@Override
public NamespaceContext getNamespaceContext() {
- return FilteredNamespaces.asJAXB(event.getNamespaceContext(),
version);
+ return TransformingNamespaces.asJAXB(event.getNamespaceContext(),
version);
}
/**
Copied:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java
(from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredXML.java)
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java&p1=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredXML.java&r1=1824588&r2=1824589&rev=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredXML.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Transformer.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -27,7 +27,7 @@ import javax.xml.stream.events.Attribute
* Base class of XML reader or writer replacing the namespaces used by JAXB by
namespaces used in the XML document,
* or conversely (depending on the direction of the I/O operation).
*
- * See {@link FilteredNamespaces} for more information.
+ * See {@link TransformingNamespaces} for more information.
*
* @author Martin Desruisseaux (Geomatys)
* @author Cullen Rombach (Image Matters)
@@ -35,11 +35,11 @@ import javax.xml.stream.events.Attribute
* @since 1.0
* @module
*/
-abstract class FilteredXML {
+abstract class Transformer {
/**
* The external XML format version to (un)marshal from.
*/
- final FilterVersion version;
+ final TransformVersion version;
/**
* Temporary list of attributes after their namespace change.
@@ -50,7 +50,7 @@ abstract class FilteredXML {
/**
* Creates a new XML reader or writer.
*/
- FilteredXML(final FilterVersion version) {
+ Transformer(final TransformVersion version) {
this.version = version;
renamedAttributes = new ArrayList<>();
}
Copied:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java
(from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredNamespaces.java)
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java&p1=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredNamespaces.java&r1=1824588&r2=1824589&rev=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredNamespaces.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingNamespaces.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -24,9 +24,9 @@ import javax.xml.XMLConstants;
/**
- * In the associations between prefixes and namespaces, substitutes the
namespaces used in JAXB annotations by the
- * namespaces used in the XML document at marshalling time. This class is used
internally by {@link FilteredReader}
- * and {@link FilteredWriter} only.
+ * In the associations between prefixes and namespaces, substitutes the
namespaces used in JAXB annotations
+ * by the namespaces used in the XML document at marshalling time. This class
is used internally by
+ * {@link TransformingReader} and {@link TransformingWriter} only.
*
* <div class="section">The problem</div>
* When the XML schemas of an international standard is updated, the URL of
the namespace is often modified.
@@ -61,7 +61,7 @@ import javax.xml.XMLConstants;
* @since 0.4
* @module
*/
-class FilteredNamespaces implements NamespaceContext {
+class TransformingNamespaces implements NamespaceContext {
/**
* Given the context for namespaces used in our JAXB annotations, returns
a context working with namespaces
* used in XML document. The returned context converts namespace arguments
from XML to JAXB namespaces, and
@@ -74,12 +74,12 @@ class FilteredNamespaces implements Name
* Conversely given a {@code "mdb"}, {@code "cit"}, <i>etc.</i>, prefix,
{@link #getNamespaceURI(String)}
* method returns the above-cited legacy GMD namespace.</div>
*/
- static NamespaceContext asXML(NamespaceContext context, final
FilterVersion version) {
+ static NamespaceContext asXML(NamespaceContext context, final
TransformVersion version) {
if (context != null) {
if (context instanceof Inverse && ((Inverse) context).version ==
version) {
context = ((Inverse) context).context;
} else {
- context = new FilteredNamespaces(context, version);
+ context = new TransformingNamespaces(context, version);
}
}
return context;
@@ -91,21 +91,21 @@ class FilteredNamespaces implements Name
* before to delegate to the wrapped context, and converts returned
namespaces from XML to JAXB.
*
* <p>This can be used when a {@link javax.xml.stream.XMLEventWriter} has
been created for writing a legacy
- * XML document and we want to expose a {@link FilteredWriter} view to
give to JAXB.</p>
+ * XML document and we want to expose a {@link TransformingWriter} view to
give to JAXB.</p>
*/
- static NamespaceContext asJAXB(NamespaceContext context, final
FilterVersion version) {
+ static NamespaceContext asJAXB(NamespaceContext context, final
TransformVersion version) {
if (context != null) {
- if (context.getClass() == FilteredNamespaces.class &&
((FilteredNamespaces) context).version == version) {
- context = ((FilteredNamespaces) context).context;
+ if (context.getClass() == TransformingNamespaces.class &&
((TransformingNamespaces) context).version == version) {
+ context = ((TransformingNamespaces) context).context;
} else {
- context = new FilteredNamespaces.Inverse(context, version);
+ context = new TransformingNamespaces.Inverse(context, version);
}
}
return context;
}
/**
- * The context to wrap, given by {@link FilteredReader} or {@link
FilteredWriter}.
+ * The context to wrap, given by {@link TransformingReader} or {@link
TransformingWriter}.
*
* @see javax.xml.stream.XMLEventWriter#getNamespaceContext()
*/
@@ -114,12 +114,12 @@ class FilteredNamespaces implements Name
/**
* The URI replacements to apply when exporting from the JAXB annotations
to the XML documents.
*/
- final FilterVersion version;
+ final TransformVersion version;
/**
- * Creates a new namespaces filter for the given target version.
+ * Creates a new namespaces transformer for the given target version.
*/
- private FilteredNamespaces(final NamespaceContext context, final
FilterVersion version) {
+ private TransformingNamespaces(final NamespaceContext context, final
TransformVersion version) {
this.context = context;
this.version = version;
}
@@ -127,13 +127,13 @@ class FilteredNamespaces implements Name
/**
* Substitutes the XML namespaces used in XML documents by namespaces used
in JAXB annotations.
* This is used at marshalling time for exporting legacy documents,
performing the reverse of
- * {@link FilteredNamespaces}. The <i>namespace → prefix</i> mapping is
simple because various
+ * {@link TransformingNamespaces}. The <i>namespace → prefix</i> mapping
is simple because various
* ISO 19115-3 namespaces are mapped to the same legacy {@code "gmd"}
prefix, but the reverse
* operation (<i>prefix → namespace</i> mapping) can often not be resolved.
*/
- private static final class Inverse extends FilteredNamespaces {
- /** Creates a new namespaces filter for the given source version. */
- Inverse(final NamespaceContext context, final FilterVersion version) {
+ private static final class Inverse extends TransformingNamespaces {
+ /** Creates a new namespaces transformer for the given source version.
*/
+ Inverse(final NamespaceContext context, final TransformVersion
version) {
super(context, version);
}
@@ -145,7 +145,7 @@ class FilteredNamespaces implements Name
* <p>Except for {@code NULL_NS_URI}, this is usually an
<cite>injective</cite> function:
* each namespace can be created from at most one prefix.</p>
*
- * @see FilteredEvent.Start#getNamespaceURI(String)
+ * @see TransformedEvent.Start#getNamespaceURI(String)
*/
@Override public String getNamespaceURI(final String prefix) {
return version.importNS(context.getNamespaceURI(prefix));
@@ -166,7 +166,7 @@ class FilteredNamespaces implements Name
/**
* Returns all prefixes for the given namespace. There is usually only
one, contrarily
- * to {@link FilteredNamespaces#getPrefixes(String)} which have many.
+ * to {@link TransformingNamespaces#getPrefixes(String)} which have
many.
*
* <p>This is a <cite>surjective</cite> function:
* many prefixes can be created from the same namespace.</p>
@@ -202,9 +202,9 @@ class FilteredNamespaces implements Name
* legacy ISO 19139:2007) is mapped to multiple namespaces in the new
ISO 19115-3:2016 or other standard.
* In such case, we have to iterate over 'exports' entries until we
find an inverse mapping.
*/
- final Iterator<Map.Entry<String, FilterVersion.Replacement>> it =
version.exports();
+ final Iterator<Map.Entry<String, TransformVersion.Replacement>> it =
version.exports();
while (it.hasNext()) {
- final Map.Entry<String, FilterVersion.Replacement> e = it.next();
+ final Map.Entry<String, TransformVersion.Replacement> e =
it.next();
if (namespaceURI.equals(e.getValue().namespace)) {
p = context.getPrefix(e.getKey());
if (p != null) return p;
@@ -224,18 +224,18 @@ class FilteredNamespaces implements Name
}
/**
- * Iterator for the prefixes to be returned by {@link
FilteredNamespaces#getPrefixes(String)}.
+ * Iterator for the prefixes to be returned by {@link
TransformingNamespaces#getPrefixes(String)}.
* Each prefix is fetched only when first needed.
*/
private static final class Prefixes implements Iterator<String> {
/** The namespace for which prefixes are desired. */
private final String namespaceURI;
- /** The {@link FilteredNamespaces#context} reference. */
+ /** * The {@link TransformingNamespaces#context} reference. */
private final NamespaceContext context;
/** Iterator over the namespace replacements. */
- private final Iterator<Map.Entry<String, FilterVersion.Replacement>>
exports;
+ private final Iterator<Map.Entry<String,
TransformVersion.Replacement>> exports;
/** Iterator over some (not all) prefixes, or {@code null} if a new
iterator needs to be fetched. */
private Iterator<String> prefixes;
@@ -244,7 +244,7 @@ class FilteredNamespaces implements Name
private String next;
/** Creates a new iterator for the prefixes associated to the given
namespace URI. */
- Prefixes(final NamespaceContext context, final
Iterator<Map.Entry<String, FilterVersion.Replacement>> exports,
+ Prefixes(final NamespaceContext context, final
Iterator<Map.Entry<String, TransformVersion.Replacement>> exports,
final String namespaceURI)
{
this.context = context;
@@ -264,7 +264,7 @@ class FilteredNamespaces implements Name
if (!exports.hasNext()) {
return false;
}
- final Map.Entry<String, FilterVersion.Replacement> e =
exports.next();
+ final Map.Entry<String, TransformVersion.Replacement> e =
exports.next();
if (namespaceURI.equals(e.getValue().namespace)) {
prefixes = context.getPrefixes(e.getKey());
}
Copied:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java
(from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredReader.java)
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java&p1=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredReader.java&r1=1824588&r2=1824589&rev=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredReader.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingReader.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -44,7 +44,7 @@ import static javax.xml.stream.XMLStream
/**
- * A filter replacing the namespaces found in XML documents by the namespaces
expected by SIS at unmarshalling time.
+ * A XML reader replacing the namespaces found in XML documents by the
namespaces expected by SIS at unmarshalling time.
* This class forwards every method calls to the wrapped {@link
XMLEventReader}, but with some {@code namespaceURI}
* modified before being transfered. This class uses a dictionary for
identifying the XML namespaces expected by JAXB
* implementation. This is needed when a single namespace in a legacy schema
has been splitted into many namespaces
@@ -57,10 +57,10 @@ import static javax.xml.stream.XMLStream
* @since 1.0
* @module
*/
-final class FilteredReader extends FilteredXML implements XMLEventReader {
+final class TransformingReader extends Transformer implements XMLEventReader {
/**
* Location of the file listing types and properties contained in
namespaces.
- * The file location is relative to this {@code FilteredReader} class.
+ * The file location is relative to this {@code TransformingReader} class.
* The file format is a tree structured with indentation as below:
*
* <ul>
@@ -120,7 +120,7 @@ final class FilteredReader extends Filte
static {
final Map<String, Map<String,String>> m = new HashMap<>(250);
try (LineNumberReader in = new LineNumberReader(new InputStreamReader(
- FilteredReader.class.getResourceAsStream(FILENAME), "UTF-8")))
+ TransformingReader.class.getResourceAsStream(FILENAME),
"UTF-8")))
{
Map<String,String> attributes = null; // All
attributes for a given type.
String namespace = null; // Value to
store in 'attributes' map.
@@ -241,9 +241,9 @@ final class FilteredReader extends Filte
private XMLEvent nextEvent;
/**
- * Creates a new filter for the given version of the standards.
+ * Creates a new reader for the given version of the standards.
*/
- FilteredReader(final XMLEventReader in, final FilterVersion version) {
+ TransformingReader(final XMLEventReader in, final TransformVersion
version) {
super(version);
this.in = in;
outerElements = new ArrayList<>();
@@ -255,7 +255,7 @@ final class FilteredReader extends Filte
* This method is used for assertions only.
*/
private static boolean isWrapper(final XMLEvent event, final XMLEvent
wrapper) {
- return (event == wrapper) || (wrapper instanceof FilteredEvent &&
((FilteredEvent) wrapper).event == event);
+ return (event == wrapper) || (wrapper instanceof TransformedEvent &&
((TransformedEvent) wrapper).event == event);
}
/**
@@ -364,7 +364,7 @@ final class FilteredReader extends Filte
final List<Namespace> namespaces = importNS(e.getNamespaces(),
originalName.getNamespaceURI(),
name.getNamespaceURI(), changed);
if (namespaces != null) {
- event = new FilteredEvent.Start(e, name, namespaces,
attributes(), version);
+ event = new TransformedEvent.Start(e, name, namespaces,
attributes(), version);
} else {
renamedAttributes.clear();
}
@@ -378,7 +378,7 @@ final class FilteredReader extends Filte
final List<Namespace> namespaces = importNS(e.getNamespaces(),
originalName.getNamespaceURI(),
name.getNamespaceURI(), name != originalName);
if (namespaces != null) {
- event = new FilteredEvent.End(e, name, namespaces);
+ event = new TransformedEvent.End(e, name, namespaces);
}
/*
* Close the last start element with a matching name. It
should be the last element
@@ -472,7 +472,7 @@ final class FilteredReader extends Filte
final QName originalName = attribute.getName();
final QName name = convert(originalName);
if (name != originalName) {
- attribute = new FilteredEvent.Attr(attribute, name);
+ attribute = new TransformedEvent.Attr(attribute, name);
}
return attribute;
}
@@ -494,12 +494,12 @@ final class FilteredReader extends Filte
private Namespace importNS(final Namespace namespace, final String oldURI,
final String newURI) {
String uri = namespace.getNamespaceURI();
if (uri != null && !uri.isEmpty()) {
- uri = FilteredXML.removeTrailingSlash(uri);
+ uri = removeTrailingSlash(uri);
final String imported = uri.equals(oldURI) ? newURI :
version.importNS(uri);
if (imported != uri) {
final String prefix = prefixes.computeIfAbsent(imported,
(ns) -> Namespaces.getPreferredPrefix(ns,
namespace.getPrefix()));
- return new FilteredEvent.NS(namespace, prefix, imported);
+ return new TransformedEvent.NS(namespace, prefix, imported);
}
}
return namespace;
@@ -508,7 +508,7 @@ final class FilteredReader extends Filte
/**
* Imports the namespaces read from the XML document.
*
- * @param namespaces the namespaces to filter.
+ * @param namespaces the namespaces to transform.
* @param oldURI an old URI which has been renamed as {@code
newURI}, or {@code null} if none.
* @param newURI the new URI for {@code oldURI}, or {@code null} if
{@code newURI} is null.
* @param changed whether to unconditionally pretend that there is a
change.
Copied:
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java
(from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredWriter.java)
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java&p1=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredWriter.java&r1=1824588&r2=1824589&rev=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredWriter.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/TransformingWriter.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -42,11 +42,11 @@ import static javax.xml.stream.XMLStream
/**
- * A filter replacing the namespaces used by JAXB by other namespaces to be
used in the XML document
+ * A writer replacing the namespaces used by JAXB by other namespaces to be
used in the XML document
* at marshalling time. This class forwards every method calls to the wrapped
{@link XMLEventWriter},
- * with all {@code namespaceURI} arguments filtered before to be delegated.
+ * with all {@code namespaceURI} arguments transformed before to be delegated.
*
- * See {@link FilteredNamespaces} for more information.
+ * See {@link TransformingNamespaces} for more information.
*
* @author Martin Desruisseaux (Geomatys)
* @author Cullen Rombach (Image Matters)
@@ -54,7 +54,7 @@ import static javax.xml.stream.XMLStream
* @since 1.0
* @module
*/
-final class FilteredWriter extends FilteredXML implements XMLEventWriter {
+final class TransformingWriter extends Transformer implements XMLEventWriter {
/**
* Elements that appear in different order in ISO 19139:2007 (or other
legacy standards) compared
* to ISO 19115-3:2016 (or other newer standards). Key are names of
elements to reorder. Values
@@ -140,9 +140,9 @@ final class FilteredWriter extends Filte
private int subtreeNesting;
/**
- * Creates a new filter for the given version of the standards.
+ * Creates a new writer for the given version of the standards.
*/
- FilteredWriter(final XMLEventWriter out, final FilterVersion version) {
+ TransformingWriter(final XMLEventWriter out, final TransformVersion
version) {
super(version);
this.out = out;
uniqueNamespaces = new LinkedHashMap<>();
@@ -157,7 +157,7 @@ final class FilteredWriter extends Filte
private QName export(QName name) throws XMLStreamException {
String uri = name.getNamespaceURI();
if (uri != null && !uri.isEmpty()) { //
Optimization for a common case.
- final FilterVersion.Replacement r = version.export(uri);
+ final TransformVersion.Replacement r = version.export(uri);
if (r != null) {
uri = r.namespace;
/*
@@ -193,7 +193,7 @@ final class FilteredWriter extends Filte
final QName originalName = attribute.getName();
final QName name = export(originalName);
if (name != originalName) {
- attribute = new FilteredEvent.Attr(attribute, name);
+ attribute = new TransformedEvent.Attr(attribute, name);
}
return attribute;
}
@@ -212,7 +212,7 @@ final class FilteredWriter extends Filte
final String exported = version.exportNS(removeTrailingSlash(uri));
if (exported != uri) {
return uniqueNamespaces.computeIfAbsent(exported, (k) -> {
- return new FilteredEvent.NS(namespace,
Namespaces.getPreferredPrefix(k, namespace.getPrefix()), k);
+ return new TransformedEvent.NS(namespace,
Namespaces.getPreferredPrefix(k, namespace.getPrefix()), k);
/*
* The new prefix selected by above line will be saved by
out.add(Namespace)
* after this method has been invoked by the NAMESPACE
case of add(XMLEvent).
@@ -231,7 +231,7 @@ final class FilteredWriter extends Filte
* (duplication may occur as a result of replacing various ISO 19115-3
namespaces by the legacy
* ISO 19139:2007 {@code "gmd"} unique namespace).
*
- * @param namespaces the namespaces to filter.
+ * @param namespaces the namespaces to transform.
* @param changed whether to unconditionally pretend that there is a
change.
* @return the updated namespaces, or {@code null} if there is no changes.
*/
@@ -283,7 +283,7 @@ final class FilteredWriter extends Filte
final QName name = export(originalName);
final List<Namespace> namespaces = export(e.getNamespaces(),
name != originalName);
if (namespaces != null) {
- event = new FilteredEvent.End(e, name, namespaces);
+ event = new TransformedEvent.End(e, name, namespaces);
}
if (toSkip != null) { // Check if a
previous START_ELEMENT found a need to reorder.
if (originalName.equals(subtreeRootName)) {
@@ -416,36 +416,36 @@ final class FilteredWriter extends Filte
*/
@Override
public void setNamespaceContext(final NamespaceContext context) throws
XMLStreamException {
- out.setNamespaceContext(FilteredNamespaces.asXML(context, version));
+ out.setNamespaceContext(TransformingNamespaces.asXML(context,
version));
}
/**
* Returns a naming context suitable for consumption by JAXB marshallers.
- * The {@link XMLEventWriter} wrapped by this {@code FilteredWriter} has
been created for writing in a file.
+ * The {@link XMLEventWriter} wrapped by this {@code TransformingWriter}
has been created for writing in a file.
* Consequently its naming context manages namespaces used in the XML
document. But the JAXB marshaller using
- * this {@code FilteredWriter} facade expects the namespaces declared in
JAXB annotations. Consequently this
+ * this {@code TransformingWriter} facade expects the namespaces declared
in JAXB annotations. Consequently this
* method returns an adapter that converts namespaces on the fly.
*
* @see Event#getNamespaceContext()
*/
@Override
public NamespaceContext getNamespaceContext() {
- return FilteredNamespaces.asJAXB(out.getNamespaceContext(), version);
+ return TransformingNamespaces.asJAXB(out.getNamespaceContext(),
version);
}
/**
* Wraps the {@link StartElement} produced by JAXB for using the
namespaces used in the XML document.
*/
- private static final class Event extends FilteredEvent.Start {
+ private static final class Event extends TransformedEvent.Start {
/** Wraps the given event with potentially different name, namespaces
and attributes. */
- Event(StartElement event, QName name, List<Namespace> namespaces,
List<Attribute> attributes, FilterVersion version) {
+ Event(StartElement event, QName name, List<Namespace> namespaces,
List<Attribute> attributes, TransformVersion version) {
super(event, name, namespaces, attributes, version);
}
/**
* Gets the URI used in the XML document for the given prefix used in
JAXB annotations.
* At marshalling time, events are created by JAXB using namespaces
used in JAXB annotations.
- * {@link FilteredWriter} wraps those events for converting those
namespaces to the ones used
+ * {@link TransformingWriter} wraps those events for converting those
namespaces to the ones used
* in the XML document.
*
* <div class="note"><b>Example:</b> the {@code "cit"} prefix from ISO
19115-3:2016 standard
@@ -460,14 +460,14 @@ final class FilteredWriter extends Filte
/**
* Returns a context mapping prefixes used in JAXB annotations to
namespaces used in XML document.
- * The {@link FilteredNamespaces#getNamespaceURI(String)} method in
that context shall do the same
+ * The {@link TransformingNamespaces#getNamespaceURI(String)} method
in that context shall do the same
* work than {@link #getNamespaceURI(String)} in this event.
*
- * @see FilteredNamespaces#getNamespaceURI(String)
+ * @see TransformingNamespaces#getNamespaceURI(String)
*/
@Override
public NamespaceContext getNamespaceContext() {
- return FilteredNamespaces.asXML(event.getNamespaceContext(),
version);
+ return TransformingNamespaces.asXML(event.getNamespaceContext(),
version);
}
}
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -150,7 +150,7 @@ import org.junit.BeforeClass;
org.apache.sis.xml.ValueConverterTest.class,
org.apache.sis.xml.OGCNamespacePrefixMapperTest.class,
org.apache.sis.xml.MarshallerPoolTest.class,
- org.apache.sis.xml.FilteredNamespacesTest.class,
+ org.apache.sis.xml.TransformingNamespacesTest.class,
org.apache.sis.internal.jaxb.XmlUtilitiesTest.class,
org.apache.sis.internal.jaxb.IdentifierMapAdapterTest.class,
org.apache.sis.internal.jaxb.ModifiableIdentifierMapTest.class,
Modified:
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java?rev=1824589&r1=1824588&r2=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/NamespacesTest.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -45,7 +45,7 @@ public final strictfp class NamespacesTe
/**
* Tests {@link Namespaces#guessForType(String)}. This method uses {@code
assertSame(…)} instead than
- * {@code assertEquals(…)} for verifying that {@link FilteredReader}
invoked {@link String#intern()}.
+ * {@code assertEquals(…)} for verifying that {@link TransformingReader}
invoked {@link String#intern()}.
*/
@Test
public void testGuessForType() {
Copied:
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/TransformingNamespacesTest.java
(from r1824588,
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/FilteredNamespacesTest.java)
URL:
http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/TransformingNamespacesTest.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/TransformingNamespacesTest.java&p1=sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/FilteredNamespacesTest.java&r1=1824588&r2=1824589&rev=1824589&view=diff
==============================================================================
---
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/FilteredNamespacesTest.java
[UTF-8] (original)
+++
sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/xml/TransformingNamespacesTest.java
[UTF-8] Sat Feb 17 13:46:34 2018
@@ -31,14 +31,14 @@ import static org.apache.sis.test.Assert
/**
- * Tests {@link FilteredNamespaces}.
+ * Tests {@link TransformingNamespaces}.
*
* @author Martin Desruisseaux (Geomatys)
* @version 1.0
* @since 1.0
* @module
*/
-public final strictfp class FilteredNamespacesTest extends TestCase implements
NamespaceContext {
+public final strictfp class TransformingNamespacesTest extends TestCase
implements NamespaceContext {
/**
* All prefixes declared in this test.
*/
@@ -47,12 +47,12 @@ public final strictfp class FilteredName
}
/**
- * Tests {@link FilteredNamespaces#getPrefixes(String)}.
+ * Tests {@link TransformingNamespaces#getPrefixes(String)}.
*/
@Test
@SuppressWarnings("unchecked") // TODO: remove with JDK9
public void testGetPrefixes() {
- final NamespaceContext fns = FilteredNamespaces.asXML(this,
FilterVersion.ISO19139);
+ final NamespaceContext fns = TransformingNamespaces.asXML(this,
TransformVersion.ISO19139);
final Iterator<String> it = fns.getPrefixes(LegacyNamespaces.GMD);
final Set<String> prefixes = new HashSet<>();
while (it.hasNext()) {
@@ -63,7 +63,7 @@ public final strictfp class FilteredName
/**
* Dummy implementation of {@link NamespaceContext#getPrefixes(String)}
for {@link #testGetPrefixes()} purpose.
- * This method will be invoked many times by the prefix iterator
implemented by {@link FilteredNamespaces}.
+ * This method will be invoked many times by the prefix iterator
implemented by {@link TransformingNamespaces}.
* This method implementation uses a hard-coded list of arbitrary prefixes.
*
* @param namespaceURI the namespace for which to get one or more
prefixes.
@@ -88,20 +88,20 @@ public final strictfp class FilteredName
}
/**
- * Tests {@link FilteredNamespaces#getPrefix(String)}.
+ * Tests {@link TransformingNamespaces#getPrefix(String)}.
*/
@Test
public void testGetPrefix() {
- final NamespaceContext fns = FilteredNamespaces.asXML(this,
FilterVersion.ISO19139);
+ final NamespaceContext fns = TransformingNamespaces.asXML(this,
TransformVersion.ISO19139);
/*
- * Following tests are not really interesting since FilteredNamespaces,
+ * Following tests are not really interesting since
TransformingNamespaces,
* after failing to find a mapping, just delegates to
this.getPrefix(…).
*/
assertEquals("cit", fns.getPrefix(Namespaces.CIT));
assertEquals("mdb", fns.getPrefix(Namespaces.MDB));
assertEquals("gex", fns.getPrefix(Namespaces.GEX));
/*
- * This is the interesting test: FilteredNamespaces replaces the gmd
namespace
+ * This is the interesting test: TransformingNamespaces replaces the
gmd namespace
* by one of the namespace recognized by this NamespaceContext, then
delegates.
*/
assertNull(getPrefix(LegacyNamespaces.GMD)); // This
test is useless if this is non-null.
@@ -111,7 +111,7 @@ public final strictfp class FilteredName
/**
* Dummy implementation of {@link NamespaceContext#getPrefix(String)} for
{@link #testGetPrefix()} purpose.
- * This method will be invoked many times by the prefix iterator
implemented by {@link FilteredNamespaces}.
+ * This method will be invoked many times by the prefix iterator
implemented by {@link TransformingNamespaces}.
* This method implementation uses a hard-coded list of arbitrary prefixes.
*
* @param namespaceURI the namespace for which to get an arbitrary
prefixes.