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 Writer 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 XMLStreamWriter 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 Result 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 PooledUnmarshaller method unmarshal.
/**
* 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. 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 TransformVersion version) throws XMLStreamException, JAXBException {
input = new TransformingReader(input, version);
final Context context = begin();
final Object object;
try {
object = unmarshaller.unmarshal(input);
} finally {
context.finish();
}
// Despite its name, this method does not close the underlying input stream.
input.close();
return object;
}
use of org.apache.sis.internal.jaxb.Context in project sis by apache.
the class PooledUnmarshaller method unmarshal.
/**
* Delegates the unmarshalling to the wrapped unmarshaller.
*/
@Override
public <T> JAXBElement<T> unmarshal(XMLEventReader input, final Class<T> declaredType) throws JAXBException {
final TransformVersion version = getTransformVersion();
if (version != null) {
input = new TransformingReader(input, version);
}
final Context context = begin();
try {
return unmarshaller.unmarshal(input, declaredType);
} finally {
context.finish();
}
}
Aggregations