Class DOMUtil

java.lang.Object
org.apache.solr.common.util.DOMUtil

public class DOMUtil extends Object
XML DOM utilities
  • Field Details

  • Constructor Details

    • DOMUtil

      public DOMUtil()
  • Method Details

    • toMap

      public static Map<String,String> toMap(NamedNodeMap attrs)
    • toMapExcept

      public static Map<String,String> toMapExcept(NamedNodeMap attrs, String... exclusions)
    • getChild

      public static Node getChild(Node node, String name)
    • getAttr

      public static String getAttr(NamedNodeMap attrs, String name)
    • getAttr

      public static String getAttr(Node nd, String name)
    • getAttrOrDefault

      public static String getAttrOrDefault(Node nd, String name, String def)
    • getAttr

      public static String getAttr(NamedNodeMap attrs, String name, String missing_err)
    • getAttr

      public static String getAttr(Node node, String name, String missing_err)
    • childNodesToNamedList

      public static NamedList<Object> childNodesToNamedList(Node nd)
    • childNodesToList

      public static List<Object> childNodesToList(Node nd)
    • nodesToNamedList

      public static NamedList<Object> nodesToNamedList(NodeList nlst)
    • nodesToList

      public static List<Object> nodesToList(NodeList nlst)
    • addToNamedList

      public static void addToNamedList(Node nd, NamedList<Object> nlst, List<Object> arr)
      Examines a Node from the DOM representation of a NamedList and adds the contents of that node to both the specified NamedList and List passed as arguments.
      Parameters:
      nd - The Node whose type will be used to determine how to parse the text content. If there is a 'name' attribute it will be used when adding to the NamedList
      nlst - A NamedList to add the item to with name if application. If this param is null it will be ignored.
      arr - A List to add the item to. If this param is null it will be ignored.
    • parseVal

      public static Object parseVal(String type, String name, String textValue)
      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    • getText

      public static String getText(Node nd)
      Drop in replacement for Node.getTextContent().

      This method is provided to support the same functionality as Node.getTextContent() but in a way that is DOM Level 2 compatible.

      See Also:
    • substituteSystemProperties

      public static void substituteSystemProperties(Node node)
      Replaces ${system.property[:default value]} references in all attributes and text nodes of supplied node. If the system property is not defined and no default value is provided, a runtime exception is thrown.
      Parameters:
      node - DOM node to walk for substitutions
    • substituteProperties

      public static void substituteProperties(Node node, Properties properties)
      Replaces ${property[:default value]} references in all attributes and text nodes of supplied node. If the property is not defined, either in the given Properties instance nor in System.getProperty and no default value is provided, a runtime exception is thrown.
      Parameters:
      node - DOM node to walk for substitutions
      properties - the Properties instance from which a value can be looked up
    • substituteProperty

      public static String substituteProperty(String value, Properties coreProperties)