Class DomDTOParser


  • public class DomDTOParser
    extends java.lang.Object
    Parse an XML file based on a DTO as schema
    • Constructor Summary

      Constructors 
      Constructor Description
      DomDTOParser()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T parse​(java.lang.Class<T> type, java.io.File doc)
      parse the given XML file based on the type as the schema.
      static <T> T parse​(java.lang.Class<T> type, java.io.InputStream doc)
      parse the given XML file based on the type as the schema.
      • Methods inherited from class java.lang.Object

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

      • DomDTOParser

        public DomDTOParser()
    • Method Detail

      • parse

        public static <T> T parse​(java.lang.Class<T> type,
                                  java.io.File doc)
                           throws java.lang.Exception
        parse the given XML file based on the type as the schema. Attributes and elements are mapped to fields in an object of this type. If the field is a collection or a DTO type, the parse will be recursive.
        Parameters:
        type - the type acting as scheme
        doc - the file
        Returns:
        a DTO of type
        Throws:
        java.lang.Exception
      • parse

        public static <T> T parse​(java.lang.Class<T> type,
                                  java.io.InputStream doc)
                           throws java.lang.Exception
        parse the given XML file based on the type as the schema. Attributes and elements are mapped to fields in an object of this type. If the field is a collection or a DTO type, the parse will be recursive.
        Parameters:
        type - the type acting as scheme
        doc - the file
        Returns:
        a DTO of type
        Throws:
        java.lang.Exception