org.xwiki.rendering.wikimodel
Class WikiPageUtil

java.lang.Object
  extended by org.xwiki.rendering.wikimodel.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$

Constructor Summary
WikiPageUtil()
           
 
Method Summary
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/).
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).
static String escapeXmlAttribute(String str)
          Returns the escaped attribute string.
static String escapeXmlString(String str)
          Returns the escaped string.
static String escapeXmlString(String str, boolean escapeQuots)
          Returns the escaped string.
static String getCDATA(String text)
           
static boolean isValidXmlChar(int ch)
          Returns true if the given value is a valid XML character.
static boolean isValidXmlName(String tagName, boolean colonEnabled)
          This method checks the given string and returns true if it is a valid XML name
static boolean isValidXmlNameChar(char ch, boolean colonEnabled)
          Returns true if the given value is a valid XML name character.
static boolean isValidXmlNameStartChar(char ch, boolean colonEnabled)
          Returns true if the given value is a valid first character of an XML name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.

Parameters:
ch - the value to check
Returns:
true if the given value is a valid XML character.
See Also:
http://www.w3.org/TR/xml/#charsets

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

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
See Also:
http://www.w3.org/TR/xml/#NT-Name

isValidXmlNameChar

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

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
See Also:
http://www.w3.org/TR/xml/#NT-NameChar

isValidXmlNameStartChar

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

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
See Also:
http://www.w3.org/TR/xml/#NT-NameStartChar


Copyright © 2004-2012 XWiki. All Rights Reserved.