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.FilterOutputStream
Performs 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 boolean
binary
private boolean
closed
private static byte
CR
private static int
DEFAULT_BUFFER_SIZE
private static byte
DOT
private static byte
EQ
private static byte[]
HEX_DIGITS
private static byte
LF
private int
nextSoftBreak
private byte[]
outBuffer
private int
outputIndex
private boolean
pendingCR
private boolean
pendingSpace
private boolean
pendingTab
private static byte
QUOTED_PRINTABLE_LAST_PLAIN
private static int
QUOTED_PRINTABLE_MAX_LINE_LENGTH
private static int
QUOTED_PRINTABLE_OCTETS_PER_ESCAPE
private byte[]
singleByte
private static byte
SP
private static byte
TB
-
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 void
clearPending()
void
close()
private void
completeEncoding()
private void
encode(byte next)
private void
encodeChunk(byte[] buffer, int off, int len)
private void
escape(byte next)
void
flush()
(package private) void
flushOutput()
private void
lineBreak()
private void
plain(byte next)
private void
softBreak()
private void
write(byte next)
void
write(byte[] b, int off, int len)
void
write(int b)
private void
writePending()
-
-
-
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:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(int b) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
-