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

public Class IMAPInputStream

extends InputStream
Class Inheritance
Imports
java.io.*, javax.mail.*, com.sun.mail.imap.protocol.*, com.sun.mail.iap.*, com.sun.mail.util.FolderClosedIOException, .MessageRemovedIOException

This class implements an IMAP data stream.
Author
John Mani

Field Summary

Modifier and TypeField and Description
private int
private byte[]
private int
private int
private boolean
private int
private IMAPMessage
private boolean
private int
private ByteArray
private String
private static final int

Constructor Summary

AccessConstructor and Description
public
IMAPInputStream(IMAPMessage
the IMAPMessage the data will come from
msg
,
String
the IMAP section/part identifier for the data
section
,
int
the number of bytes in this section
max
,
boolean
peek instead of fetch?
peek
)

Create an IMAPInputStream.

Method Summary

Modifier and TypeMethod and Description
public synchronized int
available()

Overrides java.io.InputStream.available.

Returns the number of bytes that can be read from this input stream without blocking.
private void
checkSeen()

Normally the SEEN flag will have been set by now, but if not, force it to be set (as long as the folder isn't open read-only and we're not peeking).

private void
fill()

Fetch more data from the server.

private void
forceCheckExpunged()

Do a NOOP to force any untagged EXPUNGE responses and then check if this message is expunged.

public synchronized int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from this buffered input stream.
public synchronized int
read(byte[]
the buffer into which the data is read.
b
,
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.InputStream.read.

Reads up to len bytes of data from this input stream into the given buffer.
public int
read(byte[]
the buffer into which the data is read.
b
)

Overrides java.io.InputStream.read.

Reads up to b.length bytes of data from this input stream into an array of bytes.
Inherited from java.io.InputStream:
closemarkmarkSupportednullInputStreamreadAllBytesreadNBytesreadNBytesresetskipskipNBytestransferTo

Field Detail

blksizeback to summary
private int blksize
bufback to summary
private byte[] buf
bufcountback to summary
private int bufcount
bufposback to summary
private int bufpos
lastBufferback to summary
private boolean lastBuffer
maxback to summary
private int max
msgback to summary
private IMAPMessage msg
peekback to summary
private boolean peek
posback to summary
private int pos
readbufback to summary
private ByteArray readbuf
sectionback to summary
private String section
slopback to summary
private static final int slop

Constructor Detail

IMAPInputStreamback to summary
public IMAPInputStream(IMAPMessage msg, String section, int max, boolean peek)

Create an IMAPInputStream.

Parameters
msg:IMAPMessage

the IMAPMessage the data will come from

section:String

the IMAP section/part identifier for the data

max:int

the number of bytes in this section

peek:boolean

peek instead of fetch?

Method Detail

availableback to summary
public synchronized int available() throws IOException

Overrides java.io.InputStream.available.

Returns the number of bytes that can be read from this input stream without blocking.

Returns:int

Doc from java.io.InputStream.available.

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

Annotations
@Override
Exceptions
IOException:

Doc from java.io.InputStream.available.

if an I/O error occurs.

checkSeenback to summary
private void checkSeen()

Normally the SEEN flag will have been set by now, but if not, force it to be set (as long as the folder isn't open read-only and we're not peeking). And of course, if there's no folder (e.g., a nested message) don't do anything.

fillback to summary
private void fill() throws IOException

Fetch more data from the server. This method assumes that all data has already been read in, hence bufpos > bufcount.

forceCheckExpungedback to summary
private void forceCheckExpunged() throws MessageRemovedIOException, FolderClosedIOException

Do a NOOP to force any untagged EXPUNGE responses and then check if this message is expunged.

readback to summary
public synchronized int read() throws IOException

Implements abstract java.io.InputStream.read.

Reads the next byte of data from this buffered input stream. If no byte is available, the value -1 is returned.

Returns:int

Doc from java.io.InputStream.read.

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

Annotations
@Override
Exceptions
IOException:

Doc from java.io.InputStream.read.

if an I/O error occurs.

readback to summary
public synchronized int read(byte[] b, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Reads up to len bytes of data from this input stream into the given buffer.

Returns the total number of bytes read into the buffer, or -1 if there is no more data.

Note that this method mimics the "weird !" semantics of BufferedInputStream in that the number of bytes actually returned may be less that the requested value. So callers of this routine should be aware of this and must check the return value to insure that they have obtained the requisite number of bytes.

Parameters
b:byte[]

Doc from java.io.InputStream.read.

the buffer into which the data is read.

off:int

Doc from java.io.InputStream.read.

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

len:int

Doc from java.io.InputStream.read.

the maximum number of bytes to read.

Returns:int

Doc from java.io.InputStream.read.

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:

Doc from java.io.InputStream.read.

If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.

readback to summary
public int read(byte[] b) throws IOException

Overrides java.io.InputStream.read.

Reads up to b.length bytes of data from this input stream into an array of bytes.

Returns the total number of bytes read into the buffer, or -1 is there is no more data.

Note that this method mimics the "weird !" semantics of BufferedInputStream in that the number of bytes actually returned may be less that the requested value. So callers of this routine should be aware of this and must check the return value to insure that they have obtained the requisite number of bytes.

Parameters
b:byte[]

Doc from java.io.InputStream.read.

the buffer into which the data is read.

Returns:int

Doc from java.io.InputStream.read.

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:

Doc from java.io.InputStream.read.

If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.