Package org.xwiki.rendering.wikimodel
Class WikiPageUtil
- java.lang.Object
-
- 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: 09da175c854238cedd21d5601b4f1cc2b4d4a3e3 $
-
-
Constructor Summary
Constructors Constructor Description WikiPageUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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)
Returnstrue
if the given value is a valid XML character.static boolean
isValidXmlName(String tagName, boolean colonEnabled)
This method checks the given string and returnstrue
if it is a valid XML namestatic boolean
isValidXmlNameChar(char ch, boolean colonEnabled)
Returnstrue
if the given value is a valid XML name character.static boolean
isValidXmlNameStartChar(char ch, boolean colonEnabled)
Returnstrue
if the given value is a valid first character of an XML name.
-
-
-
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 escapeescapeQuots
- if this flag istrue
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)
Returnstrue
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 returnstrue
if it is a valid XML nameSee http://www.w3.org/TR/xml/#NT-Name.
- Parameters:
tagName
- the name to checkcolonEnabled
- if this flag istrue
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)
Returnstrue
if the given value is a valid XML name character.See http://www.w3.org/TR/xml/#NT-NameChar.
- Parameters:
ch
- the character to checkcolonEnabled
- if this flag istrue
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)
Returnstrue
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 checkcolonEnabled
- if this flag istrue
then this method accepts the ':' symbol.- Returns:
true
if the given value is a valid first character for an XML name
-
-