XMLUtils (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.util, class: XMLUtils

Package org.apache.hadoop.hdfs.util

# Class XMLUtils

java.lang.Object
org.apache.hadoop.hdfs.util.XMLUtils

@Private @Unstable public class XMLUtils extends Object
General xml utilities.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `XMLUtils.InvalidXmlException`
  Exception that reflects an invalid XML document.
  `static class`
  `XMLUtils.Stanza`
  Represents a bag of key-value pairs encountered during parsing an XML file.
  `static class`
  `XMLUtils.UnmanglingError`
  Exception that reflects a string that cannot be unmangled.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `XMLUtils()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `addSaxString(ContentHandler contentHandler, String tag, String val)`
  Add a SAX tag with a string inside.
  `static String`
  `mangleXmlString(String str, boolean createEntityRefs)`
  Mangle a string so that it can be represented in an XML document.
  `static String`
  `unmangleXmlString(String str, boolean decodeEntityRefs)`
  Demangle a string from an XML document.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### XMLUtils

    public XMLUtils()

- ## Method Details

  - ### mangleXmlString

    public static String mangleXmlString(String str, boolean createEntityRefs)
    Mangle a string so that it can be represented in an XML document. There are three kinds of code points in XML: - Those that can be represented normally, - Those that have to be escaped (for example, & must be represented as &amp;) - Those that cannot be represented at all in XML. The built-in SAX functions will handle the first two types for us just fine. However, sometimes we come across a code point of the third type. In this case, we have to mangle the string in order to represent it at all. We also mangle backslash to avoid confusing a backslash in the string with part our escape sequence. The encoding used here is as follows: an illegal code point is represented as '\ABCD;', where ABCD is the hexadecimal value of the code point.
    Parameters:
      `str` - The input string.
    Returns:
      The mangled string.

  - ### unmangleXmlString

    public static String unmangleXmlString(String str, boolean decodeEntityRefs) throws XMLUtils.UnmanglingError
    Demangle a string from an XML document. See `mangleXmlString(String, boolean)` for a description of the mangling format.
    Parameters:
      `str` - The string to be demangled.
    Returns:
      The unmangled string
    Throws:
      `XMLUtils.UnmanglingError` - if the input is malformed.

  - ### addSaxString

    public static void addSaxString(ContentHandler contentHandler, String tag, String val) throws SAXException
    Add a SAX tag with a string inside.
    Parameters:
      `contentHandler` - the SAX content handler
      `tag` - the element tag to use
      `val` - the string to put inside the tag
    Throws:
      `SAXException`