Class MarshallerFactory

java.lang.Object
io.github.astrapi69.jaxb.factory.MarshallerFactory

public class MarshallerFactory extends Object
The factory class MarshallerFactory for creating Marshaller objects for serializing java beans to xml string
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static jakarta.xml.bind.Marshaller
    addProperties(@NonNull jakarta.xml.bind.Marshaller marshaller, Map<String,Object> marshallerProperties)
    Add the given marshaller properties to the given Marshaller object
    static jakarta.xml.bind.Marshaller
    newMarshaller(@NonNull Class clazz)
    Factory method for create a new Marshaller object
    static jakarta.xml.bind.Marshaller
    newMarshaller(jakarta.xml.bind.JAXBContext context, @NonNull Class clazz)
    Factory method for create a new Marshaller object
    static jakarta.xml.bind.Marshaller
    newMarshaller(jakarta.xml.bind.JAXBContext context, @NonNull Class clazz, Map<String,Object> marshallerProperties)
    Factory method for create a new Marshaller object
    static <T> jakarta.xml.bind.Marshaller
    newMarshaller(T object)
    Factory method for create a new Marshaller object
    static <T> jakarta.xml.bind.Marshaller
    Factory method for create a new Marshaller object that can make a pretty print of the xml output

    Methods inherited from class java.lang.Object

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

    • MarshallerFactory

      public MarshallerFactory()
  • Method Details

    • newMarshaller

      public static jakarta.xml.bind.Marshaller newMarshaller(@NonNull @NonNull Class clazz) throws jakarta.xml.bind.JAXBException
      Factory method for create a new Marshaller object
      Parameters:
      clazz - the Class object
      Returns:
      the new created Marshaller object
      Throws:
      jakarta.xml.bind.JAXBException - is thrown if an error was encountered while creating the JAXBContext
    • newMarshaller

      public static jakarta.xml.bind.Marshaller newMarshaller(jakarta.xml.bind.JAXBContext context, @NonNull @NonNull Class clazz) throws jakarta.xml.bind.JAXBException
      Factory method for create a new Marshaller object
      Parameters:
      context - the JAXBContext object
      clazz - the Class object
      Returns:
      the new created Marshaller object
      Throws:
      jakarta.xml.bind.JAXBException - is thrown if an error was encountered while creating the JAXBContext
    • newMarshaller

      public static <T> jakarta.xml.bind.Marshaller newMarshaller(@NonNull T object) throws jakarta.xml.bind.JAXBException
      Factory method for create a new Marshaller object
      Type Parameters:
      T - the generic type of the given object
      Parameters:
      object - the generic object
      Returns:
      the new created Marshaller object
      Throws:
      jakarta.xml.bind.JAXBException - is thrown if an error was encountered while creating the JAXBContext
    • newPrettyPrintMarshaller

      public static <T> jakarta.xml.bind.Marshaller newPrettyPrintMarshaller(@NonNull T object)
      Factory method for create a new Marshaller object that can make a pretty print of the xml output
      Type Parameters:
      T - the generic type of the given object
      Parameters:
      object - the generic object
      Returns:
      the new created Marshaller object
    • newMarshaller

      public static jakarta.xml.bind.Marshaller newMarshaller(jakarta.xml.bind.JAXBContext context, @NonNull @NonNull Class clazz, Map<String,Object> marshallerProperties) throws jakarta.xml.bind.JAXBException
      Factory method for create a new Marshaller object
      Parameters:
      context - the JAXBContext object
      clazz - the Class object
      marshallerProperties - the Map object with the marshaller properties
      Returns:
      the new created Marshaller object
      Throws:
      jakarta.xml.bind.JAXBException - is thrown if an error was encountered while creating the JAXBContext
    • addProperties

      public static jakarta.xml.bind.Marshaller addProperties(@NonNull @NonNull jakarta.xml.bind.Marshaller marshaller, Map<String,Object> marshallerProperties) throws jakarta.xml.bind.PropertyException
      Add the given marshaller properties to the given Marshaller object
      Parameters:
      marshaller - the Marshaller object
      marshallerProperties - the Map object with the marshaller properties
      Returns:
      the new Marshaller object with the given marshaller properties
      Throws:
      jakarta.xml.bind.PropertyException - is thrown if there is an error processing the given property or value