Package org.apache.james.mime4j.codec
Class QuotedPrintableOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- org.apache.james.mime4j.codec.QuotedPrintableOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class QuotedPrintableOutputStream extends java.io.FilterOutputStreamPerforms Quoted-Printable encoding on an underlying stream. Encodes every "required" char plus the dot ".". We encode the dot by default because this is a workaround for some "filter"/"antivirus" "old mua" having issues with dots at the beginning or the end of a qp encode line (maybe a bad dot-destuffing algo).
-
-
Field Summary
Fields Modifier and Type Field Description private booleanbinaryprivate booleanclosedprivate static byteCRprivate static intDEFAULT_BUFFER_SIZEprivate static byteDOTprivate static byteEQprivate static byte[]HEX_DIGITSprivate static byteLFprivate intnextSoftBreakprivate byte[]outBufferprivate intoutputIndexprivate booleanpendingCRprivate booleanpendingSpaceprivate booleanpendingTabprivate static byteQUOTED_PRINTABLE_LAST_PLAINprivate static intQUOTED_PRINTABLE_MAX_LINE_LENGTHprivate static intQUOTED_PRINTABLE_OCTETS_PER_ESCAPEprivate byte[]singleByteprivate static byteSPprivate static byteTB
-
Constructor Summary
Constructors Constructor Description QuotedPrintableOutputStream(int bufsize, java.io.OutputStream out, boolean binary)QuotedPrintableOutputStream(java.io.OutputStream out, boolean binary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidclearPending()voidclose()private voidcompleteEncoding()private voidencode(byte next)private voidencodeChunk(byte[] buffer, int off, int len)private voidescape(byte next)voidflush()(package private) voidflushOutput()private voidlineBreak()private voidplain(byte next)private voidsoftBreak()private voidwrite(byte next)voidwrite(byte[] b, int off, int len)voidwrite(int b)private voidwritePending()
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE
- See Also:
- Constant Field Values
-
TB
private static final byte TB
- See Also:
- Constant Field Values
-
SP
private static final byte SP
- See Also:
- Constant Field Values
-
EQ
private static final byte EQ
- See Also:
- Constant Field Values
-
DOT
private static final byte DOT
- See Also:
- Constant Field Values
-
CR
private static final byte CR
- See Also:
- Constant Field Values
-
LF
private static final byte LF
- See Also:
- Constant Field Values
-
QUOTED_PRINTABLE_LAST_PLAIN
private static final byte QUOTED_PRINTABLE_LAST_PLAIN
- See Also:
- Constant Field Values
-
QUOTED_PRINTABLE_MAX_LINE_LENGTH
private static final int QUOTED_PRINTABLE_MAX_LINE_LENGTH
- See Also:
- Constant Field Values
-
QUOTED_PRINTABLE_OCTETS_PER_ESCAPE
private static final int QUOTED_PRINTABLE_OCTETS_PER_ESCAPE
- See Also:
- Constant Field Values
-
HEX_DIGITS
private static final byte[] HEX_DIGITS
-
outBuffer
private final byte[] outBuffer
-
binary
private final boolean binary
-
pendingSpace
private boolean pendingSpace
-
pendingTab
private boolean pendingTab
-
pendingCR
private boolean pendingCR
-
nextSoftBreak
private int nextSoftBreak
-
outputIndex
private int outputIndex
-
closed
private boolean closed
-
singleByte
private final byte[] singleByte
-
-
Method Detail
-
encodeChunk
private void encodeChunk(byte[] buffer, int off, int len) throws java.io.IOException- Throws:
java.io.IOException
-
completeEncoding
private void completeEncoding() throws java.io.IOException- Throws:
java.io.IOException
-
writePending
private void writePending() throws java.io.IOException- Throws:
java.io.IOException
-
clearPending
private void clearPending() throws java.io.IOException- Throws:
java.io.IOException
-
encode
private void encode(byte next) throws java.io.IOException- Throws:
java.io.IOException
-
plain
private void plain(byte next) throws java.io.IOException- Throws:
java.io.IOException
-
escape
private void escape(byte next) throws java.io.IOException- Throws:
java.io.IOException
-
write
private void write(byte next) throws java.io.IOException- Throws:
java.io.IOException
-
softBreak
private void softBreak() throws java.io.IOException- Throws:
java.io.IOException
-
lineBreak
private void lineBreak() throws java.io.IOException- Throws:
java.io.IOException
-
flushOutput
void flushOutput() throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
-