Class AbstractJaxbFacade<T>

java.lang.Object
eu.europa.esig.dss.jaxb.common.AbstractJaxbFacade<T>
Type Parameters:
T - A JAXB Object
Direct Known Subclasses:
CryptographicSuiteXmlFacade, DetailedReportFacade, DiagnosticDataFacade, PKIJaxbFacade, SimpleCertificateReportFacade, SimpleReportFacade, TrustedListFacade, ValidationPolicyFacade, ValidationReportFacade, XMLEvidenceRecordFacade

public abstract class AbstractJaxbFacade<T> extends Object
Generic JAXB Facade which contains basic marshalling/unmarshalling operations.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract jakarta.xml.bind.JAXBContext
    This method returns the instance of JAXBContext which can handle the JAXB Object
    jakarta.xml.bind.Marshaller
    getMarshaller(boolean validate)
    Returns the Marshaller
    protected abstract Schema
    This method returns an instance of Schema with the loaded XML Schema(s).
    jakarta.xml.bind.Unmarshaller
    getUnmarshaller(boolean validate)
    Returns the Unmarshaller
    marshall(T jaxbObject)
    This method returns the String representation of the jaxbObject.
    marshall(T jaxbObject, boolean validate)
    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 the OutputStream.
    void
    marshall(T jaxbObject, OutputStream os, boolean validate)
    This method marshalls the jaxbObject into the OutputStream with an optional validation.
    This method unmarshalls the File and returns an instance of the JAXB Object.
    unmarshall(File file, boolean validate)
    This method unmarshalls the File and returns an instance of the JAXB Object with an optional validation.
    This method unmarshalls the InputStream and returns an instance of the JAXB Object.
    unmarshall(InputStream is, boolean validate)
    This method unmarshalls the InputStream and returns an instance of the JAXB Object with an optional validation.
    unmarshall(String xmlObject)
    This method unmarshalls the String and returns an instance of the JAXB Object.
    unmarshall(String xmlObject, boolean validate)
    This method unmarshalls the String and returns an instance of the JAXB Object with an optional validation.
    protected abstract jakarta.xml.bind.JAXBElement<T>
    wrap(T jaxbObject)
    This method wraps/envelops the JAXB object with a "root" element

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractJaxbFacade

      protected AbstractJaxbFacade()
      Default constructor
  • Method Details

    • getJAXBContext

      protected abstract jakarta.xml.bind.JAXBContext getJAXBContext() throws jakarta.xml.bind.JAXBException
      This method returns the instance of JAXBContext which can handle the JAXB Object
      Returns:
      an instance of JAXBContext
      Throws:
      jakarta.xml.bind.JAXBException - if an error occurred in the initialization process
    • getSchema

      protected abstract Schema getSchema() throws IOException, SAXException
      This method returns an instance of Schema 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 process
      SAXException - if a SAX error occurred in the initialization process
    • wrap

      protected abstract jakarta.xml.bind.JAXBElement<T> wrap(T jaxbObject)
      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

      public String marshall(T jaxbObject) throws jakarta.xml.bind.JAXBException, IOException, SAXException
      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:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • marshall

      public String marshall(T jaxbObject, boolean validate) throws jakarta.xml.bind.JAXBException, IOException, SAXException
      This method returns the String representation of the jaxbObject with an optional validation.
      Parameters:
      jaxbObject - the jaxb object to be marshalled
      validate - enable/disable the validation against the related XSD
      Returns:
      the result of the marshalling for the given jaxbObject
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • marshall

      public void marshall(T jaxbObject, OutputStream os) throws jakarta.xml.bind.JAXBException, SAXException, IOException
      This method marshalls the jaxbObject into the OutputStream. The validation of the jaxbObject against its related XSD is enabled.
      Parameters:
      jaxbObject - the jaxb object to be marshalled
      os - the OutputStream where the object will be marshalled.
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • marshall

      public void marshall(T jaxbObject, OutputStream os, boolean validate) throws jakarta.xml.bind.JAXBException, SAXException, IOException
      This method marshalls the jaxbObject into the OutputStream with an optional validation.
      Parameters:
      jaxbObject - the jaxb object to be marshalled
      os - the OutputStream where the object will be marshalled
      validate - enable/disable the validation against the related XSD
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • unmarshall

      public T unmarshall(InputStream is) throws jakarta.xml.bind.JAXBException, XMLStreamException, IOException, SAXException
      This method unmarshalls the InputStream and returns an instance of the JAXB Object. The validation of the InputStream against its related XSD is enabled.
      Parameters:
      is - the InputStream which contains a XML representation of JAXB Object.
      Returns:
      an instance of the JAXB Object
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      XMLStreamException - if an exception occurred with the source
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • unmarshall

      public T unmarshall(InputStream is, boolean validate) throws jakarta.xml.bind.JAXBException, XMLStreamException, IOException, SAXException
      This method unmarshalls the InputStream and returns an instance of the JAXB Object with an optional validation.
      Parameters:
      is - the InputStream which contains a XML representation of JAXB Object.
      validate - enable/disable the validation against the related XSD
      Returns:
      an instance of JAXB Object
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      XMLStreamException - if an exception occurred with the source
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • unmarshall

      public T unmarshall(File file) throws jakarta.xml.bind.JAXBException, XMLStreamException, IOException, SAXException
      This method unmarshalls the File and returns an instance of the JAXB Object. The validation of the File against its related XSD is enabled.
      Parameters:
      file - the File which contains a XML representation of JAXB Object.
      Returns:
      an instance of JAXB Object
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      XMLStreamException - if an exception occurred with the source
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • unmarshall

      public T unmarshall(File file, boolean validate) throws jakarta.xml.bind.JAXBException, XMLStreamException, IOException, SAXException
      This method unmarshalls the File and returns an instance of the JAXB Object with an optional validation.
      Parameters:
      file - the File which contains a XML representation of JAXB Object.
      validate - enable/disable the validation against the related XSD
      Returns:
      an instance of JAXB Object
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      XMLStreamException - if an exception occurred with the source
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • unmarshall

      public T unmarshall(String xmlObject) throws jakarta.xml.bind.JAXBException, XMLStreamException, IOException, SAXException
      This method unmarshalls the String and returns an instance of the JAXB Object. The validation of the String against its related XSD is enabled.
      Parameters:
      xmlObject - the String which contains a XML representation of JAXB Object.
      Returns:
      an instance of JAXB Object
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      XMLStreamException - if an exception occurred with the source
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • unmarshall

      public T unmarshall(String xmlObject, boolean validate) throws jakarta.xml.bind.JAXBException, XMLStreamException, IOException, SAXException
      This method unmarshalls the String and returns an instance of the JAXB Object with an optional validation.
      Parameters:
      xmlObject - the String which contains a XML representation of JAXB Object.
      validate - enable/disable the validation against the related XSD
      Returns:
      an instance of JAXB Object
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      XMLStreamException - if an exception occurred with the source
      IOException - if an exception occurred with the I/O.
      SAXException - if an exception occurred with the Schema
    • getMarshaller

      public jakarta.xml.bind.Marshaller getMarshaller(boolean validate) throws jakarta.xml.bind.JAXBException, SAXException, IOException
      Returns the Marshaller
      Parameters:
      validate - defines if the schema should be validated
      Returns:
      Marshaller
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      SAXException - if an exception occurred with the Schema
      IOException - if an exception occurred with the I/O.
    • getUnmarshaller

      public jakarta.xml.bind.Unmarshaller getUnmarshaller(boolean validate) throws jakarta.xml.bind.JAXBException, IOException, SAXException
      Returns the Unmarshaller
      Parameters:
      validate - defines if the schema should be validated
      Returns:
      Unmarshaller
      Throws:
      jakarta.xml.bind.JAXBException - if an exception occurred with the JAXBContext
      SAXException - if an exception occurred with the Schema
      IOException - if an exception occurred with the I/O.