Class DocParser

java.lang.Object
org.ampere.base.xml.DocParser

public class DocParser extends Object
utilities for parsing XML document
Author:
herve
  • Method Details

    • getSingleton

      public static DocParser getSingleton()
    • getNodeType

      public static String getNodeType(Node noeud)
    • getElement

      public static Element getElement(Element element, int index, String tag)
      return the element number 'index' having tag 'tag'
    • getUniqueElement

      public static Element getUniqueElement(Element element, String tag)
      return the first element having tag 'tag'
    • getNamedItem

      public static Node getNamedItem(Node noeud, String nom)
      return the node associated to the element named 'nom' belonging to Node
    • readStringAttribute

      public static String readStringAttribute(Node noeud, String nom)
      return the string value associated to the attribute named 'nom' of the element 'noeud'.
    • buildNodePath

      public static String buildNodePath(Node node)
    • getStringAttribute

      public static String getStringAttribute(Node node, String name, boolean certified)
      Get a string attribute
      Parameters:
      node - associated XML node
      name - attribute name
      certified - flag specifying that the attribute is required or not. If true, an exception occurs if the attribute is not defined
      Returns:
      the string value associated to the attribute
    • readDoubleAttribute

      public static Double readDoubleAttribute(Node noeud, String nom)
      return the Double value associated to the attribute named 'nom' of the element 'noeud'.
    • getDoubleAttribute

      public static Double getDoubleAttribute(Node noeud, String nom) throws PXDexception
      return the Double value associated to the attribute named 'nom' of the element 'noeud'.
      Throws:
      PXDexception
    • readIntegerAttribute

      public static Integer readIntegerAttribute(Node noeud, String nom)
      return the Integer value associated to the attribute named 'nom' of the element 'noeud'.
    • getIntegerAttribute

      public static Integer getIntegerAttribute(Node noeud, String nom) throws PXDexception
      return the Integer value associated to the attribute named 'nom' of the element 'noeud'.
      Throws:
      PXDexception
    • readBooleanAttribute

      public static Boolean readBooleanAttribute(Node node, String valueName)
      Read a boolean attribute
      Parameters:
      node -
      valueName - targeted value name
      Returns:
      the Boolean value associated to the attribute
    • getBooleanAttribute

      public static Boolean getBooleanAttribute(Node node, String valueName, boolean certified) throws PXDexception
      get the boolean attribute associated to given attribute name
      Parameters:
      node - associated node
      valueName - name of the attribute
      Returns:
      the Boolean value associated to the attribute
      Throws:
      PXDexception - if the string value do not fit the Boolean Format
    • printNodes

      public static void printNodes(PrintStream out, Element node)
      print the list of nodes of an element
    • getChildByTag

      public static ArrayList<Element> getChildByTag(Element parent, String tagName)
    • getFirstElement

      public static Element getFirstElement(Node parent, String tagName)
      Get the first matching element
      Parameters:
      parent - node parent
      tagName - if not null, tag name of the searched element.
      Returns:
      the found element or null.
    • getNextSiblingElement

      public static Element getNextSiblingElement(Node node, String tagName)
      Get the next sibling (fr:fratrie) element
      Parameters:
      node - input node
      tagName - if not null, tag name of the searched element.
      Returns:
      the found element or null.
    • testNodeType

      public static void testNodeType(Node node)