com.atlassian.jira.imports.project.util
Class XMLEscapeUtil

java.lang.Object
  extended by com.atlassian.jira.imports.project.util.XMLEscapeUtil

public class XMLEscapeUtil
extends Object

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.

Since:
v6.0

Field Summary
static char ESCAPING_CHAR
           
 
Constructor Summary
XMLEscapeUtil()
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ESCAPING_CHAR

public static final char ESCAPING_CHAR
See Also:
Constant Field Values
Constructor Detail

XMLEscapeUtil

public XMLEscapeUtil()
Method Detail

unicodeEncode

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.


unicodeDecode

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.


unicodeInPlaceEncode

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


Copyright © 2002-2014 Atlassian. All Rights Reserved.