Class XMLEncode


  • final class XMLEncode
    extends java.lang.Object
    Collection of XML encoding/decoding helpers.
    This is all about the special characters & and <, and for attributes " and '. These must be encoded/decoded from/to XML.
    • Constructor Summary

      Constructors 
      Constructor Description
      XMLEncode()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean needsEncoding​(java.lang.String text)
      Checks if this text needs encoding in order to be represented in XML.
      (package private) static void xmlEncodeText​(java.lang.String text, java.io.Writer writer)  
      private static java.lang.String xmlEncodeTextAsCDATABlock​(java.lang.String text)
      Returns string as CDATA block if possible, otherwise null.
      (package private) static void xmlEncodeTextAsPCDATA​(java.lang.String text, boolean forAttribute, char quoteChar, java.io.Writer n)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CDATA_BLOCK_THRESHOLD_LENGTH

        private static final int CDATA_BLOCK_THRESHOLD_LENGTH
        See Also:
        Constant Field Values
    • Constructor Detail

      • XMLEncode

        XMLEncode()
    • Method Detail

      • xmlEncodeText

        static void xmlEncodeText​(java.lang.String text,
                                  java.io.Writer writer)
                           throws java.io.IOException
        Throws:
        java.io.IOException
      • xmlEncodeTextAsPCDATA

        static void xmlEncodeTextAsPCDATA​(java.lang.String text,
                                          boolean forAttribute,
                                          char quoteChar,
                                          java.io.Writer n)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • xmlEncodeTextAsCDATABlock

        private static java.lang.String xmlEncodeTextAsCDATABlock​(java.lang.String text)
        Returns string as CDATA block if possible, otherwise null.
      • needsEncoding

        private static boolean needsEncoding​(java.lang.String text)
        Checks if this text needs encoding in order to be represented in XML.