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

public Class Response

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.mail.imap.protocol.IMAPResponse
Imports
java.io.*, java.util.*, java.nio.charset.StandardCharsets, com.sun.mail.util.ASCIIUtility

This class represents a response obtained from the input stream of an IMAP server.
Authors
John Mani, Bill Shannon

Field Summary

Modifier and TypeField and Description
private static String
ASTRING_CHAR_DELIM

An ASTRING_CHAR is any CHAR delimited by: SPACE | CTL | '(' | ')' | '{' | '%' | '*' | '"' | '\' (CTL is handled in readDelimString.)

private static String
ATOM_CHAR_DELIM

An ATOM is any CHAR delimited by: SPACE | CTL | '(' | ')' | '{' | '%' | '*' | '"' | '\' | ']' (CTL is handled in readDelimString.)

public static final int
protected byte[]
public static final int
public static final int
protected Exception
private static final int
protected int
public static final int
public static final int
protected int
protected int
public static final int
protected String
public static final int
public static final int
protected int
public static final int
public static final int
protected boolean

Constructor Summary

AccessConstructor and Description
public
public
Response(String
the response string
s
,
boolean
allow UTF-8 in response?
supportsUtf8
)

Constructor for testing.

public
Response(Protocol
the Protocol object
p
)

Read a new Response from the given Protocol

public
Response(Response
the Response to copy
r
)

Copy constructor.

Method Summary

Modifier and TypeMethod and Description
public static Response

Returns:

the synthetic Response object
byeResponse
(Exception
the exception
ex
)

Return a Response object that looks like a BYE protocol response.

public Exception

Returns:

the exception
getException
()

Return the exception for a synthetic BYE response.

public String

Returns:

the rest of the response
getRest
()

Return the rest of the response as a string, usually used to return the arbitrary message text after a NO response.

public String

Returns:

tag of this tagged statement
getTag
()

Return the tag, if this is a tagged statement.

public int
public boolean
public boolean
public boolean
public boolean

Returns:

true if the character is found
isNextNonSpace
(char
the character to look for
c
)

Skip past any spaces.

public boolean
isNO()

public boolean
isOK()

public boolean
public boolean
public boolean
private void
private Object
parseString(boolean parseAtoms, boolean returnString)

Generic parsing routine that can parse out a Quoted-String, Literal or Atom and return the parsed token as a String or a ByteArray.

public byte
public String

Returns:

an Atom
readAtom
()

Extract an ATOM, starting at the current position.

public String

Returns:

a String
readAtomString
()

Extract an ASTRING, starting at the current position and return as a String.

public String[]
public byte

Returns:

the next byte
readByte
()

Return the next byte from this Statement.

public ByteArray

Returns:

a ByteArray
readByteArray
()

Extract a NSTRING, starting at the current position.

public ByteArrayInputStream

Returns:

a ByteArrayInputStream
readBytes
()

Extract a NSTRING, starting at the current position.

private String
readDelimString(String delim)

Extract a string stopping at control characters or any character in delim.

public long

Returns:

a long
readLong
()

Extract a long number, starting at the current position.

public int

Returns:

a number
readNumber
()

Extract an integer, starting at the current position.

public String

Returns:

the string
readString
(char
the delimiter character
delim
)

Read a string as an arbitrary sequence of characters, stopping at the delimiter Used to read part of a response code inside [].

public String

Returns:

a String
readString
()

Extract a NSTRING, starting at the current position.

public String[]
private String[]
readStringList(boolean atom)

public void
reset()

Reset pointer to beginning of response.

public void
skip(int count)

public void
public void
skipToken()

Skip to the next space, for use in error recovery while parsing.

public boolean

Returns:

true if the server supports UTF-8
supportsUtf8
()

Does the server support UTF-8?

private String
toString(byte[] buffer, int start, int end)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ASTRING_CHAR_DELIMback to summary
private static String ASTRING_CHAR_DELIM

An ASTRING_CHAR is any CHAR delimited by: SPACE | CTL | '(' | ')' | '{' | '%' | '*' | '"' | '\' (CTL is handled in readDelimString.)

ATOM_CHAR_DELIMback to summary
private static String ATOM_CHAR_DELIM

An ATOM is any CHAR delimited by: SPACE | CTL | '(' | ')' | '{' | '%' | '*' | '"' | '\' | ']' (CTL is handled in readDelimString.)

