Package org.apache.james.mime4j.codec
Class Base64InputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.james.mime4j.codec.Base64InputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class Base64InputStream extends java.io.InputStream
Performs Base-64 decoding on an underlying stream.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>>
_recyclerRef
private static int[]
BASE64_DECODE
private static byte
BASE64_PAD
private boolean
closed
private RecycledByteArrayBuffer
decodedBuf
private byte[]
encoded
private static int
ENCODED_BUFFER_SIZE
private boolean
eof
private static int
EOF
private java.io.InputStream
in
private DecodeMonitor
monitor
private int
position
private byte[]
singleByte
private int
size
-
Constructor Summary
Constructors Modifier Constructor Description protected
Base64InputStream(int bufsize, java.io.InputStream in, DecodeMonitor monitor)
Base64InputStream(java.io.InputStream in)
Base64InputStream(java.io.InputStream in, boolean strict)
Base64InputStream(java.io.InputStream in, DecodeMonitor monitor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
private int
decodePad(int data, int sextets, byte[] buffer, int index, int end)
static BufferRecycler
getBufferRecycler()
private void
handleUnexpecedPad(int sextets)
private void
handleUnexpectedEof(int sextets)
int
read()
int
read(byte[] buffer)
int
read(byte[] buffer, int offset, int length)
private int
read0(byte[] buffer, int off, int len)
-
-
-
Field Detail
-
_recyclerRef
protected static final java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>> _recyclerRef
-
ENCODED_BUFFER_SIZE
private static final int ENCODED_BUFFER_SIZE
- See Also:
- Constant Field Values
-
BASE64_DECODE
private static final int[] BASE64_DECODE
-
BASE64_PAD
private static final byte BASE64_PAD
- See Also:
- Constant Field Values
-
EOF
private static final int EOF
- See Also:
- Constant Field Values
-
singleByte
private final byte[] singleByte
-
in
private final java.io.InputStream in
-
encoded
private final byte[] encoded
-
decodedBuf
private final RecycledByteArrayBuffer decodedBuf
-
position
private int position
-
size
private int size
-
closed
private boolean closed
-
eof
private boolean eof
-
monitor
private final DecodeMonitor monitor
-
-
Constructor Detail
-
Base64InputStream
public Base64InputStream(java.io.InputStream in, DecodeMonitor monitor)
-
Base64InputStream
protected Base64InputStream(int bufsize, java.io.InputStream in, DecodeMonitor monitor)
-
Base64InputStream
public Base64InputStream(java.io.InputStream in)
-
Base64InputStream
public Base64InputStream(java.io.InputStream in, boolean strict)
-
-
Method Detail
-
getBufferRecycler
public static BufferRecycler getBufferRecycler()
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] buffer) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] buffer, int offset, int length) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- 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.InputStream
- Throws:
java.io.IOException
-
read0
private int read0(byte[] buffer, int off, int len) throws java.io.IOException
- Throws:
java.io.IOException
-
decodePad
private int decodePad(int data, int sextets, byte[] buffer, int index, int end) throws java.io.IOException
- Throws:
java.io.IOException
-
handleUnexpectedEof
private void handleUnexpectedEof(int sextets) throws java.io.IOException
- Throws:
java.io.IOException
-
handleUnexpecedPad
private void handleUnexpecedPad(int sextets) throws java.io.IOException
- Throws:
java.io.IOException
-
-