Package eu.europa.esig.dss.jaxb.common
Class AbstractJaxbFacade<T>
java.lang.Object
eu.europa.esig.dss.jaxb.common.AbstractJaxbFacade<T>
- Type Parameters:
T
- A JAXB Object
- Direct Known Subclasses:
DetailedReportFacade
,DiagnosticDataFacade
,SimpleCertificateReportFacade
,SimpleReportFacade
,TrustedListFacade
,ValidationPolicyFacade
,ValidationReportFacade
Generic JAXB Facade which contains basic marshalling/unmarshalling
operations.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract JAXBContext
This method returns the instance ofJAXBContext
which can handle the JAXB ObjectgetMarshaller
(boolean validate) Returns the Marshallerprotected abstract Schema
This method returns an instance ofSchema
with the loaded XML Schema(s).getUnmarshaller
(boolean validate) Returns the UnmarshallerThis method returns the String representation of the jaxbObject.This method returns the String representation of the jaxbObject with an optional validation.void
marshall
(T jaxbObject, OutputStream os) This method marshalls the jaxbObject into theOutputStream
.void
marshall
(T jaxbObject, OutputStream os, boolean validate) This method marshalls the jaxbObject into theOutputStream
with an optional validation.unmarshall
(File file) This method unmarshalls theFile
and returns an instance of the JAXB Object.unmarshall
(File file, boolean validate) This method unmarshalls theFile
and returns an instance of the JAXB Object with an optional validation.This method unmarshalls theInputStream
and returns an instance of the JAXB Object.unmarshall
(InputStream is, boolean validate) This method unmarshalls theInputStream
and returns an instance of the JAXB Object with an optional validation.unmarshall
(String xmlObject) This method unmarshalls theString
and returns an instance of the JAXB Object.unmarshall
(String xmlObject, boolean validate) This method unmarshalls theString
and returns an instance of the JAXB Object with an optional validation.protected abstract JAXBElement<T>
This method wraps/envelops the JAXB object with a "root" element
-
Constructor Details
-
AbstractJaxbFacade
protected AbstractJaxbFacade()Default constructor
-
-
Method Details
-
getJAXBContext
This method returns the instance ofJAXBContext
which can handle the JAXB Object- Returns:
- an instance of
JAXBContext
- Throws:
JAXBException
- if an error occurred in the initialization process
-
getSchema
This method returns an instance ofSchema
with the loaded XML Schema(s). The XSD(s) allows to validate the JAXB Object.- Returns:
- an instance of
Schema
- Throws:
IOException
- if an I/O error occurred in the initialization processSAXException
- if a SAX error occurred in the initialization process
-
wrap
This method wraps/envelops the JAXB object with a "root" element- Parameters:
jaxbObject
- the JAXB object to be enveloped to marshall- Returns:
- the enveloped JAXB object, ready to be marshalled
-
marshall
This method returns the String representation of the jaxbObject. The validation of the jaxbObject against its related XSD is enabled.- Parameters:
jaxbObject
- the jaxb object to be marshalled- Returns:
- the result of the marshalling for the given jaxbObject
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
IOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
marshall
public String marshall(T jaxbObject, boolean validate) throws JAXBException, IOException, SAXException This method returns the String representation of the jaxbObject with an optional validation.- Parameters:
jaxbObject
- the jaxb object to be marshalledvalidate
- enable/disable the validation against the related XSD- Returns:
- the result of the marshalling for the given jaxbObject
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
IOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
marshall
This method marshalls the jaxbObject into theOutputStream
. The validation of the jaxbObject against its related XSD is enabled.- Parameters:
jaxbObject
- the jaxb object to be marshalledos
- theOutputStream
where the object will be marshalled.- Throws:
JAXBException
- if an exception occurred with theJAXBContext
IOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
marshall
public void marshall(T jaxbObject, OutputStream os, boolean validate) throws JAXBException, SAXException, IOException This method marshalls the jaxbObject into theOutputStream
with an optional validation.- Parameters:
jaxbObject
- the jaxb object to be marshalledos
- theOutputStream
where the object will be marshalledvalidate
- enable/disable the validation against the related XSD- Throws:
JAXBException
- if an exception occurred with theJAXBContext
IOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
unmarshall
public T unmarshall(InputStream is) throws JAXBException, XMLStreamException, IOException, SAXException This method unmarshalls theInputStream
and returns an instance of the JAXB Object. The validation of theInputStream
against its related XSD is enabled.- Parameters:
is
- theInputStream
which contains a XML representation of JAXB Object.- Returns:
- an instance of the JAXB Object
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
XMLStreamException
- if an exception occurred with the sourceIOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
unmarshall
public T unmarshall(InputStream is, boolean validate) throws JAXBException, XMLStreamException, IOException, SAXException This method unmarshalls theInputStream
and returns an instance of the JAXB Object with an optional validation.- Parameters:
is
- theInputStream
which contains a XML representation of JAXB Object.validate
- enable/disable the validation against the related XSD- Returns:
- an instance of JAXB Object
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
XMLStreamException
- if an exception occurred with the sourceIOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
unmarshall
This method unmarshalls theFile
and returns an instance of the JAXB Object. The validation of theFile
against its related XSD is enabled.- Parameters:
file
- theFile
which contains a XML representation of JAXB Object.- Returns:
- an instance of JAXB Object
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
XMLStreamException
- if an exception occurred with the sourceIOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
unmarshall
public T unmarshall(File file, boolean validate) throws JAXBException, XMLStreamException, IOException, SAXException This method unmarshalls theFile
and returns an instance of the JAXB Object with an optional validation.- Parameters:
file
- theFile
which contains a XML representation of JAXB Object.validate
- enable/disable the validation against the related XSD- Returns:
- an instance of JAXB Object
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
XMLStreamException
- if an exception occurred with the sourceIOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
unmarshall
public T unmarshall(String xmlObject) throws JAXBException, XMLStreamException, IOException, SAXException This method unmarshalls theString
and returns an instance of the JAXB Object. The validation of theString
against its related XSD is enabled.- Parameters:
xmlObject
- theString
which contains a XML representation of JAXB Object.- Returns:
- an instance of JAXB Object
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
XMLStreamException
- if an exception occurred with the sourceIOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
unmarshall
public T unmarshall(String xmlObject, boolean validate) throws JAXBException, XMLStreamException, IOException, SAXException This method unmarshalls theString
and returns an instance of the JAXB Object with an optional validation.- Parameters:
xmlObject
- theString
which contains a XML representation of JAXB Object.validate
- enable/disable the validation against the related XSD- Returns:
- an instance of JAXB Object
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
XMLStreamException
- if an exception occurred with the sourceIOException
- if an exception occurred with the I/O.SAXException
- if an exception occurred with theSchema
-
getMarshaller
Returns the Marshaller- Parameters:
validate
- defines if the schema should be validated- Returns:
Marshaller
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
SAXException
- if an exception occurred with theSchema
IOException
- if an exception occurred with the I/O.
-
getUnmarshaller
public Unmarshaller getUnmarshaller(boolean validate) throws JAXBException, IOException, SAXException Returns the Unmarshaller- Parameters:
validate
- defines if the schema should be validated- Returns:
Unmarshaller
- Throws:
JAXBException
- if an exception occurred with theJAXBContext
SAXException
- if an exception occurred with theSchema
IOException
- if an exception occurred with the I/O.
-