Package com.sun.mail.iap
Class Response
- java.lang.Object
 - 
- com.sun.mail.iap.Response
 
 
- 
- Direct Known Subclasses:
 IMAPResponse
public class Response extends java.lang.ObjectThis class represents a response obtained from the input stream of an IMAP server. 
- 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ResponsebyeResponse(java.lang.Exception ex)Return a Response object that looks like a BYE protocol response.java.lang.ExceptiongetException()Return the exception for a synthetic BYE response.java.lang.StringgetRest()Return the rest of the response as a string, usually used to return the arbitrary message text after a NO response.java.lang.StringgetTag()Return the tag, if this is a tagged statement.intgetType()booleanisBAD()booleanisBYE()booleanisContinuation()booleanisNextNonSpace(char c)Skip past any spaces.booleanisNO()booleanisOK()booleanisSynthetic()booleanisTagged()booleanisUnTagged()bytepeekByte()java.lang.StringreadAtom()Extract an ATOM, starting at the current position.java.lang.StringreadAtomString()Extract an ASTRING, starting at the current position and return as a String.java.lang.String[]readAtomStringList()bytereadByte()Return the next byte from this Statement.ByteArrayreadByteArray()Extract a NSTRING, starting at the current position.java.io.ByteArrayInputStreamreadBytes()Extract a NSTRING, starting at the current position.longreadLong()Extract a long number, starting at the current position.intreadNumber()Extract an integer, starting at the current position.java.lang.StringreadString()Extract a NSTRING, starting at the current position.java.lang.StringreadString(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()voidreset()Reset pointer to beginning of response.voidskip(int count)voidskipSpaces()voidskipToken()Skip to the next space, for use in error recovery while parsing.booleansupportsUtf8()Does the server support UTF-8?java.lang.StringtoString() 
 - 
 
- 
- 
Field Detail
- 
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(java.lang.String s, boolean supportsUtf8)Constructor for testing.- Parameters:
 s- the response stringsupportsUtf8- allow UTF-8 in response?- Since:
 - JavaMail 1.6.0
 
 
- 
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- for I/O errorsProtocolException- for protocol failures
 
- 
Response
public Response(Response r)
Copy constructor.- Parameters:
 r- the Response to copy
 
 - 
 
- 
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.- Parameters:
 ex- the exception- Returns:
 - the synthetic Response object
 
 
- 
supportsUtf8
public boolean supportsUtf8()
Does the server support UTF-8?- Returns:
 - true if the server supports UTF-8
 - Since:
 - JavaMail 1.6.0
 
 
- 
skipSpaces
public void skipSpaces()
 
- 
isNextNonSpace
public boolean isNextNonSpace(char c)
Skip past any spaces. If the next non-space character is c, consume it and return true. Otherwise stop at that point and return false.- Parameters:
 c- the character to look for- Returns:
 - true if the character is found
 
 
- 
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
 
 
- 
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 [].- Parameters:
 delim- the delimiter character- Returns:
 - the string
 
 
- 
readStringList
public java.lang.String[] readStringList()
 
- 
readAtomStringList
public java.lang.String[] readAtomStringList()
 
- 
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 (plus ']'). Any errors in parsing returns null ASTRING := QuotedString | Literal | 1*ASTRING_CHAR- 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.- Returns:
 - the rest of the response
 
 
- 
getException
public java.lang.Exception getException()
Return the exception for a synthetic BYE response.- Returns:
 - the exception
 - Since:
 - JavaMail 1.5.4
 
 
- 
reset
public void reset()
Reset pointer to beginning of response. 
- 
toString
public java.lang.String toString()
- Overrides:
 toStringin classjava.lang.Object
 
 - 
 
 -