类 JaxbMapper

java.lang.Object
com.jeeplus.devtools.util.JaxbMapper

public class JaxbMapper extends Object
使用Jaxb2.0实现XML<->Java Object的Mapper.

在创建时需要设定所有需要序列化的Root对象的Class. 特别支持Root对象是Collection的情形.

版本:
2021-01-15
作者:
calvin
  • 构造器详细资料

    • JaxbMapper

      public JaxbMapper()
  • 方法详细资料

    • toXml

      public static String toXml(Object root)
      Java Object->Xml without encoding.
    • toXml

      public static String toXml(Object root, String encoding)
      Java Object->Xml with encoding.
    • toXml

      public static String toXml(Object root, Class clazz, String encoding)
      Java Object->Xml with encoding.
    • toXml

      public static String toXml(Collection<?> root, String rootName, Class clazz)
      Java Collection->Xml without encoding, 特别支持Root Element是Collection的情形.
    • toXml

      public static String toXml(Collection<?> root, String rootName, Class clazz, String encoding)
      Java Collection->Xml with encoding, 特别支持Root Element是Collection的情形.
    • fromXml

      public static <T> T fromXml(String xml, Class<T> clazz)
      Xml->Java Object.
    • createMarshaller

      public static jakarta.xml.bind.Marshaller createMarshaller(Class clazz, String encoding)
      创建Marshaller并设定encoding(可为null). 线程不安全,需要每次创建或pooling。
    • createUnmarshaller

      public static jakarta.xml.bind.Unmarshaller createUnmarshaller(Class clazz)
      创建UnMarshaller. 线程不安全,需要每次创建或pooling。
    • getJaxbContext

      protected static jakarta.xml.bind.JAXBContext getJaxbContext(Class clazz)