1 36 package org.columba.ristretto.imap.parser; 37 38 import org.columba.ristretto.imap.IMAPHeader; 39 import org.columba.ristretto.imap.IMAPResponse; 40 import org.columba.ristretto.message.Attributes; 41 import org.columba.ristretto.message.Header; 42 import org.columba.ristretto.parser.HeaderParser; 43 import org.columba.ristretto.parser.ParserException; 44 45 53 public class IMAPHeaderParser { 54 55 56 63 public static IMAPHeader parse( IMAPResponse response ) throws ParserException { 64 Attributes attributes = MessageAttributeParser.parse( response.getResponseMessage() ); 66 67 String body = (String ) attributes.get("BODY"); 68 Header header; 69 70 header = HeaderParser.parse(response.getData(body)); 72 73 Integer uid = null; 75 if( attributes.get("UID") != null ) { 76 uid = new Integer ( (String )attributes.get("UID") ); 77 } 78 79 Integer size; 81 if( attributes.get("RFC822.SIZE") != null ) { 82 size = new Integer (Math.round(Integer.parseInt((String )attributes.get("RFC822.SIZE")) / 1024)); 83 } else { 84 size = new Integer (0); 85 } 86 87 return new IMAPHeader(header, uid, size ); 88 } 89 90 } 91 | Popular Tags |