org.apache.geronimo.mail.util
Class QuotedPrintableEncoder

java.lang.Object
  extended by org.apache.geronimo.mail.util.QuotedPrintableEncoder
All Implemented Interfaces:
Encoder

public class QuotedPrintableEncoder
extends Object
implements Encoder


Field Summary
protected  int bytesWritten
           
protected  int cachedCharacter
           
protected static byte[] decodingTable
           
protected  int deferredWhitespace
           
protected static byte[] encodingTable
           
protected  boolean lastCR
           
protected  boolean lastWhitespace
           
protected  int lineCount
           
protected  int lineLength
           
protected  OutputStream out
           
 
Constructor Summary
QuotedPrintableEncoder()
           
QuotedPrintableEncoder(OutputStream out)
           
QuotedPrintableEncoder(OutputStream out, int lineLength)
           
 
Method Summary
 int decode(byte[] data, int off, int length, OutputStream out)
          decode the uuencoded byte data writing it to the given output stream
 int decode(InputStream in)
           
 int decode(String data, OutputStream out)
          decode the UUEncoded String data writing it to the given output stream.
 int decodeWord(byte[] data, int off, int length, OutputStream out)
          decode the uuencoded byte data writing it to the given output stream
 int decodeWord(byte[] data, OutputStream out)
          Decode a byte array of data.
 int encode(byte[] data, int off, int length)
          encode the input data producing a UUEncoded output stream.
 int encode(byte[] data, int off, int length, OutputStream out)
          encode the input data producing a UUEncoded output stream.
 int encode(byte[] data, int off, int length, String specials)
          encode the input data producing a UUEncoded output stream.
 void encode(int ch)
           
 void encode(int ch, String specials)
          Specialized version of the decoder that handles encoding of RFC 2047 encoded word values.
 int encode(PushbackInputStream in, StringBuffer out, String specials, int limit)
          encode the input data producing a UUEncoded output stream.
 void encodeWord(byte[] data, StringBuffer out, String charset, String specials)
          Perform RFC-2047 word encoding using Base64 data encoding.
 void encodeWord(InputStream in, String charset, String specials, OutputStream out, boolean fold)
          Perform RFC-2047 word encoding using Q-P data encoding.
 void encodeWordData(byte[] data, StringBuffer out, String specials)
          Perform RFC-2047 word encoding using Q-P data encoding.
 int estimateEncodedLength(byte[] data, String specials)
          Estimate the final encoded size of a segment of data.
 void writeCharacter(int ch)
           
 void writeEncodedCharacter(int ch)
           
 void writeEOL()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

encodingTable

protected static final byte[] encodingTable

decodingTable

protected static final byte[] decodingTable

out

protected OutputStream out

bytesWritten

protected int bytesWritten

lineCount

protected int lineCount

lineLength

protected int lineLength

deferredWhitespace

protected int deferredWhitespace

cachedCharacter

protected int cachedCharacter

lastCR

protected boolean lastCR

lastWhitespace

protected boolean lastWhitespace
Constructor Detail

QuotedPrintableEncoder

public QuotedPrintableEncoder()

QuotedPrintableEncoder

public QuotedPrintableEncoder(OutputStream out)

QuotedPrintableEncoder

public QuotedPrintableEncoder(OutputStream out,
                              int lineLength)
Method Detail

encode

public int encode(byte[] data,
                  int off,
                  int length)
           throws IOException
encode the input data producing a UUEncoded output stream.

Parameters:
data - The array of byte data.
off - The starting offset within the data.
length - Length of the data to encode.
Returns:
the number of bytes produced.
Throws:
IOException

encode

public void encode(int ch)
            throws IOException
Throws:
IOException

encode

public int encode(byte[] data,
                  int off,
                  int length,
                  String specials)
           throws IOException
encode the input data producing a UUEncoded output stream.

Parameters:
data - The array of byte data.
off - The starting offset within the data.
length - Length of the data to encode.
Returns:
the number of bytes produced.
Throws:
IOException

encode

public int encode(PushbackInputStream in,
                  StringBuffer out,
                  String specials,
                  int limit)
           throws IOException
encode the input data producing a UUEncoded output stream.

Parameters:
data - The array of byte data.
off - The starting offset within the data.
length - Length of the data to encode.
Returns:
the number of bytes produced.
Throws:
IOException

