Package org.jvnet.mimepull
Class UUDecoderStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.jvnet.mimepull.UUDecoderStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
final class UUDecoderStream extends java.io.FilterInputStream
This class implements a UUDecoder. It is implemented as a FilterInputStream, so one can just wrap this class around any input stream and read bytes from this filter. The decoding is done as the bytes are read out.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
buffer
private int
bufsize
private boolean
gotEnd
private boolean
gotPrefix
private boolean
ignoreErrors
private boolean
ignoreMissingBeginEnd
private int
index
private LineInputStream
lin
private int
mode
private java.lang.String
name
private java.lang.String
readAhead
-
Constructor Summary
Constructors Constructor Description UUDecoderStream(java.io.InputStream in)
Create a UUdecoder that decodes the specified input stream.UUDecoderStream(java.io.InputStream in, boolean ignoreErrors, boolean ignoreMissingBeginEnd)
Create a UUdecoder that decodes the specified input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
private boolean
decode()
int
getMode()
Get the "mode" field from the prefix.java.lang.String
getName()
Get the "name" field from the prefix.boolean
markSupported()
int
read()
Read the next decoded byte from this input stream.int
read(byte[] buf, int off, int len)
private void
readPrefix()
UUencoded streams start off with the line: "begin" Search for this prefix and gobble it up.
-
-
-
Field Detail
-
name
private java.lang.String name
-
mode
private int mode
-
buffer
private byte[] buffer
-
bufsize
private int bufsize
-
index
private int index
-
gotPrefix
private boolean gotPrefix
-
gotEnd
private boolean gotEnd
-
lin
private LineInputStream lin
-
ignoreErrors
private boolean ignoreErrors
-
ignoreMissingBeginEnd
private boolean ignoreMissingBeginEnd
-
readAhead
private java.lang.String readAhead
-
-
Constructor Detail
-
UUDecoderStream
public UUDecoderStream(java.io.InputStream in)
Create a UUdecoder that decodes the specified input stream. The System propertymail.mime.uudecode.ignoreerrors
controls whether errors in the encoded data cause an exception or are ignored. The default is false (errors cause exception). The System propertymail.mime.uudecode.ignoremissingbeginend
controls whether a missing begin or end line cause an exception or are ignored. The default is false (errors cause exception).- Parameters:
in
- the input stream
-
UUDecoderStream
public UUDecoderStream(java.io.InputStream in, boolean ignoreErrors, boolean ignoreMissingBeginEnd)
Create a UUdecoder that decodes the specified input stream.- Parameters:
in
- the input streamignoreErrors
- ignore errors?ignoreMissingBeginEnd
- ignore missing begin or end?
-
-
Method Detail
-
read
public int read() throws java.io.IOException
Read the next decoded byte from this input stream. The byte is returned as anint
in the range0
to255
. If no byte is available because the end of the stream has been reached, the value-1
is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.- Overrides:
read
in classjava.io.FilterInputStream
- Returns:
- next byte of data, or
-1
if the end of stream is reached. - Throws:
java.io.IOException
- if an I/O error occurs.- See Also:
FilterInputStream.in
-
read
public int read(byte[] buf, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.FilterInputStream
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
getName
public java.lang.String getName() throws java.io.IOException
Get the "name" field from the prefix. This is meant to be the pathname of the decoded file- Returns:
- name of decoded file
- Throws:
java.io.IOException
- if an I/O error occurs.
-
getMode
public int getMode() throws java.io.IOException
Get the "mode" field from the prefix. This is the permission mode of the source file.- Returns:
- permission mode of source file
- Throws:
java.io.IOException
- if an I/O error occurs.
-
readPrefix
private void readPrefix() throws java.io.IOException
UUencoded streams start off with the line: "begin" Search for this prefix and gobble it up. - Throws:
java.io.IOException
-
decode
private boolean decode() throws java.io.IOException
- Throws:
java.io.IOException
-
-