Class XmlFile


  • public class XmlFile
    extends Object
    • Method Detail

      • getInputFile

        @Nullable
        public org.sonar.api.batch.fs.InputFile getInputFile()
        Returns:
        null when created based on string
      • getContents

        public String getContents()
      • getCharset

        public Charset getCharset()
      • getDocument

        public Document getDocument()
        Returns:
        document with namespace information
      • getNamespaceAwareDocument

        public Document getNamespaceAwareDocument()
      • getNamespaceUnawareDocument

        public Document getNamespaceUnawareDocument()
      • attributeNameLocation

        public static XmlTextRange attributeNameLocation​(Attr node)
      • attributeValueLocation

        public static XmlTextRange attributeValueLocation​(Attr node)
      • children

        public static List<Node> children​(Node node)
        Get all the children of a node, as a proper java list.
        Parameters:
        node - the node to get children from
        Returns:
        a list of nodes, possibly empty.
      • asList

        public static List<Node> asList​(@Nullable
                                        NodeList nodeList)
        Transform a NodeList (from DOM interface) into a java List
        Parameters:
        nodeList - the nodeList to be transformed into a List, possibly null
        Returns:
        The equivalent java list. Note that a null NodeList will produce an empty list.
      • nodeAttribute

        @CheckForNull
        public static Node nodeAttribute​(Node node,
                                         String attribute)
        Try to retrieve the attribute node corresponding to an attribute name in a given node.
        Parameters:
        node - The node to query for an attribute
        attribute - The name of the attribute to search for
        Returns:
        The corresponding attribute node, if the attribute can be found, or null if not found.