|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectus.monoid.util.EncoderUtil
public class EncoderUtil
Static methods for encoding header field values. This includes encoded-words as defined in RFC 2047 or display-names of an e-mail address, for example.
Nested Class Summary | |
---|---|
static class |
EncoderUtil.Encoding
Selects one of the two encodings specified in RFC 2047. |
static class |
EncoderUtil.Usage
Indicates the intended usage of an encoded word. |
Field Summary | |
---|---|
static Charset |
US_ASCII
|
Method Summary | |
---|---|
static String |
encodeAddressDisplayName(String displayName)
Encodes the display-name portion of an address. |
static String |
encodeAddressLocalPart(String localPart)
Encodes the local part of an address specification as described in RFC 5322 section 3.4.1. |
static String |
encodeB(byte[] bytes)
Encodes the specified byte array using the B encoding defined in RFC 2047. |
static String |
encodeEncodedWord(String text,
EncoderUtil.Usage usage)
Encodes the specified text into an encoded word or a sequence of encoded words separated by space. |
static String |
encodeEncodedWord(String text,
EncoderUtil.Usage usage,
int usedCharacters)
Encodes the specified text into an encoded word or a sequence of encoded words separated by space. |
static String |
encodeEncodedWord(String text,
EncoderUtil.Usage usage,
int usedCharacters,
Charset charset,
EncoderUtil.Encoding encoding)
Encodes the specified text into an encoded word or a sequence of encoded words separated by space. |
static String |
encodeHeaderParameter(String name,
String value)
Encodes the specified strings into a header parameter as described in RFC 2045 section 5.1 and RFC 2183 section 2. |
static String |
encodeIfNecessary(String text,
EncoderUtil.Usage usage,
int usedCharacters)
Shortcut method that encodes the specified text into an encoded-word if the text has to be encoded. |
static String |
encodeQ(byte[] bytes,
EncoderUtil.Usage usage)
Encodes the specified byte array using the Q encoding defined in RFC 2047. |
static boolean |
hasToBeEncoded(String text,
int usedCharacters)
Determines if the specified string has to encoded into an encoded-word. |
static boolean |
isToken(String str)
Tests whether the specified string is a token as defined in RFC 2045 section 5.1. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Charset US_ASCII
Method Detail |
---|
public static String encodeAddressDisplayName(String displayName)
displayName
- display-name to encode.
public static String encodeAddressLocalPart(String localPart)
localPart
- the local part to encode
public static String encodeHeaderParameter(String name, String value)
name
- parameter name.value
- parameter value.
public static String encodeIfNecessary(String text, EncoderUtil.Usage usage, int usedCharacters)
text
- text to encode.usage
- whether the encoded-word is to be used to replace a text token or
a word entity (see RFC 822).usedCharacters
- number of characters already used up (
0 <= usedCharacters <= 50
).
public static boolean hasToBeEncoded(String text, int usedCharacters)
true
if the text contains characters that don't fall
into the printable ASCII character set or if the text contains a 'word'
(sequence of non-whitespace characters) longer than 77 characters
(including characters already used up in the line).
text
- text to analyze.usedCharacters
- number of characters already used up (
0 <= usedCharacters <= 50
).
true
if the specified text has to be encoded into an
encoded-word, false
otherwise.public static String encodeEncodedWord(String text, EncoderUtil.Usage usage)
The charset to encode the specified text into a byte array and the encoding to use for the encoded-word are detected automatically.
This method assumes that zero characters have already been used up in the current line.
text
- text to encode.usage
- whether the encoded-word is to be used to replace a text token or
a word entity (see RFC 822).
hasToBeEncoded(String, int)
public static String encodeEncodedWord(String text, EncoderUtil.Usage usage, int usedCharacters)
The charset to encode the specified text into a byte array and the encoding to use for the encoded-word are detected automatically.
text
- text to encode.usage
- whether the encoded-word is to be used to replace a text token or
a word entity (see RFC 822).usedCharacters
- number of characters already used up (
0 <= usedCharacters <= 50
).
hasToBeEncoded(String, int)
public static String encodeEncodedWord(String text, EncoderUtil.Usage usage, int usedCharacters, Charset charset, EncoderUtil.Encoding encoding)
text
- text to encode.usage
- whether the encoded-word is to be used to replace a text token or
a word entity (see RFC 822).usedCharacters
- number of characters already used up (
0 <= usedCharacters <= 50
).charset
- the Java charset that should be used to encode the specified
string into a byte array. A suitable charset is detected
automatically if this parameter is null
.encoding
- the encoding to use for the encoded-word (either B or Q). A
suitable encoding is automatically chosen if this parameter is
null
.
hasToBeEncoded(String, int)
public static String encodeB(byte[] bytes)
bytes
- byte array to encode.
public static String encodeQ(byte[] bytes, EncoderUtil.Usage usage)
bytes
- byte array to encode.usage
- whether the encoded-word is to be used to replace a text token or
a word entity (see RFC 822).
public static boolean isToken(String str)
str
- string to test.
true
if the specified string is a RFC 2045 token,
false
otherwise.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |