/** * 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. * * @param object the object to marshall. * @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, XMLStreamWriter output, final FilterVersion version) throws XMLStreamException, JAXBException { output = new FilteredStreamWriter(output, version); final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } output.close(); // Despite its name, this method does not close the underlying output stream. }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, XMLStreamWriter output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) { output = new FilteredStreamWriter(output, version); } final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public Node getNode(final Object object) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) { // This exception is thrown by javax.xml.bind.helpers.AbstractMarshallerImpl anyway. throw new UnsupportedOperationException(); } else { final Context context = begin(); try { return marshaller.getNode(toImplementation(object)); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public Node getNode(Object object) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) { // This exception is thrown by javax.xml.bind.helpers.AbstractMarshallerImpl anyway. throw new UnsupportedOperationException(); } else { final Context context = begin(); try { return marshaller.getNode(object); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, XMLEventWriter output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) { output = new TransformingWriter(output, version); } final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, final File output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) try { try (OutputStream s = new BufferedOutputStream(new FileOutputStream(output))) { marshal(object, OutputFactory.createXMLEventWriter(s, getEncoding()), version); } } catch (IOException | XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, final File output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) try { try (OutputStream s = new BufferedOutputStream(new FileOutputStream(output))) { marshal(object, OutputFactory.createXMLStreamWriter(s, getEncoding()), version); } } catch (IOException | XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, final Writer output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLStreamWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, final Node output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLStreamWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, final Result output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLEventWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, final XMLStreamWriter output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLEventWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, final ContentHandler output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLEventWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, final Node output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLEventWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, final Result output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLStreamWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, final ContentHandler output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLStreamWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, final XMLEventWriter output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLStreamWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, final Writer output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLEventWriter(output), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(final Object object, final OutputStream output) throws JAXBException { final FilterVersion version = getFilterVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLStreamWriter(output, getEncoding()), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(toImplementation(object), output); } finally { context.finish(); } } }
/** * Delegates the marshalling to the wrapped marshaller. */ @Override public void marshal(Object object, final OutputStream output) throws JAXBException { object = toImplementation(object); // Must be call before getTransformVersion() final TransformVersion version = getTransformVersion(); if (version != null) try { marshal(object, OutputFactory.createXMLEventWriter(output, getEncoding()), version); } catch (XMLStreamException e) { throw new JAXBException(e); } else { // Marshalling to the default GML version. final Context context = begin(); try { marshaller.marshal(object, output); } finally { context.finish(); } } }