BADback to summary
public static final int BAD
bufferback to summary
protected byte[] buffer
BYEback to summary
public static final int BYE
CONTINUATIONback to summary
public static final int CONTINUATION
exback to summary
protected Exception ex
Since
JavaMail 1.5.4
incrementback to summary
private static final int increment
indexback to summary
protected int index
NOback to summary
public static final int NO
OKback to summary
public static final int OK
pindexback to summary
protected int pindex
sizeback to summary
protected int size
SYNTHETICback to summary
public static final int SYNTHETIC
tagback to summary
protected String tag
TAG_MASKback to summary
public static final int TAG_MASK
TAGGEDback to summary
public static final int TAGGED
typeback to summary
protected int type
TYPE_MASKback to summary
public static final int TYPE_MASK
UNTAGGEDback to summary
public static final int UNTAGGED
utf8back to summary
protected boolean utf8

Constructor Detail

Responseback to summary
public Response(String s)
Responseback to summary
public Response(String s, boolean supportsUtf8)

Constructor for testing.

Parameters
s:String

the response string

supportsUtf8:boolean

allow UTF-8 in response?

Since
JavaMail 1.6.0
Responseback to summary
public Response(Protocol p) throws IOException, ProtocolException

Read a new Response from the given Protocol

Parameters
p:Protocol

the Protocol object

Exceptions
IOException:
for I/O errors
ProtocolException:
for protocol failures
Responseback to summary
public Response(Response r)

Copy constructor.

Parameters
r:Response

the Response to copy

Method Detail

byeResponseback to summary
public static Response byeResponse(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:Exception

the exception

Returns:Response

the synthetic Response object

getExceptionback to summary
public Exception getException()

Return the exception for a synthetic BYE response.

Returns:Exception

the exception

Since
JavaMail 1.5.4
getRestback to summary
public String getRest()

Return the rest of the response as a string, usually used to return the arbitrary message text after a NO response.

Returns:String

the rest of the response

getTagback to summary
public String getTag()

Return the tag, if this is a tagged statement.

Returns:String

tag of this tagged statement

getTypeback to summary
public int getType()
isBADback to summary
public boolean isBAD()
isBYEback to summary
public boolean isBYE()
isContinuationback to summary
public boolean isContinuation()
isNextNonSpaceback to summary
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:char

the character to look for

Returns:boolean

true if the character is found

isNOback to summary
public boolean isNO()
isOKback to summary
public boolean isOK()
isSyntheticback to summary
public boolean isSynthetic()
isTaggedback to summary
public boolean isTagged()
isUnTaggedback to summary
public boolean isUnTagged()
parseback to summary
private void parse()
parseStringback to summary
private Object parseString(boolean parseAtoms, boolean returnString)

Generic parsing routine that can parse out a Quoted-String, Literal or Atom and return the parsed token as a String or a ByteArray. Errors or NIL data will return null.

peekByteback to summary
public byte peekByte()
readAtomback to summary
public String readAtom()

Extract an ATOM, starting at the current position. Updates the internal index to beyond the Atom.

Returns:String

an Atom

readAtomStringback to summary
public 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:String

a String

readAtomStringListback to summary
public String[] readAtomStringList()
readByteback to summary
public byte readByte()

Return the next byte from this Statement.

Returns:byte

the next byte

readByteArrayback to summary
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:ByteArray

a ByteArray

readBytesback to summary
public 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:ByteArrayInputStream

a ByteArrayInputStream

readDelimStringback to summary
private String readDelimString(String delim)

Extract a string stopping at control characters or any character in delim.

readLongback to summary
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:long

a long

readNumberback to summary
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:int

a number

readStringback to summary
public 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:char

the delimiter character

Returns:String

the string

readStringback to summary
public 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:String

a String

readStringListback to summary
public String[] readStringList()
readStringListback to summary
private String[] readStringList(boolean atom)
resetback to summary
public void reset()

Reset pointer to beginning of response.

skipback to summary
public void skip(int count)
skipSpacesback to summary
public void skipSpaces()
skipTokenback to summary
public void skipToken()

Skip to the next space, for use in error recovery while parsing.

supportsUtf8back to summary
public boolean supportsUtf8()

Does the server support UTF-8?

Returns:boolean

true if the server supports UTF-8

Since
JavaMail 1.6.0
toStringback to summary
private String toString(byte[] buffer, int start, int end)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override