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 StringdecodeHttpParams(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 StringencodeHttpParams(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 StringescapeXmlAttribute(String str)Returns the escaped attribute string.static StringescapeXmlString(String str)Returns the escaped string.static StringescapeXmlString(String str, boolean escapeQuots)Returns the escaped string.static StringgetCDATA(String text)static booleanisValidXmlChar(int ch)Returnstrueif the given value is a valid XML character.static booleanisValidXmlName(String tagName, boolean colonEnabled)This method checks the given string and returnstrueif it is a valid XML namestatic booleanisValidXmlNameChar(char ch, boolean colonEnabled)Returnstrueif the given value is a valid XML name character.static booleanisValidXmlNameStartChar(char ch, boolean colonEnabled)Returnstrueif 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 istruethen "'" 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)
Returnstrueif the given value is a valid XML character.See http://www.w3.org/TR/xml/#charsets
- Parameters:
ch- the value to check- Returns:
trueif the given value is a valid XML character.
-
isValidXmlName
public static boolean isValidXmlName(String tagName, boolean colonEnabled)
This method checks the given string and returnstrueif it is a valid XML nameSee http://www.w3.org/TR/xml/#NT-Name.
- Parameters:
tagName- the name to checkcolonEnabled- if this flag istruethen this method accepts the ':' symbol in the name- Returns:
trueif the given string is a valid XML name
-
isValidXmlNameChar
public static boolean isValidXmlNameChar(char ch, boolean colonEnabled)Returnstrueif 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 istruethen this method accepts the ':' symbol.- Returns:
trueif the given value is a valid XML name character
-
isValidXmlNameStartChar
public static boolean isValidXmlNameStartChar(char ch, boolean colonEnabled)Returnstrueif 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 istruethen this method accepts the ':' symbol.- Returns:
trueif the given value is a valid first character for an XML name
-
-