Class DomDTOParser

java.lang.Object
aQute.lib.xmldtoparser.DomDTOParser

public class DomDTOParser extends Object
Parse an XML file based on a DTO as schema
  • Field Details

  • Constructor Details

    • DomDTOParser

      public DomDTOParser()
  • Method Details

    • parse

      public static <T> T parse(Class<T> type, File doc) throws 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:
      Exception
    • parse

      public static <T> T parse(Class<T> type, InputStream doc) throws 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:
      Exception
    • parse

      private static <T> T parse(Class<T> type, Node node) throws Exception
      Throws:
      Exception
    • get

      private static <T> void get(T instance, Node node) throws Exception
      Throws:
      Exception
    • getName

      private static String getName(Field field)
    • toSimpleName

      private static String toSimpleName(String nodeName)
    • isSimple

      private static boolean isSimple(Class<?> class1)
    • isCollection

      private static boolean isCollection(Class<?> class1)
    • findField

      private static Field findField(Class<? extends Object> class1, String name) throws Exception
      Throws:
      Exception
    • setField

      private static void setField(Field f, Object targetObject, Object value) throws Exception
      Throws:
      Exception
    • getField

      private static <T> T getField(Field f, Object targetObject) throws Exception
      Throws:
      Exception
    • isStatic

      private static boolean isStatic(Member m)