Package org.apache.sis.xml
Class PooledUnmarshaller
java.lang.Object
org.apache.sis.xml.Pooled
org.apache.sis.xml.PooledUnmarshaller
- All Implemented Interfaces:
Unmarshaller
Wraps a
Unmarshaller
in order to have some control on the modifications applied on it.
This wrapper serves three purposes:
- Save properties before modification, in order to restore them to their original values when the unmarshaller is recycled.
- Constructs a SIS
Context
object on unmarshalling, in order to give additional information to the SIS object being unmarshalled. - Wraps the input stream in a
TransformingReader
if the document GML version in not the SIS native GML version.
- Since:
- 0.3
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface javax.xml.bind.Unmarshaller
Unmarshaller.Listener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Unmarshaller
The wrapped marshaller which does the real work.Fields inherited from class org.apache.sis.xml.Pooled
initialProperties, resetTime
-
Constructor Summary
ConstructorsConstructorDescriptionPooledUnmarshaller
(Unmarshaller unmarshaller, Pooled template) Creates a pooled unmarshaller wrapping the given one. -
Method Summary
Modifier and TypeMethodDescription<A extends XmlAdapter>
AgetAdapter
(Class<A> type) Delegates to the wrapped unmarshaller.Delegates to the wrapped unmarshaller.Delegates to the wrapped unmarshaller.Delegates to the wrapped marshaller.Delegates to the wrapped unmarshaller.(package private) Object
getStandardProperty
(String name) Delegates to the wrapped unmarshaller.Delegates to the wrapped unmarshaller.boolean
Deprecated.protected void
Resets the given unmarshaller property to its initial state.<A extends XmlAdapter>
voidsetAdapter
(Class<A> type, A adapter) Delegates to the wrapped unmarshaller.void
Delegates to the wrapped unmarshaller.void
setEventHandler
(ValidationEventHandler handler) Delegates to the wrapped unmarshaller.void
setListener
(Unmarshaller.Listener listener) Delegates to the wrapped marshaller.void
Delegates to the wrapped unmarshaller.(package private) void
setStandardProperty
(String name, Object value) Delegates to the wrapped unmarshaller.void
setValidating
(boolean validating) Deprecated.Replaced bysetSchema(javax.xml.validation.Schema)
in JAXB 2.0.Delegates the unmarshalling to the wrapped unmarshaller.unmarshal
(InputStream input) Delegates the unmarshalling to the wrapped unmarshaller.Delegates the unmarshalling to the wrapped unmarshaller.Delegates the unmarshalling to the wrapped unmarshaller.unmarshal
(XMLEventReader input) Delegates the unmarshalling to the wrapped unmarshaller.<T> JAXBElement
<T> unmarshal
(XMLEventReader input, Class<T> declaredType) Delegates the unmarshalling to the wrapped unmarshaller.private Object
unmarshal
(XMLEventReader input, TransformVersion version) Unmarshals to the given input with on-the-fly substitution of namespaces.private <T> JAXBElement
<T> unmarshal
(XMLEventReader input, TransformVersion version, Class<T> declaredType) Same asunmarshal(XMLEventReader, TransformVersion)
, but delegating to the unmarshaller methods returning a JAXB element instead of the one returning the object.unmarshal
(XMLStreamReader input) Delegates the unmarshalling to the wrapped unmarshaller.<T> JAXBElement
<T> unmarshal
(XMLStreamReader input, Class<T> declaredType) Delegates the unmarshalling to the wrapped unmarshaller.Delegates the unmarshalling to the wrapped unmarshaller.<T> JAXBElement
<T> Delegates the unmarshalling to the wrapped unmarshaller.Delegates the unmarshalling to the wrapped unmarshaller.<T> JAXBElement
<T> Delegates the unmarshalling to the wrapped unmarshaller.unmarshal
(InputSource input) Delegates the unmarshalling to the wrapped unmarshaller.Methods inherited from class org.apache.sis.xml.Pooled
begin, getProperty, getRootAdapters, getTransformVersion, initialize, isPropertySaved, reset, saveProperty, setAdapter, setProperty, specificBitMasks
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.xml.bind.Unmarshaller
getProperty, setAdapter, setProperty
-
Field Details
-
unmarshaller
The wrapped marshaller which does the real work.
-
-
Constructor Details
-
PooledUnmarshaller
PooledUnmarshaller(Unmarshaller unmarshaller, Pooled template) throws JAXBException Creates a pooled unmarshaller wrapping the given one. Callers shall invokePooled.reset(Pooled)
after construction for completing the initialization.- Parameters:
unmarshaller
- the unmarshaller to use for the actual work.template
- thePooledTemplate
from which to get the initial values.- Throws:
JAXBException
- if an error occurred while setting a property.
-
-
Method Details
-
reset
Resets the given unmarshaller property to its initial state. This method is invoked automatically byPooled.reset(Pooled)
.- Specified by:
reset
in classPooled
- Parameters:
key
- the property to reset.value
- the saved initial value to give to the property.- Throws:
JAXBException
- if an error occurred while restoring a property.
-
unmarshal
private Object unmarshal(XMLEventReader input, TransformVersion version) throws XMLStreamException, JAXBException Unmarshals to the given input with on-the-fly substitution of namespaces. This method is invoked when we may marshal a different GML or metadata version than the one supported natively by SIS, i.e. whenPooled.getTransformVersion()
returns a non-null value.- Parameters:
input
- the reader created by SIS (not the reader given by the user).version
- identify the namespace substitutions to perform.- Returns:
- the unmarshalled object.
- Throws:
XMLStreamException
JAXBException
-
unmarshal
private <T> JAXBElement<T> unmarshal(XMLEventReader input, TransformVersion version, Class<T> declaredType) throws XMLStreamException, JAXBException Same asunmarshal(XMLEventReader, TransformVersion)
, but delegating to the unmarshaller methods returning a JAXB element instead of the one returning the object.- Throws:
XMLStreamException
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
public <T> JAXBElement<T> unmarshal(XMLStreamReader input, Class<T> declaredType) throws JAXBException Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
unmarshal
public <T> JAXBElement<T> unmarshal(XMLEventReader input, Class<T> declaredType) throws JAXBException Delegates the unmarshalling to the wrapped unmarshaller.- Specified by:
unmarshal
in interfaceUnmarshaller
- Throws:
JAXBException
-
getUnmarshallerHandler
Delegates to the wrapped unmarshaller.- Specified by:
getUnmarshallerHandler
in interfaceUnmarshaller
-
setStandardProperty
Delegates to the wrapped unmarshaller. This method is invoked by the parent class if the given name was not one of theXML
constants.- Specified by:
setStandardProperty
in classPooled
- Throws:
PropertyException
-
getStandardProperty
Delegates to the wrapped unmarshaller. This method is invoked by the parent class if the given name was not one of theXML
constants.- Specified by:
getStandardProperty
in classPooled
- Throws:
PropertyException
-
setAdapter
Delegates to the wrapped unmarshaller. The initial state will be saved if it was not already done, for future restoration byPooled.reset(Pooled)
.- Specified by:
setAdapter
in interfaceUnmarshaller
- Overrides:
setAdapter
in classPooled
-
getAdapter
Delegates to the wrapped unmarshaller.- Specified by:
getAdapter
in interfaceUnmarshaller
- Specified by:
getAdapter
in classPooled
-
setValidating
Deprecated.Replaced bysetSchema(javax.xml.validation.Schema)
in JAXB 2.0.Delegates to the wrapped unmarshaller. The initial state will be saved if it was not already done, for future restoration byPooled.reset(Pooled)
.- Specified by:
setValidating
in interfaceUnmarshaller
- Throws:
JAXBException
-
isValidating
Deprecated.Replaced bygetSchema()
in JAXB 2.0.Delegates to the wrapped unmarshaller.- Specified by:
isValidating
in interfaceUnmarshaller
- Throws:
JAXBException
-
setSchema
Delegates to the wrapped unmarshaller. The initial state will be saved if it was not already done, for future restoration byPooled.reset(Pooled)
.- Specified by:
setSchema
in interfaceUnmarshaller
- Overrides:
setSchema
in classPooled
-
getSchema
Delegates to the wrapped unmarshaller.- Specified by:
getSchema
in interfaceUnmarshaller
- Specified by:
getSchema
in classPooled
-
setEventHandler
Delegates to the wrapped unmarshaller. The initial state will be saved if it was not already done, for future restoration byPooled.reset(Pooled)
.- Specified by:
setEventHandler
in interfaceUnmarshaller
- Overrides:
setEventHandler
in classPooled
- Throws:
JAXBException
-
getEventHandler
Delegates to the wrapped unmarshaller.- Specified by:
getEventHandler
in interfaceUnmarshaller
- Specified by:
getEventHandler
in classPooled
- Throws:
JAXBException
-
setAttachmentUnmarshaller
Delegates to the wrapped unmarshaller. The initial state will be saved if it was not already done, for future restoration byPooled.reset(Pooled)
.- Specified by:
setAttachmentUnmarshaller
in interfaceUnmarshaller
-
getAttachmentUnmarshaller
Delegates to the wrapped unmarshaller.- Specified by:
getAttachmentUnmarshaller
in interfaceUnmarshaller
-
setListener
Delegates to the wrapped marshaller. The initial state will be saved if it was not already done, for future restoration byPooled.reset(Pooled)
.- Specified by:
setListener
in interfaceUnmarshaller
-
getListener
Delegates to the wrapped marshaller.- Specified by:
getListener
in interfaceUnmarshaller
-
getSchema()
in JAXB 2.0.