public class

URLCodec

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.URLCodec

Summary

Public Constructors
URLCodec()
Public Methods
static byte[] decode(byte[] bytes)
Decodes an array of URL safe 7-bit characters into an array of original bytes.
static Object decode(Object pObject)
Decodes a URL safe object into its original form.
static String decode(String pString, String charset)
Decodes a URL safe string into its original form using the specified encoding.
static String decode(String pString)
Decodes a URL safe string into its original form using the default string charset.
static byte[] decodeUrl(byte[] bytes)
Decodes an array of URL safe 7-bit characters into an array of original bytes.
static Object encode(Object pObject)
Encodes an object into its URL safe form.
static String encode(String pString, String charset)
Encodes a string into its URL safe form using the specified string charset.
static byte[] encode(byte[] bytes, boolean withSpacesAsHexValue)
Encodes an array of bytes into an array of URL safe 7-bit characters.
static byte[] encode(byte[] bytes)
Encodes an array of bytes into an array of URL safe 7-bit characters.
static String encode(String pString, boolean withSpacesAsHexValue)
Encodes a string into its URL safe form using the default string charset.
static Object encode(Object pObject, boolean withSpacesAsHexValue)
Encodes an object into its URL safe form.
static String encode(String pString, String charset, boolean withSpacesAsHexValue)
Encodes a string into its URL safe form using the specified string charset.
static String encode(String pString)
Encodes a string into its URL safe form using the default string charset.
static byte[] encodeUrl(BitSet urlsafe, byte[] bytes)
Encodes an array of bytes into an array of URL safe 7-bit characters.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public URLCodec ()

Public Methods

public static byte[] decode (byte[] bytes)

Decodes an array of URL safe 7-bit characters into an array of original bytes. Escaped characters are converted back to their original representation.

Parameters
bytes array of URL safe characters
Returns
  • array of original bytes
Throws
UnsupportedEncodingException Thrown if URL decoding is unsuccessful

public static Object decode (Object pObject)

Decodes a URL safe object into its original form. Escaped characters are converted back to their original representation.

Parameters
pObject URL safe object to convert into its original form
Returns
  • original object
Throws
UnsupportedEncodingException Thrown if the argument is not a String or byte[]. Thrown if a failure condition is encountered during the decode process.

public static String decode (String pString, String charset)

Decodes a URL safe string into its original form using the specified encoding. Escaped characters are converted back to their original representation.

Parameters
pString URL safe string to convert into its original form
charset the original string charset
Returns
  • original string
Throws
UnsupportedEncodingException Thrown if charset is not supported

public static String decode (String pString)

Decodes a URL safe string into its original form using the default string charset. Escaped characters are converted back to their original representation.

Parameters
pString URL safe string to convert into its original form
Returns
  • original string
Throws
UnsupportedEncodingException Thrown if URL decoding is unsuccessful
See Also
  • #getDefaultCharset()

public static byte[] decodeUrl (byte[] bytes)

Decodes an array of URL safe 7-bit characters into an array of original bytes. Escaped characters are converted back to their original representation.

Parameters
bytes array of URL safe characters
Returns
  • array of original bytes
Throws
UnsupportedEncodingException Thrown if URL decoding is unsuccessful

public static Object encode (Object pObject)

Encodes an object into its URL safe form. Unsafe characters are escaped. Encodes spaces as '+' character.

Parameters
pObject string to convert to a URL safe form
Returns
  • URL safe object
Throws
UnsupportedEncodingException Thrown if URL encoding is not applicable to objects of this type or if encoding is unsuccessful

public static String encode (String pString, String charset)

Encodes a string into its URL safe form using the specified string charset. Unsafe characters are escaped. Spaces are encoded with the '+' character.

Parameters
pString string to convert to a URL safe form
charset the charset for pString
Returns
  • URL safe string
Throws
UnsupportedEncodingException Thrown if charset is not supported

public static byte[] encode (byte[] bytes, boolean withSpacesAsHexValue)

Encodes an array of bytes into an array of URL safe 7-bit characters. Unsafe characters are escaped.

Parameters
bytes array of bytes to convert to URL safe characters
withSpacesAsHexValue if true, spaces will be encoded with their hex value (%20), otherwise they're encoded with '+' character.
Returns
  • array of bytes containing URL safe characters

public static byte[] encode (byte[] bytes)

Encodes an array of bytes into an array of URL safe 7-bit characters. Unsafe characters are escaped. Spaces are encoded as the '+' character.

Parameters
bytes array of bytes to convert to URL safe characters
Returns
  • array of bytes containing URL safe characters

public static String encode (String pString, boolean withSpacesAsHexValue)

Encodes a string into its URL safe form using the default string charset. Unsafe characters are escaped.

Parameters
pString string to convert to a URL safe form
withSpacesAsHexValue if true spaces will be encoded with their hex value (%20), otherwise they're encoded with '+' character.
Returns
  • URL safe string
Throws
UnsupportedEncodingException Thrown if URL encoding is unsuccessful
See Also
  • #getDefaultCharset()

public static Object encode (Object pObject, boolean withSpacesAsHexValue)

Encodes an object into its URL safe form. Unsafe characters are escaped.

Parameters
pObject string to convert to a URL safe form
withSpacesAsHexValue if true spaces will be encoded with their hex value (%20), otherwise they're encoded with '+' character.
Returns
  • URL safe object
Throws
UnsupportedEncodingException Thrown if URL encoding is not applicable to objects of this type or if encoding is unsuccessful

public static String encode (String pString, String charset, boolean withSpacesAsHexValue)

Encodes a string into its URL safe form using the specified string charset. Unsafe characters are escaped.

Parameters
pString string to convert to a URL safe form
charset the charset for pString
withSpacesAsHexValue if true spaces will be encoded with their hex value (%20), otherwise they're encoded with '+' character.
Returns
  • URL safe string
Throws
UnsupportedEncodingException Thrown if charset is not supported

public static String encode (String pString)

Encodes a string into its URL safe form using the default string charset. Unsafe characters are escaped. Spaces are encoded as the '+' character.

Parameters
pString string to convert to a URL safe form
Returns
  • URL safe string
Throws
UnsupportedEncodingException Thrown if URL encoding is unsuccessful
See Also
  • #getDefaultCharset()

public static byte[] encodeUrl (BitSet urlsafe, byte[] bytes)

Encodes an array of bytes into an array of URL safe 7-bit characters. Unsafe characters are escaped.

Parameters
urlsafe bitset of characters deemed URL safe
bytes array of bytes to convert to URL safe characters
Returns
  • array of bytes containing URL safe characters