Package com.sun.mail.imap.protocol
Class FetchResponse
- java.lang.Object
-
- com.sun.mail.iap.Response
-
- com.sun.mail.imap.protocol.IMAPResponse
-
- com.sun.mail.imap.protocol.FetchResponse
-
public class FetchResponse extends IMAPResponse
This class represents a FETCH response obtained from the input stream of an IMAP server.
-
-
Constructor Summary
Constructors Constructor Description FetchResponse(Protocol p)
FetchResponse(IMAPResponse r)
FetchResponse(IMAPResponse r, FetchItem[] fitems)
Construct a FetchResponse that handles the additional FetchItems.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
getExtensionItems()
Return a map of the extension items found in this fetch response.Item
getItem(int index)
static <T extends Item>
TgetItem(Response[] r, int msgno, java.lang.Class<T> c)
Return the first fetch response item of the given class for the given message number.<T extends Item>
TgetItem(java.lang.Class<T> c)
int
getItemCount()
static <T extends Item>
java.util.List<T>getItems(Response[] r, int msgno, java.lang.Class<T> c)
Return all fetch response items of the given class for the given message number.private boolean
match(char[] itemName)
Does the current buffer match the given item name? itemName is the name of the IMAP item to compare against.private boolean
match(java.lang.String itemName)
Does the current buffer match the given item name? itemName is the name of the IMAP item to compare against.private java.lang.String
next20()
Return the next 20 characters in the buffer, for exception messages.private void
parse()
private boolean
parseExtensionItem()
If this item is a known extension item, parse it.private Item
parseItem()
Parse the item at the current position in the buffer, skipping over the item if successful.-
Methods inherited from class com.sun.mail.imap.protocol.IMAPResponse
getKey, getNumber, keyEquals, readSimpleList
-
Methods inherited from class com.sun.mail.iap.Response
byeResponse, getException, getRest, getTag, getType, isBAD, isBYE, isContinuation, isNextNonSpace, isNO, isOK, isSynthetic, isTagged, isUnTagged, peekByte, readAtom, readAtomString, readAtomStringList, readByte, readByteArray, readBytes, readLong, readNumber, readString, readString, readStringList, reset, skip, skipSpaces, skipToken, supportsUtf8, toString
-
-
-
-
Constructor Detail
-
FetchResponse
public FetchResponse(Protocol p) throws java.io.IOException, ProtocolException
- Throws:
java.io.IOException
ProtocolException
-
FetchResponse
public FetchResponse(IMAPResponse r) throws java.io.IOException, ProtocolException
- Throws:
java.io.IOException
ProtocolException
-
FetchResponse
public FetchResponse(IMAPResponse r, FetchItem[] fitems) throws java.io.IOException, ProtocolException
Construct a FetchResponse that handles the additional FetchItems.- Parameters:
r
- the IMAPResponsefitems
- the fetch items- Throws:
java.io.IOException
- for I/O errorsProtocolException
- for protocol failures- Since:
- JavaMail 1.4.6
-
-
Method Detail
-
getItemCount
public int getItemCount()
-
getItem
public Item getItem(int index)
-
getItem
public <T extends Item> T getItem(java.lang.Class<T> c)
-
getItem
public static <T extends Item> T getItem(Response[] r, int msgno, java.lang.Class<T> c)
Return the first fetch response item of the given class for the given message number.- Type Parameters:
T
- the type of fetch item- Parameters:
r
- the responsesmsgno
- the message numberc
- the class- Returns:
- the fetch item
-
getItems
public static <T extends Item> java.util.List<T> getItems(Response[] r, int msgno, java.lang.Class<T> c)
Return all fetch response items of the given class for the given message number.- Type Parameters:
T
- the type of fetch items- Parameters:
r
- the responsesmsgno
- the message numberc
- the class- Returns:
- the list of fetch items
- Since:
- JavaMail 1.5.2
-
getExtensionItems
public java.util.Map<java.lang.String,java.lang.Object> getExtensionItems()
Return a map of the extension items found in this fetch response. The map is indexed by extension item name. Callers should not modify the map.- Returns:
- Map of extension items, or null if none
- Since:
- JavaMail 1.4.6
-
parse
private void parse() throws ParsingException
- Throws:
ParsingException
-
next20
private java.lang.String next20()
Return the next 20 characters in the buffer, for exception messages.
-
parseItem
private Item parseItem() throws ParsingException
Parse the item at the current position in the buffer, skipping over the item if successful. Otherwise, return null and leave the buffer position unmodified.- Throws:
ParsingException
-
parseExtensionItem
private boolean parseExtensionItem() throws ParsingException
If this item is a known extension item, parse it.- Throws:
ParsingException
-
match
private boolean match(char[] itemName)
Does the current buffer match the given item name? itemName is the name of the IMAP item to compare against. NOTE that itemName *must* be all uppercase. If the match is successful, the buffer pointer (index) is incremented past the matched item.
-
match
private boolean match(java.lang.String itemName)
Does the current buffer match the given item name? itemName is the name of the IMAP item to compare against. NOTE that itemName *must* be all uppercase. If the match is successful, the buffer pointer (index) is incremented past the matched item.
-
-