Methods Summary |
---|
public java.lang.String | decode(java.lang.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.
if (pString == null) {
return null;
}
try {
return decode(pString, getDefaultCharset());
} catch(UnsupportedEncodingException e) {
throw new DecoderException(e.getMessage());
}
|
public java.lang.Object | decode(java.lang.Object pObject)Decodes a URL safe object into its original form. Escaped
characters are converted back to their original representation.
if (pObject == null) {
return null;
} else if (pObject instanceof byte[]) {
return decode((byte[])pObject);
} else if (pObject instanceof String) {
return decode((String)pObject);
} else {
throw new DecoderException("Objects of type " +
pObject.getClass().getName() + " cannot be URL decoded");
}
|
public 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.
return decodeUrl(bytes);
|
public java.lang.String | decode(java.lang.String pString, java.lang.String charset)Decodes a URL safe string into its original form using the
specified encoding. Escaped characters are converted back
to their original representation.
if (pString == null) {
return null;
}
return new String(decode(pString.getBytes(StringEncodings.US_ASCII)), charset);
|
public static final 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.
if (bytes == null) {
return null;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
for (int i = 0; i < bytes.length; i++) {
int b = bytes[i];
if (b == '+") {
buffer.write(' ");
} else if (b == '%") {
try {
int u = Character.digit((char)bytes[++i], 16);
int l = Character.digit((char)bytes[++i], 16);
if (u == -1 || l == -1) {
throw new DecoderException("Invalid URL encoding");
}
buffer.write((char)((u << 4) + l));
} catch(ArrayIndexOutOfBoundsException e) {
throw new DecoderException("Invalid URL encoding");
}
} else {
buffer.write(b);
}
}
return buffer.toByteArray();
|
public java.lang.Object | encode(java.lang.Object pObject)Encodes an object into its URL safe form. Unsafe characters are
escaped.
if (pObject == null) {
return null;
} else if (pObject instanceof byte[]) {
return encode((byte[])pObject);
} else if (pObject instanceof String) {
return encode((String)pObject);
} else {
throw new EncoderException("Objects of type " +
pObject.getClass().getName() + " cannot be URL encoded");
}
|
public byte[] | encode(byte[] bytes)Encodes an array of bytes into an array of URL safe 7-bit
characters. Unsafe characters are escaped.
return encodeUrl(WWW_FORM_URL, bytes);
|
public java.lang.String | encode(java.lang.String pString, java.lang.String charset)Encodes a string into its URL safe form using the specified
string charset. Unsafe characters are escaped.
if (pString == null) {
return null;
}
return new String(encode(pString.getBytes(charset)), StringEncodings.US_ASCII);
|
public java.lang.String | encode(java.lang.String pString)Encodes a string into its URL safe form using the default string
charset. Unsafe characters are escaped.
if (pString == null) {
return null;
}
try {
return encode(pString, getDefaultCharset());
} catch(UnsupportedEncodingException e) {
throw new EncoderException(e.getMessage());
}
|
public static final byte[] | encodeUrl(java.util.BitSet urlsafe, byte[] bytes)Encodes an array of bytes into an array of URL safe 7-bit
characters. Unsafe characters are escaped.
if (bytes == null) {
return null;
}
if (urlsafe == null) {
urlsafe = WWW_FORM_URL;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
for (int i = 0; i < bytes.length; i++) {
int b = bytes[i];
if (b < 0) {
b = 256 + b;
}
if (urlsafe.get(b)) {
if (b == ' ") {
b = '+";
}
buffer.write(b);
} else {
buffer.write('%");
char hex1 = Character.toUpperCase(
Character.forDigit((b >> 4) & 0xF, 16));
char hex2 = Character.toUpperCase(
Character.forDigit(b & 0xF, 16));
buffer.write(hex1);
buffer.write(hex2);
}
}
return buffer.toByteArray();
|
public java.lang.String | getDefaultCharset()The default charset used for string decoding and encoding.
return this.charset;
|
public java.lang.String | getEncoding()The String encoding used for decoding and encoding.
return this.charset;
|