com.sun.mail.iap
Class Response

java.lang.Object
  extended by com.sun.mail.iap.Response
Direct Known Subclasses:
IMAPResponse

public class Response
extends java.lang.Object

This class represents a response obtained from the input stream of an IMAP server.

Version:
1.1, 97/11/10
Author:
John Mani

Field Summary
static int BAD
           
protected  byte[] buffer
           
static int BYE
           
static int CONTINUATION
           
protected  int index
           
static int NO
           
static int OK
           
protected  int pindex
           
protected  int size
           
static int SYNTHETIC
           
protected  java.lang.String tag
           
static int TAG_MASK
           
static int TAGGED
           
protected  int type
           
static int TYPE_MASK
           
static int UNTAGGED
           
 
Constructor Summary
Response(Protocol p)
          Read a new Response from the given Protocol
Response(Response r)
          Copy constructor.
Response(java.lang.String s)
           
 
Method Summary
static Response byeResponse(java.lang.Exception ex)
          Return a Response object that looks like a BYE protocol response.
 java.lang.String getRest()
          Return the rest of the response as a string, usually used to return the arbitrary message text after a NO response.
 java.lang.String getTag()
          Return the tag, if this is a tagged statement.
 int getType()
           
 boolean isBAD()
           
 boolean isBYE()
           
 boolean isContinuation()
           
 boolean isNO()
           
 boolean isOK()
           
 boolean isSynthetic()
           
 boolean isTagged()
           
 boolean isUnTagged()
           
 byte peekByte()
           
 java.lang.String readAtom()
          Extract an ATOM, starting at the current position.
 java.lang.String readAtom(char delim)
          Extract an ATOM, but stop at the additional delimiter (if not NUL).
 java.lang.String readAtomString()
          Extract an ASTRING, starting at the current position and return as a String.
 byte readByte()
          Return the next byte from this Statement.
 ByteArray readByteArray()
          Extract a NSTRING, starting at the current position.
 java.io.ByteArrayInputStream readBytes()
          Extract a NSTRING, starting at the current position.
 long readLong()
          Extract a long number, starting at the current position.
 int readNumber()
          Extract an integer, starting at the current position.
 java.lang.String readString()
          Extract a NSTRING, starting at the current position.
 java.lang.String readString(char delim)
          Read a string as an arbitrary sequence of characters, stopping at the delimiter Used to read part of a response code inside [].
 java.lang.String[] readStringList()
           
 void reset()
          Reset pointer to beginning of response.
 void skip(int count)
           
 void skipSpaces()
           
 void skipToken()
          Skip to the next space, for use in error recovery while parsing.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

index

protected int index

pindex

protected int pindex

size

protected int size

buffer

protected byte[] buffer

type

protected int type

tag

protected java.lang.String tag

TAG_MASK

public static final int TAG_MASK
See Also:
Constant Field Values

CONTINUATION

public static final int CONTINUATION
See Also:
Constant Field Values

TAGGED

public static final int TAGGED
See Also:
Constant Field Values

UNTAGGED

public static final int UNTAGGED
See Also:
Constant Field Values

TYPE_MASK

public static final int TYPE_MASK
See Also:
Constant Field Values

OK

public static final int OK
See Also:
Constant Field Values

NO

public static final int NO
See Also:
Constant Field Values

BAD

public static final int BAD
See Also:
Constant Field Values

BYE

public static final int BYE
See Also:
Constant Field Values

SYNTHETIC

public static final int SYNTHETIC
See Also:
Constant Field Values
Constructor Detail

Response

public Response(java.lang.String s)

Response

public Response(Protocol p)
         throws java.io.IOException,
                ProtocolException
Read a new Response from the given Protocol

Parameters:
p - the Protocol object
Throws:
java.io.IOException
ProtocolException

Response

public Response(Response r)
Copy constructor.

Method Detail

byeResponse

public static Response byeResponse(java.lang.Exception ex)
Return a Response object that looks like a BYE protocol response. Include the details of the exception in the response string.


skipSpaces

public void skipSpaces()

skipToken

public void skipToken()
Skip to the next space, for use in error recovery while parsing.


skip

public void skip(int count)

peekByte

public byte peekByte()

readByte

public byte readByte()
Return the next byte from this Statement.

Returns:
the next byte.

readAtom

public java.lang.String readAtom()
Extract an ATOM, starting at the current position. Updates the internal index to beyond the Atom.

Returns:
an Atom

readAtom

public java.lang.String readAtom(char delim)
Extract an ATOM, but stop at the additional delimiter (if not NUL). Used to parse a response code inside [].


readString

public java.lang.String readString(char delim)
Read a string as an arbitrary sequence of characters, stopping at the delimiter Used to read part of a response code inside [].


readStringList

public java.lang.String[] readStringList()

readNumber

public int readNumber()
Extract an integer, starting at the current position. Updates the internal index to beyond the number. Returns -1 if a number was not found.

Returns:
a number

readLong

public long readLong()
Extract a long number, starting at the current position. Updates the internal index to beyond the number. Returns -1 if a long number was not found.

Returns:
a long

readString

public java.lang.String readString()
Extract a NSTRING, starting at the current position. Return it as a String. The sequence 'NIL' is returned as null NSTRING := QuotedString | Literal | "NIL"

Returns:
a String

readBytes

public java.io.ByteArrayInputStream readBytes()
Extract a NSTRING, starting at the current position. Return it as a ByteArrayInputStream. The sequence 'NIL' is returned as null NSTRING := QuotedString | Literal | "NIL"

Returns:
a ByteArrayInputStream

readByteArray

public ByteArray readByteArray()
Extract a NSTRING, starting at the current position. Return it as a ByteArray. The sequence 'NIL' is returned as null NSTRING := QuotedString | Literal | "NIL"

Returns:
a ByteArray

readAtomString

public java.lang.String readAtomString()
Extract an ASTRING, starting at the current position and return as a String. An ASTRING can be a QuotedString, a Literal or an Atom Any errors in parsing returns null ASTRING := QuotedString | Literal | Atom

Returns:
a String

getType

public int getType()

isContinuation

public boolean isContinuation()

isTagged

public boolean isTagged()

isUnTagged

public boolean isUnTagged()

isOK

public boolean isOK()

isNO

public boolean isNO()

isBAD

public boolean isBAD()

isBYE

public boolean isBYE()

isSynthetic

public boolean isSynthetic()

getTag

public java.lang.String getTag()
Return the tag, if this is a tagged statement.

Returns:
tag of this tagged statement

getRest

public java.lang.String getRest()
Return the rest of the response as a string, usually used to return the arbitrary message text after a NO response.


reset

public void reset()
Reset pointer to beginning of response.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2011. All Rights Reserved.