Top Description Fields Constructors Methods
com.sun.mail.util

public Class UUDecoderStream

extends FilterInputStream
Class Inheritance
Imports
java.io.*

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.
Authors
John Mani, Bill Shannon

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private boolean
private boolean
private boolean
private boolean
private int
private LineInputStream
private int
private String
private String
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
UUDecoderStream(InputStream
the input stream
in
)

Create a UUdecoder that decodes the specified input stream.

public
UUDecoderStream(InputStream
the input stream
in
,
boolean
ignore errors?
ignoreErrors
,
boolean
ignore missing begin or end?
ignoreMissingBeginEnd
)

Create a UUdecoder that decodes the specified input stream.

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.
private boolean
public int

Returns:

permission mode of source file
getMode
()

Get the "mode" field from the prefix.

public String

Returns:

name of decoded file
getName
()

Get the "name" field from the prefix.

public boolean
markSupported()

Overrides java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.
public int

Returns:

next byte of data, or -1 if the end of stream is reached.
read
()

Overrides java.io.FilterInputStream.read.

Read the next decoded byte from this input stream.
public int
read(byte[]
the buffer into which the data is read.
buf
,
int
the start offset in array b at which the data is written.
off
,
int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.
private void
readPrefix()

UUencoded streams start off with the line: "begin <mode> <filename>" Search for this prefix and gobble it up.

Inherited from java.io.FilterInputStream:
closemarkreadresetskip

Field Detail

bufferback to summary
private byte[] buffer
bufsizeback to summary
private int bufsize
gotEndback to summary
private boolean gotEnd
gotPrefixback to summary
private boolean gotPrefix
ignoreErrorsback to summary
private boolean ignoreErrors
ignoreMissingBeginEndback to summary
private boolean ignoreMissingBeginEnd
indexback to summary
private int index
linback to summary
private LineInputStream lin
modeback to summary
private int mode
nameback to summary
private String name
readAheadback to summary
private String readAhead

Constructor Detail

UUDecoderStreamback to summary
public UUDecoderStream(InputStream in)

Create a UUdecoder that decodes the specified input stream. The System property mail.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 property mail.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:InputStream

the input stream

UUDecoderStreamback to summary
public UUDecoderStream(InputStream in, boolean ignoreErrors, boolean ignoreMissingBeginEnd)

Create a UUdecoder that decodes the specified input stream.

Parameters
in:InputStream

the input stream

ignoreErrors:boolean

ignore errors?

ignoreMissingBeginEnd:boolean

ignore missing begin or end?

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.FilterInputStream.available.

Doc from java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Returns:int

an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
decodeback to summary
private boolean decode() throws IOException
getModeback to summary
public int getMode() throws IOException

Get the "mode" field from the prefix. This is the permission mode of the source file.

Returns:int

permission mode of source file

Exceptions
IOException:
if an I/O error occurs.
getNameback to summary
public String getName() throws IOException

Get the "name" field from the prefix. This is meant to be the pathname of the decoded file

Returns:String

name of decoded file

Exceptions
IOException:
if an I/O error occurs.
markSupportedback to summary
public boolean markSupported()

Overrides java.io.FilterInputStream.markSupported.

Doc from java.io.FilterInputStream.markSupported.

Tests if this input stream supports the mark and reset methods.

Returns:boolean

true if this stream type supports the mark and reset method; false otherwise.

Annotations
@Override
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Read the next decoded byte from this input stream. The byte is returned as an int in the range 0 to 255. 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.

Returns:int

next byte of data, or -1 if the end of stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
See Also
java.io.FilterInputStream#in
readback to summary
public int read(byte[] buf, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
buf:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readPrefixback to summary
private void readPrefix() throws IOException

UUencoded streams start off with the line: "begin " Search for this prefix and gobble it up.