use of org.apache.sis.internal.jaxb.Context in project sis by apache.
the class PooledMarshaller method marshal.
/**
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
public void marshal(Object object, final Node output) throws JAXBException {
// Must be call before getTransformVersion()
object = toImplementation(object);
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();
}
}
}
use of org.apache.sis.internal.jaxb.Context in project sis by apache.
the class PooledMarshaller method marshal.
/**
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
public void marshal(Object object, final File output) throws JAXBException {
// Must be call before getTransformVersion()
object = toImplementation(object);
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();
}
}
}
use of org.apache.sis.internal.jaxb.Context in project sis by apache.
the class PooledMarshaller method getNode.
/**
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
public Node getNode(Object object) throws JAXBException {
// Must be call before getTransformVersion()
object = toImplementation(object);
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();
}
}
}
use of org.apache.sis.internal.jaxb.Context in project sis by apache.
the class PooledMarshaller method marshal.
/**
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
public void marshal(Object object, XMLEventWriter output) throws JAXBException {
// Must be call before getTransformVersion()
object = toImplementation(object);
final TransformVersion version = getTransformVersion();
if (version != null) {
output = new TransformingWriter(output, version);
}
final Context context = begin();
try {
marshaller.marshal(object, output);
} finally {
context.finish();
}
}
use of org.apache.sis.internal.jaxb.Context in project sis by apache.
the class PooledMarshaller method marshal.
/**
* Delegates the marshalling to the wrapped marshaller.
*/
@Override
public void marshal(Object object, final ContentHandler output) throws JAXBException {
// Must be call before getTransformVersion()
object = toImplementation(object);
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();
}
}
}
Aggregations