Methods Summary |
---|
public java.lang.String | decode(java.lang.String pString)Decodes a quoted-printable 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 quoted-printable 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 quoted-printable decoded");
}
|
public byte[] | decode(byte[] bytes)Decodes an array of quoted-printable characters into an array of original bytes. Escaped characters are converted
back to their original representation.
This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
RFC 1521.
return decodeQuotedPrintable(bytes);
|
public java.lang.String | decode(java.lang.String pString, java.lang.String charset)Decodes a quoted-printable string into its original form using the specified string charset. 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[] | decodeQuotedPrintable(byte[] bytes)Decodes an array quoted-printable characters into an array of original bytes. Escaped characters are converted
back to their original representation.
This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
RFC 1521.
if (bytes == null) {
return null;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
for (int i = 0; i < bytes.length; i++) {
int b = bytes[i];
if (b == ESCAPE_CHAR) {
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 quoted-printable encoding");
}
buffer.write((char) ((u << 4) + l));
} catch (ArrayIndexOutOfBoundsException e) {
throw new DecoderException("Invalid quoted-printable encoding");
}
} else {
buffer.write(b);
}
}
return buffer.toByteArray();
|
public java.lang.Object | encode(java.lang.Object pObject)Encodes an object into its quoted-printable 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 quoted-printable encoded");
}
|
public java.lang.String | encode(java.lang.String pString, java.lang.String charset)Encodes a string into its quoted-printable form using the specified charset. Unsafe characters are escaped.
This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
RFC 1521 and is suitable for encoding binary data and unformatted text.
if (pString == null) {
return null;
}
return new String(encode(pString.getBytes(charset)), StringEncodings.US_ASCII);
|
public byte[] | encode(byte[] bytes)Encodes an array of bytes into an array of quoted-printable 7-bit characters. Unsafe characters are escaped.
This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
RFC 1521 and is suitable for encoding binary data and unformatted text.
return encodeQuotedPrintable(PRINTABLE_CHARS, bytes);
|
public java.lang.String | encode(java.lang.String pString)Encodes a string into its quoted-printable form using the default string charset. Unsafe characters are escaped.
This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
RFC 1521 and is suitable for encoding binary data.
if (pString == null) {
return null;
}
try {
return encode(pString, getDefaultCharset());
} catch (UnsupportedEncodingException e) {
throw new EncoderException(e.getMessage());
}
|
private static final void | encodeQuotedPrintable(int b, java.io.ByteArrayOutputStream buffer)Encodes byte into its quoted-printable representation.
buffer.write(ESCAPE_CHAR);
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);
|
public static final byte[] | encodeQuotedPrintable(java.util.BitSet printable, byte[] bytes)Encodes an array of bytes into an array of quoted-printable 7-bit characters. Unsafe characters are escaped.
This function implements a subset of quoted-printable encoding specification (rule #1 and rule #2) as defined in
RFC 1521 and is suitable for encoding binary data and unformatted text.
if (bytes == null) {
return null;
}
if (printable == null) {
printable = PRINTABLE_CHARS;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
for (int i = 0; i < bytes.length; i++) {
int b = bytes[i];
if (b < 0) {
b = 256 + b;
}
if (printable.get(b)) {
buffer.write(b);
} else {
encodeQuotedPrintable(b, buffer);
}
}
return buffer.toByteArray();
|
public java.lang.String | getDefaultCharset()Returns the default charset used for string decoding and encoding.
return this.charset;
|