in geronimo-mail_2.1_impl/geronimo-mail_2.1_provider/src/main/java/org/apache/geronimo/mail/store/imap/connection/IMAPFetchResponse.java [36:113]
public IMAPFetchResponse(int sequenceNumber, byte[] data, IMAPResponseTokenizer source) throws MessagingException {
super("FETCH", data);
this.sequenceNumber = sequenceNumber;
// fetch responses are a list, even if there is just a single member.
source.checkLeftParen();
// loop until we find the list end.
while (source.notListEnd()) {
// the response names are coded as ATOMS. The BODY one's use a special
// syntax, so we need to use the expanded delimiter set to pull this out.
String itemName = source.readAtom(true).toUpperCase();
if (itemName.equals("ENVELOPE")) {
dataItems.add(new IMAPEnvelope(source));
}
else if (itemName.equals("BODYSTRUCTURE")) {
dataItems.add(new IMAPBodyStructure(source));
}
else if (itemName.equals("FLAGS")) {
dataItems.add(new IMAPFlags(source));
}
else if (itemName.equals("INTERNALDATE")) {
dataItems.add(new IMAPInternalDate(source));
}
else if (itemName.equals("UID")) {
dataItems.add(new IMAPUid(sequenceNumber, source));
}
else if (itemName.equals("RFC822")) {
// all of the RFC822 items are of form
// "RFC822.name". We used the expanded parse above because
// the BODY names include some complicated bits. If we got one
// of the RFC822 sections, then parse the rest of the name using
// the old rules, which will pull in the rest of the name from the period.
itemName = source.readAtom(false).toUpperCase();
if (itemName.equals(".SIZE")) {
dataItems.add(new IMAPMessageSize(source));
}
else if (itemName.equals(".HEADER")) {
dataItems.add(new IMAPInternetHeader(source.readByteArray()));
}
else if (itemName.equals(".TEXT")) {
dataItems.add(new IMAPMessageText(source.readByteArray()));
}
}
// this is just the body alone. Specific body segments
// have a more complex naming structure. Believe it or
// not,
else if (itemName.equals("BODY")) {
// time to go parse out the section information from the
// name.
IMAPBodySection section = new IMAPBodySection(source);
switch (section.section) {
case IMAPBodySection.BODY:
// a "full body cast". Just grab the binary data
dataItems.add(new IMAPBody(section, source.readByteArray()));
break;
case IMAPBodySection.HEADERS:
case IMAPBodySection.HEADERSUBSET:
case IMAPBodySection.MIME:
// these 3 are all variations of a header request
dataItems.add(new IMAPInternetHeader(section, source.readByteArray()));
break;
case IMAPBodySection.TEXT:
// just the text portion of the body
// a "full body cast". Just grab the binary data
dataItems.add(new IMAPMessageText(section, source.readByteArray()));
break;
}
}
}
// swallow the terminating right paren
source.checkRightParen();
}