1 36 package org.columba.ristretto.imap.parser; 37 38 import java.util.regex.Matcher ; 39 import java.util.regex.Pattern ; 40 41 import org.columba.ristretto.imap.AppendInfo; 42 import org.columba.ristretto.imap.IMAPResponse; 43 import org.columba.ristretto.parser.ParserException; 44 45 49 public class AppendInfoParser 50 { 51 private static final Pattern stringAppendPlusPattern = Pattern.compile("^APPENDUID ([0-9]*) ([0-9]*)"); 52 53 54 61 public static AppendInfo parse(IMAPResponse response) throws ParserException 62 { 63 String in = response.getResponseTextCode().getStringValue(); 64 AppendInfo result = null; 65 Matcher matcher = stringAppendPlusPattern.matcher(in); 68 if (matcher.find()) { 69 try { 70 result = new AppendInfo(Long.parseLong(matcher.group(1)), Long.parseLong(matcher.group(2))); 71 } 72 catch(NumberFormatException e) { 73 throw new ParserException("APPENDUID parse error : " + e.getMessage()); 74 } 75 } 76 else { 77 throw new ParserException("No APPENDUID response : " + in); 78 } 79 80 return result; 81 } 82 83 } | Popular Tags |