public class

XMLEscapeUtil

extends Object
java.lang.Object
   ↳ com.atlassian.jira.imports.project.util.XMLEscapeUtil

Class Overview

Replaces all characters that are illegal in XML with a escape sequence '☃[0-9][0-9][0-9][0-9]'. Additionally ☃ character is also escaped to ensure that decoding encoded text will ne the same.

Summary

Constants
char ESCAPING_CHAR
Public Constructors
XMLEscapeUtil()
Public Methods
static String unicodeDecode(String string)
Substitutes all occurrences of '☃[0-9][0-9][0-9][0-9]' with their corresponding character codes.
static String unicodeEncode(String string)
Replaces all characters that are illegal in XML with a Java-like unicode escape sequence '☃[0-9][0-9][0-9][0-9]'.
static int unicodeInPlaceEncode(char[] cbuf, int off, int len, int maxLen, Queue<Character> overflow)
Escaping characters in place in given buffer.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final char ESCAPING_CHAR

Constant Value: 9731 (0x00002603)

Public Constructors

public XMLEscapeUtil ()

Public Methods

public static String unicodeDecode (String string)

Substitutes all occurrences of '☃[0-9][0-9][0-9][0-9]' with their corresponding character codes. When null is passed into this method, null is returned.

public static String unicodeEncode (String string)

Replaces all characters that are illegal in XML with a Java-like unicode escape sequence '☃[0-9][0-9][0-9][0-9]'. When null is passed into this method, null is returned.

public static int unicodeInPlaceEncode (char[] cbuf, int off, int len, int maxLen, Queue<Character> overflow)

Escaping characters in place in given buffer. Because escaped character is encoded with more than one character it is quite possible that it won't fit in buffer. Additional characters in escaped form if needed will be added to overflow queue. Buffer is analyzed from offset for len characters. Buffer may be longer but not filled - maxLen is maximum buffer length that can be used.

Parameters
cbuf buffer with data - it will be overwritten with escaped data
off offset of characters in buffer to be analyzed and escaped if needed
len number of characters to be analyzed
maxLen maximum number of characters that can be put into buffer (counting from offset)
overflow should be empty when called, used to return overflow data
Returns
  • number of characters in buffer starting from offset at the end of function