Package org.apache.sis.xml
Class PooledMarshaller
java.lang.Object
org.apache.sis.xml.Pooled
org.apache.sis.xml.PooledMarshaller
- All Implemented Interfaces:
Marshaller
Wraps a
Marshaller 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 marshaller is recycled.
- Constructs a SIS
Contextobject on marshalling, in order to give additional information to the SIS object being marshalled. - Wraps the output stream in a
TransformingWriterif the desired 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.Marshaller
Marshaller.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final MarshallerThe wrapper marshaller which does the real work.private intBit masks specific to the object being marshalled.Fields inherited from class org.apache.sis.xml.Pooled
initialProperties, resetTimeFields inherited from interface javax.xml.bind.Marshaller
JAXB_ENCODING, JAXB_FORMATTED_OUTPUT, JAXB_FRAGMENT, JAXB_NO_NAMESPACE_SCHEMA_LOCATION, JAXB_SCHEMA_LOCATION -
Constructor Summary
ConstructorsConstructorDescriptionPooledMarshaller(Marshaller marshaller, Pooled template) Creates a pooled marshaller wrapping the given one. -
Method Summary
Modifier and TypeMethodDescription<A extends XmlAdapter>
AgetAdapter(Class<A> type) Delegates to the wrapped marshaller.Delegates to the wrapped marshaller.private StringReturns the encoding of the XML document to write.Delegates to the wrapped marshaller.Delegates to the wrapped marshaller.Delegates the marshalling to the wrapped marshaller.Delegates to the wrapped marshaller.(package private) ObjectgetStandardProperty(String name) Delegates to the wrapped marshaller.voidDelegates the marshalling to the wrapped marshaller.voidmarshal(Object object, OutputStream output) Delegates the marshalling to the wrapped marshaller.voidDelegates the marshalling to the wrapped marshaller.voidmarshal(Object object, XMLEventWriter output) Delegates the marshalling to the wrapped marshaller.private voidmarshal(Object object, XMLEventWriter output, TransformVersion version) Marshals to the given output with on-the-fly substitution of namespaces.voidmarshal(Object object, XMLStreamWriter output) Delegates the marshalling to the wrapped marshaller.voidDelegates the marshalling to the wrapped marshaller.voidDelegates the marshalling to the wrapped marshaller.voidmarshal(Object object, ContentHandler output) Delegates the marshalling to the wrapped marshaller.protected voidResets the given marshaller property to its initial state.<A extends XmlAdapter>
voidsetAdapter(Class<A> type, A adapter) Delegates to the wrapped marshaller.voidDelegates to the wrapped marshaller.voidsetEventHandler(ValidationEventHandler handler) Delegates to the wrapped marshaller.voidsetListener(Marshaller.Listener listener) Delegates to the wrapped marshaller.voidDelegates to the wrapped marshaller.(package private) voidsetStandardProperty(String name, Object value) Delegates to the wrapped marshaller.(package private) final intReturns a non-zero bitmask if the object given in last call totoImplementation(Object)should use legacy metadata.private ObjecttoImplementation(Object value) Converts the given arbitrary object to an implementation having JAXB annotations.Methods inherited from class org.apache.sis.xml.Pooled
begin, getProperty, getRootAdapters, getTransformVersion, initialize, isPropertySaved, reset, saveProperty, setAdapter, setPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.xml.bind.Marshaller
getProperty, setAdapter, setProperty
-
Field Details
-
marshaller
The wrapper marshaller which does the real work. -
specificBitMasks
private int specificBitMasksBit masks specific to the object being marshalled. This mask will be combined with the bit masks managed by thePooledbase class. This is used mostly for mandating legacy metadata format (ISO 19139:2007) for some object to marshal.
-
-
Constructor Details
-
PooledMarshaller
PooledMarshaller(Marshaller marshaller, Pooled template) throws JAXBException Creates a pooled marshaller wrapping the given one. Callers shall invokePooled.reset(Pooled)after construction for completing the initialization.- Parameters:
marshaller- the marshaller to use for the actual work.template- thePooledTemplatefrom which to get the initial values.- Throws:
JAXBException- if an error occurred while setting a property.
-
-
Method Details
-
reset
Resets the given marshaller property to its initial state. This method is invoked automatically byPooled.reset(Pooled).- Specified by:
resetin 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.
-
getEncoding
Returns the encoding of the XML document to write.- Throws:
PropertyException
-
specificBitMasks
final int specificBitMasks()Returns a non-zero bitmask if the object given in last call totoImplementation(Object)should use legacy metadata. This is a hack for marshalling metadata in GML. May be deleted if we implement SIS-401.- Overrides:
specificBitMasksin classPooled- See Also:
-
toImplementation
Converts the given arbitrary object to an implementation having JAXB annotations. If the given object is not recognized or is already an instance of the expected class, then it is returned unchanged. -
marshal
private void marshal(Object object, XMLEventWriter output, TransformVersion version) throws XMLStreamException, JAXBException Marshals to the given output with on-the-fly substitution of namespaces. 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. whenPooled.getTransformVersion()returns a non-null value.- Parameters:
object- the object to marshal.output- the writer created by SIS (not the writer given by the user).version- identifies the namespace substitutions to perform.- Throws:
XMLStreamExceptionJAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
marshal
Delegates the marshalling to the wrapped marshaller.- Specified by:
marshalin interfaceMarshaller- Throws:
JAXBException
-
getNode
Delegates the marshalling to the wrapped marshaller.- Specified by:
getNodein interfaceMarshaller- Throws:
JAXBException
-
setStandardProperty
Delegates to the wrapped marshaller. This method is invoked by the parent class if the given name was not one of theXMLconstants.- Specified by:
setStandardPropertyin classPooled- Throws:
PropertyException
-
getStandardProperty
Delegates to the wrapped marshaller. This method is invoked by the parent class if the given name was not one of theXMLconstants.- Specified by:
getStandardPropertyin classPooled- Throws:
PropertyException
-
setAdapter
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:
setAdapterin interfaceMarshaller- Overrides:
setAdapterin classPooled
-
getAdapter
Delegates to the wrapped marshaller.- Specified by:
getAdapterin interfaceMarshaller- Specified by:
getAdapterin classPooled
-
setSchema
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:
setSchemain interfaceMarshaller- Overrides:
setSchemain classPooled
-
getSchema
Delegates to the wrapped marshaller.- Specified by:
getSchemain interfaceMarshaller- Specified by:
getSchemain classPooled
-
setEventHandler
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:
setEventHandlerin interfaceMarshaller- Overrides:
setEventHandlerin classPooled- Throws:
JAXBException
-
getEventHandler
Delegates to the wrapped marshaller.- Specified by:
getEventHandlerin interfaceMarshaller- Specified by:
getEventHandlerin classPooled- Throws:
JAXBException
-
setAttachmentMarshaller
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:
setAttachmentMarshallerin interfaceMarshaller
-
getAttachmentMarshaller
Delegates to the wrapped marshaller.- Specified by:
getAttachmentMarshallerin interfaceMarshaller
-
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:
setListenerin interfaceMarshaller
-
getListener
Delegates to the wrapped marshaller.- Specified by:
getListenerin interfaceMarshaller
-