|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.hunnysoft.jmime.QuotedPrintableDecoderW
Class that performs quoted-printable decoding, with input from a char array.
This class is the same as QuotedPrintableDecoder, except
that the input is taken from a character array, instead of a byte array.
See the overview section of QuotedPrintableDecoder for
general information that applies to both
QuotedPrintableDecoder and
QuotedPrintableDecoderW.
QuotedPrintableDecoder| Constructor Summary | |
QuotedPrintableDecoderW()
Default constructor. |
|
| Method Summary | |
ByteString |
decode(java.lang.String encoded)
Performs single-step buffer-to-buffer quoted-printable decoding. |
void |
decodeSegment(CharBuffer inBuf,
ByteBuffer outBuf)
Decodes data from the input buffer to the output buffer. |
boolean |
errorDetected()
Indicates if an error occurred while decoding. |
void |
finish(ByteBuffer outBuf)
Finishes a multiple-buffer decode operation. |
boolean |
outputCrLf()
Gets the CRLF end-of-line characters option. |
void |
setOutputCrLf(boolean b)
Sets the CRLF end-of-line characters option. |
void |
start()
Starts a multiple-buffer decode operation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public QuotedPrintableDecoderW()
| Method Detail |
public void setOutputCrLf(boolean b)
If this option is true, then the decoder uses CR LF as the end-of-line characters for hard line breaks in the decoded output. If this option is false, then the decoder uses LF alone.
Normally, you do not need to set this option, because the
decoder performs correctly by default. When your program starts,
and before you create any threads, set TextUtil.EOL to
either TextUtil.LF_EOL or TextUtil.CRLF_EOL. (The
default is TextUtil.LF_EOL.) Then, the
quoted-printable decoder sets the value of this option based on the
value of TextUtil.EOL.
b - true value causes the decoder to output CR LF for the
end-of-line characters; false causes it to output LF.public boolean outputCrLf()
setOutputCrLf(boolean)public boolean errorDetected()
After a decode operation, you may check the return value of this method to discover if the decoder detected any errors while decoding.
The decoder correctly decodes all content that is encoded according to the MIME standard. However, if the content is encoded incorrectly, the decoder detects an error, and the decoder may not be able to correctly decode the content. The decoder treats all errors as non-fatal and tries to recover from them.
The decoder treats errors as non-fatal errors because most quoted-printable-encoded content is text. Even if there are errors in decoding the content, the text should still be presented to a human user, since humans are much better than machines at understanding text.
public void start()
If you use the low-level interface for multiple-buffer decoding,
you must call start to begin the decode operation. You
may use a QuotedPrintableDecoder instance for many
decode operations, but you must call start to begin
each operation.
For more information on using the low-level interface, see the
overview section for QuotedPrintableDecoder.
You do not need to call this method if you use the decode(String) method for decoding.
public void decodeSegment(CharBuffer inBuf,
ByteBuffer outBuf)
This method is an essential part of the low-level interface and
performs most of the work of decoding for the
QuotedPrintableDecoderW class. It takes an input buffer
and an output buffer as parameters, and decodes data from the input
buffer until the input buffer is empty or the output buffer is full.
In other words, one of the following conditions is guaranteed to be
satisfied when the method returns:
inBuf.pos == inBuf.endPos
(input buffer empty) outBuf.pos == outBuf.endPos
(output buffer full) You may call the method multiple times to decode multiple buffers of input data. However, before you call the method, both of the following conditions should be true:
inBuf.pos < inBuf.endPos
(input buffer data available) outBuf.pos < outBuf.endPos
(output buffer space available) For more information on using the low-level interface, see the
overview section for QuotedPrintableDecoder.
inBuf - input bufferoutBuf - output bufferpublic void finish(ByteBuffer outBuf)
When you use the low-level interface, the decoder buffers some data internally. Therefore, after you have passed all input data to the decoder, you must call this method to flush the internal buffer.
The following condition must be satisfied when you call the method:
outBuf.pos < outBuf.endPos
(output buffer space available) The above condition must also be satisified after the method
returns in order to guarantee that all output data has been written
to the output buffer. You may need to call finish more
than once before the above condition is satisfied when the method
returns.
For more information on using the low-level interface, see the
overview section for QuotedPrintableDecoder.
outBuf - output bufferpublic ByteString decode(java.lang.String encoded)
To perform quoted-printable decoding using this method, create a
String containing the data you want to decode and pass
it as the method's argument. The returned ByteString
contains the decoded output.
This method makes it very simple to perform quoted-printable decoding. The disadvantage of this method is that it requires all the data to be kept in memory for processing. You may use the low-level interface, described in the overview section, to perform quoted-printable decoding of large data using limited memory.
This method uses the low-level interface internally. Any options set for the decoder object have the same effect using either this method or the low-level interface.
encoded - string containing the encoded data
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||