com.hunnysoft.jmime
Class TextUtil

java.lang.Object
  extended bycom.hunnysoft.jmime.TextUtil

public final class TextUtil
extends java.lang.Object

Class that provides text utilities.

TextUtil provides various text utilities. All fields and methods are static; therefore, you may not create instances of TextUtil.

The EOL static field contains the default end-of-line character sequence that the library uses when generating new lines of text.


Field Summary
static ByteString CRLF_EOL
          Named constant for CR LF byte string.
static ByteString EOL
          The library's default end-of-line characters.
static ByteString LF_EOL
          Named constant for LF byte string.
 
Method Summary
static ByteString toCrLf(ByteString bstr)
          Converts to CR LF end-of-line characters.
static ByteString toDefaultEol(ByteString bstr)
          Converts to the default end-of-line character sequence.
static ByteString toLf(ByteString bstr)
          Converts to LF end-of-line character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CRLF_EOL

public static final ByteString CRLF_EOL
Named constant for CR LF byte string.


LF_EOL

public static final ByteString LF_EOL
Named constant for LF byte string.


EOL

public static ByteString EOL
The library's default end-of-line characters.

The value of TextUtil.EOL determines the default value for the end-of-line characters used by the library. If you change its value, you should set it to one of the static fields TextUtil.CRLF_EOL or TextUtil.LF_EOL. For example, the following code:

 TextUtil.EOL = TextUtil.CRLF_EOL;
 

will set CR LF as the default end-of-line characters for the library.

The value of EOL does not affect the way Hunny JMIME performs parsing. The assemble() member functions of some classes use EOL to append end-of-line characters.

EOL is static. You must be careful when you set its value in a multithreaded environment. You should set its value from your main thread when the program begins.

The default value for EOL is TextUtil.CRLF_EOL.

The MIME standard requires CR LF as the characters used for the end-of-line sequence. However, in the C and Unix programming environment, LF alone (frequently called "newline") is used for the end-of-line sequence. In that environment, it is common for disk I/O functions to convert to LF end-of-line sequence on input, and convert to CR LF on output. For compatibility with such an environment, JMIME allows you to change the default end-of-line characters. To change the default to LF alone, set this field to TextUtil.LF_EOL.

Method Detail

toCrLf

public static ByteString toCrLf(ByteString bstr)
Converts to CR LF end-of-line characters.

Parameters:
bstr - byte string to convert
Returns:
byte string with CR LF end-of-line characters

toLf

public static ByteString toLf(ByteString bstr)
Converts to LF end-of-line character.

Parameters:
bstr - byte string to convert
Returns:
byte string with LF end-of-line characters

toDefaultEol

public static ByteString toDefaultEol(ByteString bstr)
Converts to the default end-of-line character sequence.

The value of TextUtil.EOL determines end-of-line characters in the output string.

Parameters:
bstr - byte string to convert
Returns:
byte string with default end-of-line characters