Class WikiPageUtil


  • public class WikiPageUtil
    extends Object
    This class contains some utility methods used for escaping xml strings as well as for encoding/decoding http parameters.
    Since:
    4.0M1
    Version:
    $Id: 09da175c854238cedd21d5601b4f1cc2b4d4a3e3 $
    • Constructor Detail

      • WikiPageUtil

        public WikiPageUtil()
    • Method Detail

      • decodeHttpParams

        public static String decodeHttpParams​(String str)
        Returns the decoded http string - all special symbols, replaced by replaced by the %[HEX HEX] sequence, where [HEX HEX] is the hexadecimal code of the escaped symbol will be restored to its original characters (see RFC-2616 http://www.w3.org/Protocols/rfc2616/).
        Parameters:
        str - the string to decode
        Returns:
        the decoded string.
      • encodeHttpParams

        public static String encodeHttpParams​(String str)
        Returns the encoded string - all special symbols will be replaced by %[HEX HEX] sequence, where [HEX HEX] is the hexadecimal code of the escaped symbol (see RFC-2616 http://www.w3.org/Protocols/rfc2616/rfc2616.html).
        Parameters:
        str - the string to encode
        Returns:
        the encoded string.
      • escapeXmlAttribute

        public static String escapeXmlAttribute​(String str)
        Returns the escaped attribute string.
        Parameters:
        str - the string to escape
        Returns:
        the escaped string.
      • escapeXmlString

        public static String escapeXmlString​(String str)
        Returns the escaped string.
        Parameters:
        str - the string to escape
        Returns:
        the escaped string.
      • escapeXmlString

        public static String escapeXmlString​(String str,
                                             boolean escapeQuots)
        Returns the escaped string.
        Parameters:
        str - the string to escape
        escapeQuots - if this flag is true then "'" and "\"" symbols also will be escaped
        Returns:
        the escaped string.
      • getCDATA

        public static String getCDATA​(String text)
        Returns:
        CDATA block corresponding to the given text
      • isValidXmlChar

        public static boolean isValidXmlChar​(int ch)
        Returns true if the given value is a valid XML character.

        See http://www.w3.org/TR/xml/#charsets

        Parameters:
        ch - the value to check
        Returns:
        true if the given value is a valid XML character.
      • isValidXmlName

        public static boolean isValidXmlName​(String tagName,
                                             boolean colonEnabled)
        This method checks the given string and returns true if it is a valid XML name

        See http://www.w3.org/TR/xml/#NT-Name.

        Parameters:
        tagName - the name to check
        colonEnabled - if this flag is true then this method accepts the ':' symbol in the name
        Returns:
        true if the given string is a valid XML name
      • isValidXmlNameChar

        public static boolean isValidXmlNameChar​(char ch,
                                                 boolean colonEnabled)
        Returns true if the given value is a valid XML name character.

        See http://www.w3.org/TR/xml/#NT-NameChar.

        Parameters:
        ch - the character to check
        colonEnabled - if this flag is true then this method accepts the ':' symbol.
        Returns:
        true if the given value is a valid XML name character
      • isValidXmlNameStartChar

        public static boolean isValidXmlNameStartChar​(char ch,
                                                      boolean colonEnabled)
        Returns true if the given value is a valid first character of an XML name.

        See http://www.w3.org/TR/xml/#NT-NameStartChar.

        Parameters:
        ch - the character to check
        colonEnabled - if this flag is true then this method accepts the ':' symbol.
        Returns:
        true if the given value is a valid first character for an XML name