encode

public void encode(int ch,
                   String specials)
            throws IOException
Specialized version of the decoder that handles encoding of RFC 2047 encoded word values. This has special handling for certain characters, but less special handling for blanks and linebreaks.

Parameters:
ch -
specials -
Throws:
IOException

encode

public int encode(byte[] data,
                  int off,
                  int length,
                  OutputStream out)
           throws IOException
encode the input data producing a UUEncoded output stream.

Specified by:
encode in interface Encoder
Parameters:
data - The array of byte data.
off - The starting offset within the data.
length - Length of the data to encode.
out - The output stream the encoded data is written to.
Returns:
the number of bytes produced.
Throws:
IOException

decode

public int decode(byte[] data,
                  int off,
                  int length,
                  OutputStream out)
           throws IOException
decode the uuencoded byte data writing it to the given output stream

Specified by:
decode in interface Encoder
Parameters:
data - The array of byte data to decode.
off - Starting offset within the array.
length - The length of data to encode.
out - The output stream used to return the decoded data.
Returns:
the number of bytes produced.
Throws:
IOException

decodeWord

public int decodeWord(byte[] data,
                      OutputStream out)
               throws IOException
Decode a byte array of data.

Parameters:
data - The data array.
out - The output stream target for the decoded data.
Returns:
The number of bytes written to the stream.
Throws:
IOException

decodeWord

public int decodeWord(byte[] data,
                      int off,
                      int length,
                      OutputStream out)
               throws IOException
decode the uuencoded byte data writing it to the given output stream

Parameters:
data - The array of byte data to decode.
off - Starting offset within the array.
length - The length of data to encode.
out - The output stream used to return the decoded data.
Returns:
the number of bytes produced.
Throws:
IOException

decode

public int decode(String data,
                  OutputStream out)
           throws IOException
decode the UUEncoded String data writing it to the given output stream.

Specified by:
decode in interface Encoder
Parameters:
data - The String data to decode.
out - The output stream to write the decoded data to.
Returns:
the number of bytes produced.
Throws:
IOException

writeEncodedCharacter

public void writeEncodedCharacter(int ch)
                           throws IOException
Throws:
IOException

writeCharacter

public void writeCharacter(int ch)
                    throws IOException
Throws:
IOException

writeEOL

public void writeEOL()
              throws IOException
Throws:
IOException

decode

public int decode(InputStream in)
           throws IOException
Throws:
IOException

encodeWord

public void encodeWord(InputStream in,
                       String charset,
                       String specials,
                       OutputStream out,
                       boolean fold)
                throws IOException
Perform RFC-2047 word encoding using Q-P data encoding.

Parameters:
in - The source for the encoded data.
charset - The charset tag to be added to each encoded data section.
specials - The set of special characters that we require to encoded.
out - The output stream where the encoded data is to be written.
fold - Controls whether separate sections of encoded data are separated by linebreaks or whitespace.
Throws:
IOException

encodeWord

public void encodeWord(byte[] data,
                       StringBuffer out,
                       String charset,
                       String specials)
                throws IOException
Perform RFC-2047 word encoding using Base64 data encoding.

Parameters:
in - The source for the encoded data.
charset - The charset tag to be added to each encoded data section.
out - The output stream where the encoded data is to be written.
fold - Controls whether separate sections of encoded data are separated by linebreaks or whitespace.
Throws:
IOException

encodeWordData

public void encodeWordData(byte[] data,
                           StringBuffer out,
                           String specials)
                    throws IOException
Perform RFC-2047 word encoding using Q-P data encoding.

Parameters:
in - The source for the encoded data.
charset - The charset tag to be added to each encoded data section.
specials - The set of special characters that we require to encoded.
out - The output stream where the encoded data is to be written.
fold - Controls whether separate sections of encoded data are separated by linebreaks or whitespace.
Throws:
IOException

estimateEncodedLength

public int estimateEncodedLength(byte[] data,
                                 String specials)
Estimate the final encoded size of a segment of data. This is used to ensure that the encoded blocks do not get split across a unicode character boundary and that the encoding will fit within the bounds of a mail header line.

Parameters:
data - The data we're anticipating encoding.
Returns:
The size of the byte data in encoded form.


Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.