类 EncoderUtil
java.lang.Object
com.sh.mail.mime4j.codec.EncoderUtil
Description:
Title:首亨软件 - TSS/CRM等
- 从以下版本开始:
- Aug 16, 2012
-
嵌套类概要
嵌套类修饰符和类型类说明static enumSelects one of the two encodings specified in RFC 2047.static enumIndicates the intended usage of an encoded word. -
方法概要
修饰符和类型方法说明static StringencodeAddressDisplayName(String displayName) Encodes the display-name portion of an address.static StringencodeAddressLocalPart(String localPart) Encodes the local part of an address specification as described in RFC 5322 section 3.4.1.static StringencodeB(byte[] bytes) Encodes the specified byte array using the B encoding defined in RFC 2047.static StringencodeEncodedWord(String text, EncoderUtil.Usage usage) Encodes the specified text into an encoded word or a sequence of encoded words separated by space.static StringencodeEncodedWord(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 StringencodeEncodedWord(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 StringencodeHeaderParameter(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 StringencodeIfNecessary(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 StringencodeQ(byte[] bytes, EncoderUtil.Usage usage) Encodes the specified byte array using the Q encoding defined in RFC 2047.static booleanhasToBeEncoded(String text, int usedCharacters) Determines if the specified string has to encoded into an encoded-word.static booleanTests whether the specified string is a token as defined in RFC 2045 section 5.1.
-
方法详细资料
-
encodeAddressDisplayName
Encodes the display-name portion of an address. See RFC 5322 section 3.4 and RFC 2047 section 5.3. The specified string should not be folded.- 参数:
displayName- display-name to encode.- 返回:
- encoded display-name.
-
encodeAddressLocalPart
Encodes the local part of an address specification as described in RFC 5322 section 3.4.1. Leading and trailing CFWS should have been removed before calling this method. The specified string should not contain any illegal (control or non-ASCII) characters.- 参数:
localPart- the local part to encode- 返回:
- the encoded local part.
-
encodeHeaderParameter
Encodes the specified strings into a header parameter as described in RFC 2045 section 5.1 and RFC 2183 section 2. The specified strings should not contain any illegal (control or non-ASCII) characters.- 参数:
name- parameter name.value- parameter value.- 返回:
- encoded result.
-
encodeIfNecessary
Shortcut method that encodes the specified text into an encoded-word if the text has to be encoded.- 参数:
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).- 返回:
- the specified text if encoding is not necessary or an encoded word or a sequence of encoded words otherwise.
-
hasToBeEncoded
Determines if the specified string has to encoded into an encoded-word. Returnstrueif 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.
-
encodeEncodedWord
Encodes the specified text into an encoded word or a sequence of encoded words separated by space. The text is separated into a sequence of encoded words if it does not fit in a single one.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).- 返回:
- the encoded word (or sequence of encoded words if the given text does not fit in a single encoded word).
- 另请参阅:
-
encodeEncodedWord
Encodes the specified text into an encoded word or a sequence of encoded words separated by space. The text is separated into a sequence of encoded words if it does not fit in a single one.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).- 返回:
- the encoded word (or sequence of encoded words if the given text does not fit in a single encoded word).
- 另请参阅:
-
encodeEncodedWord
public 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. The text is separated into a sequence of encoded words if it does not fit in a single one.- 参数:
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.- 返回:
- the encoded word (or sequence of encoded words if the given text does not fit in a single encoded word).
- 另请参阅:
-
encodeB
Encodes the specified byte array using the B encoding defined in RFC 2047.- 参数:
bytes- byte array to encode.- 返回:
- encoded string.
-
encodeQ
Encodes the specified byte array using the Q encoding defined in RFC 2047.- 参数:
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).- 返回:
- encoded string.
-
isToken
Tests whether the specified string is a token as defined in RFC 2045 section 5.1.- 参数:
str- string to test.- 返回:
trueif the specified string is a RFC 2045 token,falseotherwise.
-