geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlaskow...@apache.org
Subject svn commit: r390524 [3/7] - in /geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail: authentication/ store/nntp/ store/nntp/newsrc/ store/pop3/ store/pop3/message/ store/pop3/response/ transport/nntp/ transport/smtp/ util/
Date Fri, 31 Mar 2006 22:24:56 GMT
Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Folder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Folder.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Folder.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Folder.java Fri Mar 31 14:24:52 2006
@@ -36,305 +36,305 @@
 import org.apache.geronimo.javamail.store.pop3.response.POP3StatusResponse;
 
 /**
- * The POP3 implementation of the javax.mail.Folder
- * Note that only INBOX is supported in POP3
+ * The POP3 implementation of the javax.mail.Folder Note that only INBOX is
+ * supported in POP3
  * <p>
  * <url>http://www.faqs.org/rfcs/rfc1939.html</url>
  * </p>
+ * 
  * @see javax.mail.Folder
  * 
  * @version $Rev$ $Date$
  */
 public class POP3Folder extends Folder {
 
-	private boolean isFolderOpen = false;
-	private int mode;
-	private POP3Connection pop3Con;
-	private int msgCount;
-	private Session session;
-	
-	/**
-	* Vector is synchronized so choose over the other Collection impls
-	* This is initialized on open
-	* A chache will save the expensive operation of retrieving the message
-	* again from the server.
-	*/
-	private Vector msgCache;
-	
-	protected POP3Folder(Store store,URLName url) {
-		super(store);
-	}
-	
-	protected POP3Folder(Store store,Session session,POP3Connection pop3Con) {
-		super(store);
-		this.pop3Con = pop3Con;
-		this.session = session;
-	}
-
-	public String getName() {
-		return "INBOX";
-	}
-
-	public String getFullName() {
-		return "INBOX";
-	}
-
-	/**
-	 * Never return "this" as the parent folder.
-	 * Somebody not familliar with POP3 may do something like
-	 * while(getParent() != null) or something simmilar which
-	 * will result in an infinte loop
-	 */
-	public Folder getParent() throws MessagingException {
-		throw new MethodNotSupportedException("INBOX is the root folder");
-	}
-
-	public boolean exists() throws MessagingException {
-		// INBOX always exists at the backend
-		return true;
-	}
-
-	public Folder[] list(String pattern) throws MessagingException {
-		throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
-	}
-
-	/** 
-	 * No sub folders, hence there is no notion of a seperator
-	 */
-	public char getSeparator() throws MessagingException {
-		throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
-	}
-
-	public int getType() throws MessagingException {
-		return HOLDS_MESSAGES;
-	}
-
-	public boolean create(int type) throws MessagingException {
-		throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
-	}
-
-	public boolean hasNewMessages() throws MessagingException {
-		throw new MethodNotSupportedException("POP3 doesn't support this operation");
-	}
-
-	public Folder getFolder(String name) throws MessagingException {
-		throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
-	}
-
-	public boolean delete(boolean recurse) throws MessagingException {
-		throw new MethodNotSupportedException("Only INBOX is supported in POP3 and INBOX cannot be deleted");
-	}
-
-	public boolean renameTo(Folder f) throws MessagingException {
-		throw new MethodNotSupportedException("Only INBOX is supported in POP3 and INBOX cannot be renamed");
-	}
-
-	/**
-	 * @see javax.mail.Folder#open(int)
-	 */
-	public void open(int mode) throws MessagingException {
-		//Can only be performed on a closed folder
-		checkClosed();
-		
-		try {
-			
-			POP3StatusResponse res = (POP3StatusResponse) POP3ResponseFactory
-						.getStatusResponse(pop3Con.sendCommand(POP3CommandFactory
-								.getCOMMAND_STAT()));
-			
-			// I am not checking for the res == null condition as the 
-			// try catch block will handle it.
-			
-			this.mode = mode;
-			this.isFolderOpen = true;
-			this.msgCount = res.getNumMessages();
-			// JavaMail API has no method in Folder to expose the total 
-			// size (no of bytes) of the  mail drop;
-			
-			msgCache = new Vector(msgCount);
-			msgCache.setSize(msgCount);
-			
-		} catch (Exception e) {
-			throw new MessagingException("Unable to execute STAT command",e);
-		}
-		
-		notifyConnectionListeners(ConnectionEvent.OPENED);
-	}
-
-	public void close(boolean expunge) throws MessagingException {
-		// Can only be performed on an open folder
-		checkOpen();
-
-		try {
-			if (mode == READ_WRITE) {
-				// find all messages marked deleted and issue DELE commands
-				POP3Message m;
-				for (int i = 0; i < msgCache.size(); i++) {
-					if ((m = (POP3Message) msgCache.elementAt(i)) != null) {
-						if (m.isSet(Flags.Flag.DELETED)) {
-							try {
-								pop3Con.sendCommand(POP3CommandFactory
-										.getCOMMAND_DELE(i + 1));
-							} catch (Exception e) {
-								throw new MessagingException(
-										"Exception deleting message no ["
-												+ (i + 1) + "] during close", e);
-							}
-						}
-					}
-				}
-			}
-
-			try {
-				pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_QUIT());
-			} catch (Exception e) {
-				// doesn't really care about the response
-			}
-		// dosn't need a catch block here, but added incase something goes wrong
-		// so that the finnaly is garunteed to execute in such a case.	
-		} finally {
-			try {
-				pop3Con.close();
-			} catch (Exception e) {
-				// doesn't really care about the response
-				// all we can do is to set the reference explicitly to null
-				pop3Con = null;
-			}
-			
-			/*
-			 * The message numbers depend on the mail drop
-			 * if the connection is closed, then purge the cache
-			 */
-			msgCache = null;
-			isFolderOpen = false;
-			notifyConnectionListeners(ConnectionEvent.CLOSED);
-		}
-	}
-
-	public boolean isOpen() {
-		return isFolderOpen;
-	}
-
-	public Flags getPermanentFlags() {
-		// unfortunately doesn't have a throws clause for this method
-		//throw new MethodNotSupportedException("POP3 doesn't support permanent flags");
-		
-		// Better than returning null, save the extra condition from a user to check for null
-		// and avoids a NullPointerException for the careless.
-		return new Flags();
-	}
-
-	public int getMessageCount() throws MessagingException {
-		return msgCount;
-	}
-
-	/**
-	 * Checks wether the message is in cache, if not
-	 * will create a new message object and return it.
-	 * @see javax.mail.Folder#getMessage(int)
-	 */
-	public Message getMessage(int msgNum) throws MessagingException {
-		// Can only be performed on an Open folder
-		checkOpen();
-		if(msgNum <1 || msgNum> getMessageCount()){
-			throw new MessagingException("Invalid Message number");
-		}
-		
-		Message msg = null;
-		try {
-			msg = (Message)msgCache.elementAt(msgNum);
-		} catch (RuntimeException e) {
-			session.getDebugOut().println("Message not in cache");
-		}  
-		if(msg == null){
-			msg = POP3MessageFactory.createMessage(this,session,pop3Con,msgNum);
-			msgCache.setElementAt(msg,msgNum);
-		}
-		
-		return msg;
-	}
-
-	public void appendMessages(Message[] msgs) throws MessagingException {
-		throw new MethodNotSupportedException("Message appending is not supported in POP3");
-
-	}
-
-	public Message[] expunge() throws MessagingException {
-		throw new MethodNotSupportedException("Expunge is not supported in POP3");
-	}
-	
-	public int getMode()throws IllegalStateException{ 
-		// Can only be performed on an Open folder
-		checkOpen();
-		return mode;
-	}
-
-	/**
-	 * @see javax.mail.Folder#fetch(javax.mail.Message[], javax.mail.FetchProfile)
-	 * 
-	 * The JavaMail API recommends that this method be overrident to provide a meaningfull
-	 * implementation.
-	 */
-	public void fetch(Message[] msgs, FetchProfile fp)
-			throws MessagingException {
-		// Can only be performed on an Open folder
-		checkOpen();
-		for(int i=0; i<msgs.length;i++)
-		{
-			Message msg = msgs[i];
-			if(msg == null)
-			{
-				msg = POP3MessageFactory.createMessage(this,session,pop3Con,i);
-			}
-			if(fp.contains(FetchProfile.Item.ENVELOPE))
-			{
-				msg = POP3MessageFactory.createMessageWithEvelope((POP3Message)msg);
-			}
-			
-			if(fp.contains(FetchProfile.Item.CONTENT_INFO))
-			{
-				msg = POP3MessageFactory.createMessageWithContentInfo((POP3Message)msg);
-			}
-			
-			if(fp.contains(FetchProfile.Item.FLAGS))
-			{
-				msg = POP3MessageFactory.createMessageWithFlags((POP3Message)msg);
-			}
-			
-			msgs[i] = msg;
-		}
-	}
-	
-     
-	/**
-	 * Below is a list of covinience methods that avoid repeated checking for a
-	 * value and throwing an exception
-	 */
-	
+    private boolean isFolderOpen = false;
+
+    private int mode;
+
+    private POP3Connection pop3Con;
+
+    private int msgCount;
+
+    private Session session;
+
+    /**
+     * Vector is synchronized so choose over the other Collection impls This is
+     * initialized on open A chache will save the expensive operation of
+     * retrieving the message again from the server.
+     */
+    private Vector msgCache;
+
+    protected POP3Folder(Store store, URLName url) {
+        super(store);
+    }
+
+    protected POP3Folder(Store store, Session session, POP3Connection pop3Con) {
+        super(store);
+        this.pop3Con = pop3Con;
+        this.session = session;
+    }
+
+    public String getName() {
+        return "INBOX";
+    }
+
+    public String getFullName() {
+        return "INBOX";
+    }
+
+    /**
+     * Never return "this" as the parent folder. Somebody not familliar with
+     * POP3 may do something like while(getParent() != null) or something
+     * simmilar which will result in an infinte loop
+     */
+    public Folder getParent() throws MessagingException {
+        throw new MethodNotSupportedException("INBOX is the root folder");
+    }
+
+    public boolean exists() throws MessagingException {
+        // INBOX always exists at the backend
+        return true;
+    }
+
+    public Folder[] list(String pattern) throws MessagingException {
+        throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
+    }
+
+    /**
+     * No sub folders, hence there is no notion of a seperator
+     */
+    public char getSeparator() throws MessagingException {
+        throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
+    }
+
+    public int getType() throws MessagingException {
+        return HOLDS_MESSAGES;
+    }
+
+    public boolean create(int type) throws MessagingException {
+        throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
+    }
+
+    public boolean hasNewMessages() throws MessagingException {
+        throw new MethodNotSupportedException("POP3 doesn't support this operation");
+    }
+
+    public Folder getFolder(String name) throws MessagingException {
+        throw new MethodNotSupportedException("Only INBOX is supported in POP3, no sub folders");
+    }
+
+    public boolean delete(boolean recurse) throws MessagingException {
+        throw new MethodNotSupportedException("Only INBOX is supported in POP3 and INBOX cannot be deleted");
+    }
+
+    public boolean renameTo(Folder f) throws MessagingException {
+        throw new MethodNotSupportedException("Only INBOX is supported in POP3 and INBOX cannot be renamed");
+    }
+
+    /**
+     * @see javax.mail.Folder#open(int)
+     */
+    public void open(int mode) throws MessagingException {
+        // Can only be performed on a closed folder
+        checkClosed();
+
+        try {
+
+            POP3StatusResponse res = (POP3StatusResponse) POP3ResponseFactory.getStatusResponse(pop3Con
+                    .sendCommand(POP3CommandFactory.getCOMMAND_STAT()));
+
+            // I am not checking for the res == null condition as the
+            // try catch block will handle it.
+
+            this.mode = mode;
+            this.isFolderOpen = true;
+            this.msgCount = res.getNumMessages();
+            // JavaMail API has no method in Folder to expose the total
+            // size (no of bytes) of the mail drop;
+
+            msgCache = new Vector(msgCount);
+            msgCache.setSize(msgCount);
+
+        } catch (Exception e) {
+            throw new MessagingException("Unable to execute STAT command", e);
+        }
+
+        notifyConnectionListeners(ConnectionEvent.OPENED);
+    }
+
+    public void close(boolean expunge) throws MessagingException {
+        // Can only be performed on an open folder
+        checkOpen();
+
+        try {
+            if (mode == READ_WRITE) {
+                // find all messages marked deleted and issue DELE commands
+                POP3Message m;
+                for (int i = 0; i < msgCache.size(); i++) {
+                    if ((m = (POP3Message) msgCache.elementAt(i)) != null) {
+                        if (m.isSet(Flags.Flag.DELETED)) {
+                            try {
+                                pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_DELE(i + 1));
+                            } catch (Exception e) {
+                                throw new MessagingException("Exception deleting message no [" + (i + 1)
+                                        + "] during close", e);
+                            }
+                        }
+                    }
+                }
+            }
+
+            try {
+                pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_QUIT());
+            } catch (Exception e) {
+                // doesn't really care about the response
+            }
+            // dosn't need a catch block here, but added incase something goes
+            // wrong
+            // so that the finnaly is garunteed to execute in such a case.
+        } finally {
+            try {
+                pop3Con.close();
+            } catch (Exception e) {
+                // doesn't really care about the response
+                // all we can do is to set the reference explicitly to null
+                pop3Con = null;
+            }
+
+            /*
+             * The message numbers depend on the mail drop if the connection is
+             * closed, then purge the cache
+             */
+            msgCache = null;
+            isFolderOpen = false;
+            notifyConnectionListeners(ConnectionEvent.CLOSED);
+        }
+    }
+
+    public boolean isOpen() {
+        return isFolderOpen;
+    }
+
+    public Flags getPermanentFlags() {
+        // unfortunately doesn't have a throws clause for this method
+        // throw new MethodNotSupportedException("POP3 doesn't support permanent
+        // flags");
+
+        // Better than returning null, save the extra condition from a user to
+        // check for null
+        // and avoids a NullPointerException for the careless.
+        return new Flags();
+    }
+
+    public int getMessageCount() throws MessagingException {
+        return msgCount;
+    }
+
+    /**
+     * Checks wether the message is in cache, if not will create a new message
+     * object and return it.
+     * 
+     * @see javax.mail.Folder#getMessage(int)
+     */
+    public Message getMessage(int msgNum) throws MessagingException {
+        // Can only be performed on an Open folder
+        checkOpen();
+        if (msgNum < 1 || msgNum > getMessageCount()) {
+            throw new MessagingException("Invalid Message number");
+        }
+
+        Message msg = null;
+        try {
+            msg = (Message) msgCache.elementAt(msgNum);
+        } catch (RuntimeException e) {
+            session.getDebugOut().println("Message not in cache");
+        }
+        if (msg == null) {
+            msg = POP3MessageFactory.createMessage(this, session, pop3Con, msgNum);
+            msgCache.setElementAt(msg, msgNum);
+        }
+
+        return msg;
+    }
+
+    public void appendMessages(Message[] msgs) throws MessagingException {
+        throw new MethodNotSupportedException("Message appending is not supported in POP3");
+
+    }
+
+    public Message[] expunge() throws MessagingException {
+        throw new MethodNotSupportedException("Expunge is not supported in POP3");
+    }
+
+    public int getMode() throws IllegalStateException {
+        // Can only be performed on an Open folder
+        checkOpen();
+        return mode;
+    }
+
+    /**
+     * @see javax.mail.Folder#fetch(javax.mail.Message[],
+     *      javax.mail.FetchProfile)
+     * 
+     * The JavaMail API recommends that this method be overrident to provide a
+     * meaningfull implementation.
+     */
+    public void fetch(Message[] msgs, FetchProfile fp) throws MessagingException {
+        // Can only be performed on an Open folder
+        checkOpen();
+        for (int i = 0; i < msgs.length; i++) {
+            Message msg = msgs[i];
+            if (msg == null) {
+                msg = POP3MessageFactory.createMessage(this, session, pop3Con, i);
+            }
+            if (fp.contains(FetchProfile.Item.ENVELOPE)) {
+                msg = POP3MessageFactory.createMessageWithEvelope((POP3Message) msg);
+            }
+
+            if (fp.contains(FetchProfile.Item.CONTENT_INFO)) {
+                msg = POP3MessageFactory.createMessageWithContentInfo((POP3Message) msg);
+            }
+
+            if (fp.contains(FetchProfile.Item.FLAGS)) {
+                msg = POP3MessageFactory.createMessageWithFlags((POP3Message) msg);
+            }
+
+            msgs[i] = msg;
+        }
+    }
+
+    /**
+     * Below is a list of covinience methods that avoid repeated checking for a
+     * value and throwing an exception
+     */
+
     /** Ensure the folder is open */
     private void checkOpen() throws IllegalStateException {
-		if (!isFolderOpen){ 
-		    throw new IllegalStateException("Folder is not Open");
-		}
+        if (!isFolderOpen) {
+            throw new IllegalStateException("Folder is not Open");
+        }
     }
 
     /** Ensure the folder is not open */
     private void checkClosed() throws IllegalStateException {
-		if (isFolderOpen){ 
-		    throw new IllegalStateException("Folder is Open");
-		}    
-    }
-    
-    /** 
-     * @see javax.mail.Folder#notifyMessageChangedListeners(int, javax.mail.Message)
+        if (isFolderOpen) {
+            throw new IllegalStateException("Folder is Open");
+        }
+    }
+
+    /**
+     * @see javax.mail.Folder#notifyMessageChangedListeners(int,
+     *      javax.mail.Message)
      * 
-     * this method is protected and cannot be used outside of Folder, therefore had to
-     * explicitly expose it via a method in POP3Folder, so that POP3Message has access to it
+     * this method is protected and cannot be used outside of Folder, therefore
+     * had to explicitly expose it via a method in POP3Folder, so that
+     * POP3Message has access to it
      * 
      * Bad design on the part of the Java Mail API.
      */
     public void notifyMessageChangedListeners(int type, Message m) {
-    	super.notifyMessageChangedListeners(type, m);
+        super.notifyMessageChangedListeners(type, m);
     }
 
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Response.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Response.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Response.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Response.java Fri Mar 31 14:24:52 2006
@@ -29,33 +29,33 @@
  * @version $Rev$ $Date$
  */
 public interface POP3Response {
-	
-	/**
-	 * Returns the response OK or ERR
-	 * <ul>
-	 * <li>OK   --> +OK in pop3 spec
-	 * <li>ERR  --> -ERR in pop3 spec
-	 * </ul>
-	 */
-	public int getStatus();
-	
-	/**
-	 * this corresponds to the line with the status
-	 * however the status will be removed and the remainder is returned.
-	 * Ex. "+OK 132 3023673" is the first line of response for a STAT command
-	 * this method will return "132 3023673"
-	 * 
-	 * So any subsequent process can parse the params 132 as no of msgs
-	 * and 3023674 as the size.
-	 * @see org.apache.geronimo.javamail.store.pop3.response.POP3StatusResponse
-	 */
-	public String getFirstLine();
-	
-	/**
-	 * This way we are not restricting anybody as InputStream.class
-	 * is the most basic type to represent an inputstream and ppl can
-	 * decorate it anyway they want, for ex BufferedInputStream or as an
-	 * InputStreamReader allowing maximum flexibility in using it. 
-	 */
-	public InputStream getData();
+
+    /**
+     * Returns the response OK or ERR
+     * <ul>
+     * <li>OK --> +OK in pop3 spec
+     * <li>ERR --> -ERR in pop3 spec
+     * </ul>
+     */
+    public int getStatus();
+
+    /**
+     * this corresponds to the line with the status however the status will be
+     * removed and the remainder is returned. Ex. "+OK 132 3023673" is the first
+     * line of response for a STAT command this method will return "132 3023673"
+     * 
+     * So any subsequent process can parse the params 132 as no of msgs and
+     * 3023674 as the size.
+     * 
+     * @see org.apache.geronimo.javamail.store.pop3.response.POP3StatusResponse
+     */
+    public String getFirstLine();
+
+    /**
+     * This way we are not restricting anybody as InputStream.class is the most
+     * basic type to represent an inputstream and ppl can decorate it anyway
+     * they want, for ex BufferedInputStream or as an InputStreamReader allowing
+     * maximum flexibility in using it.
+     */
+    public InputStream getData();
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3ResponseBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3ResponseBuilder.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3ResponseBuilder.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3ResponseBuilder.java Fri Mar 31 14:24:52 2006
@@ -26,104 +26,103 @@
 import javax.mail.MessagingException;
 import javax.mail.Session;
 
-import org.apache.geronimo.javamail.store.pop3.response.POP3ResponseFactory;;
+import org.apache.geronimo.javamail.store.pop3.response.POP3ResponseFactory;
+
+;
 
 /**
- * Builds a basic response out of the input stream received by the
- * connection.
+ * Builds a basic response out of the input stream received by the connection.
  * Performs only two basic functions
  * <ul>
  * <li>Extrats the status code</li>
  * <li>If multi-line response then extract the data as an input stream</li>
  * </ul>
- *  
- * @version $Rev$ $Date$ 
+ * 
+ * @version $Rev$ $Date$
  */
 
-public final class POP3ResponseBuilder implements POP3Constants{
-	
-	public static POP3Response buildResponse(Session session, BufferedReader reader, boolean isMultiLineResponse) throws MessagingException {
-
-		int status = ERR;
-		InputStream data = null;
-		
-		String line;
-		try {
-			line = reader.readLine();
-		} catch (IOException e) {
-			throw new MessagingException("Error in receving response");
-		}
-		if (line == null || line.trim().equals("")) {
-		    if (session.getDebug()){
-		    	session.getDebugOut().println("Empty Response");
-		    }	
-		    throw new MessagingException("Empty Response");
-		}
-		if (session.getDebug()){
-			session.getDebugOut().println("Response From Server " + line);
-		}
-				
-		if (line.startsWith("+OK")){
-			status = OK;
-			line   = removeStatusField(line);
-			if(isMultiLineResponse){
-				data = getMultiLineResponse(session,reader);
-			}
-		}else if (line.startsWith("-ERR")){
-			status = ERR;
-			line   = removeStatusField(line);
-		}else{
-		    throw new MessagingException("Unexpected response: " + line);
-		}
-		
-		return POP3ResponseFactory.getDefaultResponse(status,line,data);
-	}
-	
-	private static String removeStatusField(String line){		
-		return line.substring(line.indexOf(SPACE)+1);
-	}
-		
-	/**
-	 * This could be a multiline response
-	 */
-	private static InputStream getMultiLineResponse(Session session,
-			BufferedReader reader) throws MessagingException {
-		
-		int byteRead = -1;
-		int lastByteRead = LF;
-		ByteArrayOutputStream out = new ByteArrayOutputStream();
-		try {
-			while ((byteRead = reader.read()) >= 0) {
-				// We are checking for the end of a multiline response
-				// the format is .CRLF
-				
-				// checking for the DOT and CR
-				if (lastByteRead == DOT && byteRead == CR) {
-					byteRead = reader.read();
-					// now checking for the LF of the second CRLF
-					if (byteRead == LF) {
-						// end of response
-						break;
-					}
-				}
-				
-				out.write(byteRead);
-				lastByteRead = byteRead;
-			}
-			
-			if(session.getDebug()){
-				session.getDebugOut().println("\n============================ Response Content==================\n");
-				session.getDebugOut().write(out.toByteArray());
-				session.getDebugOut().println("\n==============================================================\n");
-			}
-			
-		} catch (IOException e) {
-			throw new MessagingException("Error processing a multi-line response",e);
-		}
-		
-		
-		
-		return new ByteArrayInputStream(out.toByteArray());
-	}
+public final class POP3ResponseBuilder implements POP3Constants {
+
+    public static POP3Response buildResponse(Session session, BufferedReader reader, boolean isMultiLineResponse)
+            throws MessagingException {
+
+        int status = ERR;
+        InputStream data = null;
+
+        String line;
+        try {
+            line = reader.readLine();
+        } catch (IOException e) {
+            throw new MessagingException("Error in receving response");
+        }
+        if (line == null || line.trim().equals("")) {
+            if (session.getDebug()) {
+                session.getDebugOut().println("Empty Response");
+            }
+            throw new MessagingException("Empty Response");
+        }
+        if (session.getDebug()) {
+            session.getDebugOut().println("Response From Server " + line);
+        }
+
+        if (line.startsWith("+OK")) {
+            status = OK;
+            line = removeStatusField(line);
+            if (isMultiLineResponse) {
+                data = getMultiLineResponse(session, reader);
+            }
+        } else if (line.startsWith("-ERR")) {
+            status = ERR;
+            line = removeStatusField(line);
+        } else {
+            throw new MessagingException("Unexpected response: " + line);
+        }
+
+        return POP3ResponseFactory.getDefaultResponse(status, line, data);
+    }
+
+    private static String removeStatusField(String line) {
+        return line.substring(line.indexOf(SPACE) + 1);
+    }
+
+    /**
+     * This could be a multiline response
+     */
+    private static InputStream getMultiLineResponse(Session session, BufferedReader reader) throws MessagingException {
+
+        int byteRead = -1;
+        int lastByteRead = LF;
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            while ((byteRead = reader.read()) >= 0) {
+                // We are checking for the end of a multiline response
+                // the format is .CRLF
+
+                // checking for the DOT and CR
+                if (lastByteRead == DOT && byteRead == CR) {
+                    byteRead = reader.read();
+                    // now checking for the LF of the second CRLF
+                    if (byteRead == LF) {
+                        // end of response
+                        break;
+                    }
+                }
+
+                out.write(byteRead);
+                lastByteRead = byteRead;
+            }
+
+            if (session.getDebug()) {
+                session.getDebugOut().println("\n============================ Response Content==================\n");
+                session.getDebugOut().write(out.toByteArray());
+                session.getDebugOut().println("\n==============================================================\n");
+            }
+
+        } catch (IOException e) {
+            throw new MessagingException("Error processing a multi-line response", e);
+        }
+
+        return new ByteArrayInputStream(out.toByteArray());
+    }
 
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Store.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Store.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Store.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/POP3Store.java Fri Mar 31 14:24:52 2006
@@ -15,7 +15,6 @@
  *  limitations under the License.
  */
 
-
 package org.apache.geronimo.javamail.store.pop3;
 
 import javax.mail.AuthenticationFailedException;
@@ -26,186 +25,180 @@
 import javax.mail.URLName;
 
 /**
- * POP3 implementation of javax.mail.Store
- * POP protocol spec is implemented in 
- * org.apache.geronimo.javamail.store.pop3.POP3Connection 
+ * POP3 implementation of javax.mail.Store POP protocol spec is implemented in
+ * org.apache.geronimo.javamail.store.pop3.POP3Connection
  * 
- * @version $Rev$ $Date$ 
+ * @version $Rev$ $Date$
  */
 
-public class POP3Store extends Store{
-	
-	private POP3Connection pop3Con;
-		
-	public POP3Store(Session session, URLName urlName) {
-		super(session,urlName);
-	}
-
-	
-	/**
-	 * @see javax.mail.Store#getDefaultFolder()
-	 * 
-	 * There is only INBOX supported in POP3
-	 * so the default folder is inbox
-	 */
-	public Folder getDefaultFolder() throws MessagingException {
-		return getFolder("INBOX");
-	}
-
-	/**  
-	 * @see javax.mail.Store#getFolder(java.lang.String)
-	 */
-	public Folder getFolder(String name) throws MessagingException {
-		
-		checkConnectionStatus();
-		
-		if(! "INBOX".equalsIgnoreCase(name)){
-			throw new MessagingException("Only INBOX is supported in POP3");
-		}		
-		return new POP3Folder(this,session,pop3Con);
-	}
-
-	/**  
-	 * @see javax.mail.Store#getFolder(javax.mail.URLName)
-	 */
-	public Folder getFolder(URLName url) throws MessagingException {
-		return getFolder(url.getFile());
-	}
-	
-	
-	/**  
-	 * @see javax.mail.Service#protocolConnect(java.lang.String, int, java.lang.String, java.lang.String)
-	 */
-	protected synchronized boolean protocolConnect(String host, int portNum,
-			String user, String passwd) throws MessagingException {
-		
-		// Never store the user, passwd for security reasons
-		
-		// if these values are null, no connection attempt should be made
-		if (host == null || passwd == null || user == null)
-		{
-			return false;
-		}	
-		
-		// validate port num
-		if (portNum <1) {
-			String portstring = session.getProperty("mail.pop3.port");
-			if (portstring != null){
-				try{	
-					portNum = Integer.parseInt(portstring);
-				} catch (NumberFormatException e) {
-					portNum = 110;
-				}	
-			}
-		}
-		
-				
-		/*
-		 *  Obtaining a connection to the server.
-		 * 
-		 */
-		pop3Con= new POP3Connection(this.session,host,portNum);
-		try {	
-			pop3Con.open();
-		} catch (Exception e) {
-			throw new MessagingException("Connection failed", e);
-		}
-						
-		/*
-		 * Sending the USER command with username
-		 * 
-		 */		
-		POP3Response resUser = null;
-		try {
-			resUser = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_USER(user));
-		} catch (Exception e) {
-			throw new MessagingException("Connection failed",e);			
-		}
-		
-		if(POP3Constants.ERR == resUser.getStatus()){
-			
-			/*
-			 * Authentication failed so sending QUIT
-			 * 
-			 */	
-			try {
-				pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_QUIT());
-			} catch (Exception e) {
-				// We don't care about the response or if any error happens
-				// just trying to comply with the spec.
-				// Most likely the server would have terminated the connection
-				// by now.
-			}
-			
-			throw new AuthenticationFailedException(resUser.getFirstLine());
-		}		
-				
-		/*
-		 * Sending the PASS command with password
-		 * 
-		 */	
-		POP3Response resPwd = null;
-		try {
-			resPwd = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_PASS(passwd));
-		} catch (Exception e) {
-			throw new MessagingException("Connection failed",e);			
-		}
-		
-		if(POP3Constants.ERR == resPwd.getStatus()){
-			
-			/*
-			 * Authentication failed so sending QUIT
-			 * 
-			 */	
-			try {
-				pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_QUIT());
-			} catch (Exception e) {
-				// We don't care about the response or if any error happens
-				// just trying to comply with the spec.
-				// Most likely the server would have terminated the connection
-				// by now.
-			}
-			
-			throw new AuthenticationFailedException(resPwd.getFirstLine());
-		}		
-
-		return true;
-	}
-	
-	/**  
-	 * @see javax.mail.Service#isConnected()
-	 */
-	public boolean isConnected()
-	{
-		POP3Response res = null;
-		try {
-			res = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_NOOP());
-		} catch (Exception e) {
-			return false;		
-		}
-		
-		return(POP3Constants.OK == res.getStatus());
-	}
-	
-	/**  
-	 * @see javax.mail.Service#close()
-	 */
-	public void close() throws MessagingException{
-		// This is done to ensure proper event notification.
-		super.close();
-		try{	
-			pop3Con.close();
-		}catch(Exception e){
-			// A message is already set at the connection level
-			// unfortuantely there is no constructor that takes only
-			// the root exception
-			new MessagingException("",e);
-		}
-	}
-	
-	private void checkConnectionStatus() throws MessagingException {
-		if (!this.isConnected()){
-		    throw new MessagingException("Not connected ");
-	    }
-	}
+public class POP3Store extends Store {
+
+    private POP3Connection pop3Con;
+
+    public POP3Store(Session session, URLName urlName) {
+        super(session, urlName);
+    }
+
+    /**
+     * @see javax.mail.Store#getDefaultFolder()
+     * 
+     * There is only INBOX supported in POP3 so the default folder is inbox
+     */
+    public Folder getDefaultFolder() throws MessagingException {
+        return getFolder("INBOX");
+    }
+
+    /**
+     * @see javax.mail.Store#getFolder(java.lang.String)
+     */
+    public Folder getFolder(String name) throws MessagingException {
+
+        checkConnectionStatus();
+
+        if (!"INBOX".equalsIgnoreCase(name)) {
+            throw new MessagingException("Only INBOX is supported in POP3");
+        }
+        return new POP3Folder(this, session, pop3Con);
+    }
+
+    /**
+     * @see javax.mail.Store#getFolder(javax.mail.URLName)
+     */
+    public Folder getFolder(URLName url) throws MessagingException {
+        return getFolder(url.getFile());
+    }
+
+    /**
+     * @see javax.mail.Service#protocolConnect(java.lang.String, int,
+     *      java.lang.String, java.lang.String)
+     */
+    protected synchronized boolean protocolConnect(String host, int portNum, String user, String passwd)
+            throws MessagingException {
+
+        // Never store the user, passwd for security reasons
+
+        // if these values are null, no connection attempt should be made
+        if (host == null || passwd == null || user == null) {
+            return false;
+        }
+
+        // validate port num
+        if (portNum < 1) {
+            String portstring = session.getProperty("mail.pop3.port");
+            if (portstring != null) {
+                try {
+                    portNum = Integer.parseInt(portstring);
+                } catch (NumberFormatException e) {
+                    portNum = 110;
+                }
+            }
+        }
+
+        /*
+         * Obtaining a connection to the server.
+         * 
+         */
+        pop3Con = new POP3Connection(this.session, host, portNum);
+        try {
+            pop3Con.open();
+        } catch (Exception e) {
+            throw new MessagingException("Connection failed", e);
+        }
+
+        /*
+         * Sending the USER command with username
+         * 
+         */
+        POP3Response resUser = null;
+        try {
+            resUser = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_USER(user));
+        } catch (Exception e) {
+            throw new MessagingException("Connection failed", e);
+        }
+
+        if (POP3Constants.ERR == resUser.getStatus()) {
+
+            /*
+             * Authentication failed so sending QUIT
+             * 
+             */
+            try {
+                pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_QUIT());
+            } catch (Exception e) {
+                // We don't care about the response or if any error happens
+                // just trying to comply with the spec.
+                // Most likely the server would have terminated the connection
+                // by now.
+            }
+
+            throw new AuthenticationFailedException(resUser.getFirstLine());
+        }
+
+        /*
+         * Sending the PASS command with password
+         * 
+         */
+        POP3Response resPwd = null;
+        try {
+            resPwd = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_PASS(passwd));
+        } catch (Exception e) {
+            throw new MessagingException("Connection failed", e);
+        }
+
+        if (POP3Constants.ERR == resPwd.getStatus()) {
+
+            /*
+             * Authentication failed so sending QUIT
+             * 
+             */
+            try {
+                pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_QUIT());
+            } catch (Exception e) {
+                // We don't care about the response or if any error happens
+                // just trying to comply with the spec.
+                // Most likely the server would have terminated the connection
+                // by now.
+            }
+
+            throw new AuthenticationFailedException(resPwd.getFirstLine());
+        }
+
+        return true;
+    }
+
+    /**
+     * @see javax.mail.Service#isConnected()
+     */
+    public boolean isConnected() {
+        POP3Response res = null;
+        try {
+            res = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_NOOP());
+        } catch (Exception e) {
+            return false;
+        }
+
+        return (POP3Constants.OK == res.getStatus());
+    }
+
+    /**
+     * @see javax.mail.Service#close()
+     */
+    public void close() throws MessagingException {
+        // This is done to ensure proper event notification.
+        super.close();
+        try {
+            pop3Con.close();
+        } catch (Exception e) {
+            // A message is already set at the connection level
+            // unfortuantely there is no constructor that takes only
+            // the root exception
+            new MessagingException("", e);
+        }
+    }
+
+    private void checkConnectionStatus() throws MessagingException {
+        if (!this.isConnected()) {
+            throw new MessagingException("Not connected ");
+        }
+    }
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3Message.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3Message.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3Message.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3Message.java Fri Mar 31 14:24:52 2006
@@ -39,210 +39,202 @@
 import org.apache.geronimo.javamail.store.pop3.response.POP3ListResponse;
 import org.apache.geronimo.javamail.store.pop3.response.POP3ResponseFactory;
 
-
 /**
- * POP3 implementation of javax.mail.internet.MimeMessage 
+ * POP3 implementation of javax.mail.internet.MimeMessage
+ * 
+ * Only the most basic information is given and Message objects created here is
+ * a light-weight reference to the actual Message As per the JavaMail spec items
+ * from the actual message will get filled up on demand
+ * 
+ * If some other items are obtained from the server as a result of one call,
+ * then the other details are also processed and filled in. For ex if RETR is
+ * called then header information will also be processed in addition to the
+ * content
  * 
- * Only the most basic information is given and
- * Message objects created here is a light-weight reference to the actual Message
- * As per the JavaMail spec items from the actual message will get filled up on demand
- *  
- * If some other items are obtained from the server as a result of one call, then the other
- * details are also processed and filled in. For ex if RETR is called then header information
- * will also be processed in addition to the content
- *  
- * @version $Rev$ $Date$ 
+ * @version $Rev$ $Date$
  */
 public class POP3Message extends MimeMessage {
 
-	private POP3Connection pop3Con;
-	private int msgSize = -1;
-	private int headerSize = -1;
-	
-	// We can't use header bcos it's already initialize to
-	// to an empty InternetHeader
-	private InputStream rawHeaders;
-	
-	// used to force loading of headers again
-	private boolean loadHeaders = true;
-	
-	// to get accessed to the debug setting and log
-	private Session session;
-	
-	protected POP3Message(Folder folder, int msgnum, Session session, POP3Connection pop3Con) {
-		super(folder, msgnum);
-		this.pop3Con = pop3Con;
-		this.session = session;
-	}
-	
-	/**
-	 * @see javax.mail.internet.MimeMessage#getContentStream()
-	 */
-	protected InputStream getContentStream() throws MessagingException {
-		POP3Response msgResponse = null;
-		try {
-			msgResponse = pop3Con.sendCommand(POP3CommandFactory
-					.getCOMMAND_RETR(msgnum));
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
+    private POP3Connection pop3Con;
+
+    private int msgSize = -1;
+
+    private int headerSize = -1;
+
+    // We can't use header bcos it's already initialize to
+    // to an empty InternetHeader
+    private InputStream rawHeaders;
+
+    // used to force loading of headers again
+    private boolean loadHeaders = true;
+
+    // to get accessed to the debug setting and log
+    private Session session;
+
+    protected POP3Message(Folder folder, int msgnum, Session session, POP3Connection pop3Con) {
+        super(folder, msgnum);
+        this.pop3Con = pop3Con;
+        this.session = session;
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getContentStream()
+     */
+    protected InputStream getContentStream() throws MessagingException {
+        POP3Response msgResponse = null;
+        try {
+            msgResponse = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_RETR(msgnum));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         loadHeaders = true;
         loadHeaders(msgResponse.getData());
         loadContent(msgResponse.getData());
-        
-		return contentStream;
-	}
-
-
-	public void setFlags(Flags newFlags, boolean set) throws MessagingException {
-		Flags oldFlags = (Flags)flags.clone(); 
-		super.setFlags(newFlags, set);
-
-		if (!flags.equals(oldFlags)) {
-			((POP3Folder) folder).notifyMessageChangedListeners(
-					MessageChangedEvent.FLAGS_CHANGED, this);
-		}
-	}
-	
-	protected void loadHeaders(InputStream in)throws MessagingException{
-		if(loadHeaders || rawHeaders == null){
-			rawHeaders = in;
-			headers = new InternetHeaders(rawHeaders);
-			loadHeaders = false;
-		}
-	}
-	
-	protected void loadContent(InputStream stream)throws MessagingException{
-		ByteArrayOutputStream out =  new ByteArrayOutputStream();		
-		try {
-			int byteRead = stream.read();
-			int lastByte = -1;
-			for(;byteRead > 0;){
-				if(byteRead == ' ' && lastByte == '\n'){
-					break;
-				}
-				lastByte = byteRead;
-				byteRead = stream.read();
-			}
-			
-			for(;stream.available()>0;){
-				out.write(stream.read());
-			}
-			
-			contentStream = new ByteArrayInputStream(out.toByteArray());
-			msgSize = contentStream.available();
-			
-		} catch (IOException e) {
-		   
-			throw new MessagingException("Error loading content info",e);
-		}		
-	}
-	
-	public int getSize() throws MessagingException {
-		if (msgSize >= 0) {
-			return msgSize;
-		}
-		try {
-
-			if (msgSize < 0) {
-				if (rawHeaders == null) {
-					loadHeaders();
-				}
-				POP3ListResponse res = (POP3ListResponse) POP3ResponseFactory
-						.getListResponse(pop3Con.sendCommand(POP3CommandFactory
-								.getCOMMAND_LIST(msgnum)));
-				msgSize = res.getSize() - headerSize;
-			}
-			return msgSize;
-		} catch (MessagingException ex) {
-			throw new MessagingException("error getting size", ex);
-		}
-	}
-
-	/**
-	 * notice that we pass zero as the no of lines from the message,as it
-	 * doesn't serv any purpose to get only a certain number of lines.
-	 * 
-	 * However this maybe important if a mail client only shows 3 or 4 lines of the
-	 * message in the list and then when the user clicks they would load the
-	 * message on demand.
-	 * 
-	 */
-	protected void loadHeaders() throws MessagingException{
-		POP3Response msgResponse = null;
-		try {
-			 
-			
-			msgResponse = pop3Con.sendCommand(POP3CommandFactory
-					.getCOMMAND_TOP(msgnum,0));
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		loadHeaders(msgResponse.getData());
-	}
-	
-	/******************************************************************
-	 * Following is a set of methods that deal with headers
-	 * I have tried to use the bare minimum
-	 * 
-	 * Used sun's POP3 impl & JavaMail API as a guide in decided which
-	 * methods are important.
-	 ********************************************************************/
-	
-	public String[] getHeader(String name) throws MessagingException {
-		if (rawHeaders == null)
-			loadHeaders();
-		return headers.getHeader(name);
-	}
-
-	public String getHeader(String name, String delimiter)
-			throws MessagingException {
-		if (headers == null)
-			loadHeaders();
-		return headers.getHeader(name, delimiter);
-	}
-
-	public Enumeration getAllHeaders() throws MessagingException {
-		if (headers == null)
-			loadHeaders();
-		return headers.getAllHeaders();
-	}
-
-	public Enumeration getMatchingHeaders(String[] names)
-			throws MessagingException {
-		if (headers == null)
-			loadHeaders();
-		return headers.getMatchingHeaders(names);
-	}
-
-	public Enumeration getNonMatchingHeaders(String[] names)
-			throws MessagingException {
-		if (headers == null)
-			loadHeaders();
-		return headers.getNonMatchingHeaders(names);
-	}
-
-	public Enumeration getAllHeaderLines() throws MessagingException {
-		if (headers == null)
-			loadHeaders();
-		return headers.getAllHeaderLines();
-	}
-
-	public Enumeration getMatchingHeaderLines(String[] names)
-			throws MessagingException {
-		if (headers == null)
-			loadHeaders();
-		return headers.getMatchingHeaderLines(names);
-	}
-
-	public Enumeration getNonMatchingHeaderLines(String[] names)
-			throws MessagingException {
-		if (headers == null)
-			loadHeaders();
-		return headers.getNonMatchingHeaderLines(names);
-	}
 
-    // the following are overrides for header modification methods.  These messages are read only,
+        return contentStream;
+    }
+
+    public void setFlags(Flags newFlags, boolean set) throws MessagingException {
+        Flags oldFlags = (Flags) flags.clone();
+        super.setFlags(newFlags, set);
+
+        if (!flags.equals(oldFlags)) {
+            ((POP3Folder) folder).notifyMessageChangedListeners(MessageChangedEvent.FLAGS_CHANGED, this);
+        }
+    }
+
+    protected void loadHeaders(InputStream in) throws MessagingException {
+        if (loadHeaders || rawHeaders == null) {
+            rawHeaders = in;
+            headers = new InternetHeaders(rawHeaders);
+            loadHeaders = false;
+        }
+    }
+
+    protected void loadContent(InputStream stream) throws MessagingException {
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try {
+            int byteRead = stream.read();
+            int lastByte = -1;
+            for (; byteRead > 0;) {
+                if (byteRead == ' ' && lastByte == '\n') {
+                    break;
+                }
+                lastByte = byteRead;
+                byteRead = stream.read();
+            }
+
+            for (; stream.available() > 0;) {
+                out.write(stream.read());
+            }
+
+            contentStream = new ByteArrayInputStream(out.toByteArray());
+            msgSize = contentStream.available();
+
+        } catch (IOException e) {
+
+            throw new MessagingException("Error loading content info", e);
+        }
+    }
+
+    public int getSize() throws MessagingException {
+        if (msgSize >= 0) {
+            return msgSize;
+        }
+        try {
+
+            if (msgSize < 0) {
+                if (rawHeaders == null) {
+                    loadHeaders();
+                }
+                POP3ListResponse res = (POP3ListResponse) POP3ResponseFactory.getListResponse(pop3Con
+                        .sendCommand(POP3CommandFactory.getCOMMAND_LIST(msgnum)));
+                msgSize = res.getSize() - headerSize;
+            }
+            return msgSize;
+        } catch (MessagingException ex) {
+            throw new MessagingException("error getting size", ex);
+        }
+    }
+
+    /**
+     * notice that we pass zero as the no of lines from the message,as it
+     * doesn't serv any purpose to get only a certain number of lines.
+     * 
+     * However this maybe important if a mail client only shows 3 or 4 lines of
+     * the message in the list and then when the user clicks they would load the
+     * message on demand.
+     * 
+     */
+    protected void loadHeaders() throws MessagingException {
+        POP3Response msgResponse = null;
+        try {
+
+            msgResponse = pop3Con.sendCommand(POP3CommandFactory.getCOMMAND_TOP(msgnum, 0));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        loadHeaders(msgResponse.getData());
+    }
+
+    /***************************************************************************
+     * Following is a set of methods that deal with headers I have tried to use
+     * the bare minimum
+     * 
+     * Used sun's POP3 impl & JavaMail API as a guide in decided which methods
+     * are important.
+     **************************************************************************/
+
+    public String[] getHeader(String name) throws MessagingException {
+        if (rawHeaders == null)
+            loadHeaders();
+        return headers.getHeader(name);
+    }
+
+    public String getHeader(String name, String delimiter) throws MessagingException {
+        if (headers == null)
+            loadHeaders();
+        return headers.getHeader(name, delimiter);
+    }
+
+    public Enumeration getAllHeaders() throws MessagingException {
+        if (headers == null)
+            loadHeaders();
+        return headers.getAllHeaders();
+    }
+
+    public Enumeration getMatchingHeaders(String[] names) throws MessagingException {
+        if (headers == null)
+            loadHeaders();
+        return headers.getMatchingHeaders(names);
+    }
+
+    public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException {
+        if (headers == null)
+            loadHeaders();
+        return headers.getNonMatchingHeaders(names);
+    }
+
+    public Enumeration getAllHeaderLines() throws MessagingException {
+        if (headers == null)
+            loadHeaders();
+        return headers.getAllHeaderLines();
+    }
+
+    public Enumeration getMatchingHeaderLines(String[] names) throws MessagingException {
+        if (headers == null)
+            loadHeaders();
+        return headers.getMatchingHeaderLines(names);
+    }
+
+    public Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException {
+        if (headers == null)
+            loadHeaders();
+        return headers.getNonMatchingHeaderLines(names);
+    }
+
+    // the following are overrides for header modification methods. These
+    // messages are read only,
     // so the headers cannot be modified.
     public void addHeader(String name, String value) throws MessagingException {
         throw new IllegalWriteException("POP3 messages are read-only");
@@ -260,10 +252,10 @@
         throw new IllegalWriteException("POP3 messages are read-only");
     }
 
-	/**
-	 * We cannot modify these messages
-	 */
-	public void saveChanges() throws MessagingException {
-		throw new IllegalWriteException("POP3 messages are read-only");
-	}
+    /**
+     * We cannot modify these messages
+     */
+    public void saveChanges() throws MessagingException {
+        throw new IllegalWriteException("POP3 messages are read-only");
+    }
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageFactory.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageFactory.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageFactory.java Fri Mar 31 14:24:52 2006
@@ -27,59 +27,58 @@
 
 /**
  * Fctory class to create POP3Messages based on the fetch profile
- *  
- * @version $Rev$ $Date$ 
+ * 
+ * @version $Rev$ $Date$
  */
 public final class POP3MessageFactory {
 
-	/**
-	 * Creates a basic method with no items, the items
-	 * will be loaded on demand
-	 * @param folder
-	 * @param session
-	 * @param pop3Con
-	 * @param msgNum
-	 * @return
-	 */
-	public static Message createMessage(POP3Folder folder, Session session,
-			POP3Connection pop3Con, int msgNum) {
-		return new POP3Message(folder,msgNum,session,pop3Con);
-	}
-
-	/**
-	 * Created in response to <cpde>FetchProfile.ENVELOPE</code>
-	 */
-	public static Message createMessageWithEvelope(POP3Message msg) throws MessagingException {
-		msg.getAllHeaders();
-		msg.getSender();
-		msg.getSentDate();
-		msg.getSubject();
-		msg.getReplyTo();
-		msg.getReceivedDate();
-		msg.getRecipients(RecipientType.TO);
-		
-		return msg;
-	}
-
-	/**
-	 * Created in response to <code>FetchProfile.CONTENT_INFO</code>
-	 */
-	public static Message createMessageWithContentInfo(POP3Message msg) throws MessagingException {
-		msg.getContentType();
-		msg.getDisposition();
-		msg.getDescription();
-		msg.getSize();
-		msg.getLineCount();
-		
-		return msg;
-	}
-
-	/**
-	 * Created in response to <code>FetchProfile.FLAGS</code>
-	 */
-	public static Message createMessageWithFlags(POP3Message msg) throws MessagingException {
-		msg.getFlags();
-		return msg;
-	}
+    /**
+     * Creates a basic method with no items, the items will be loaded on demand
+     * 
+     * @param folder
+     * @param session
+     * @param pop3Con
+     * @param msgNum
+     * @return
+     */
+    public static Message createMessage(POP3Folder folder, Session session, POP3Connection pop3Con, int msgNum) {
+        return new POP3Message(folder, msgNum, session, pop3Con);
+    }
+
+    /**
+     * Created in response to <cpde>FetchProfile.ENVELOPE</code>
+     */
+    public static Message createMessageWithEvelope(POP3Message msg) throws MessagingException {
+        msg.getAllHeaders();
+        msg.getSender();
+        msg.getSentDate();
+        msg.getSubject();
+        msg.getReplyTo();
+        msg.getReceivedDate();
+        msg.getRecipients(RecipientType.TO);
+
+        return msg;
+    }
+
+    /**
+     * Created in response to <code>FetchProfile.CONTENT_INFO</code>
+     */
+    public static Message createMessageWithContentInfo(POP3Message msg) throws MessagingException {
+        msg.getContentType();
+        msg.getDisposition();
+        msg.getDescription();
+        msg.getSize();
+        msg.getLineCount();
+
+        return msg;
+    }
+
+    /**
+     * Created in response to <code>FetchProfile.FLAGS</code>
+     */
+    public static Message createMessageWithFlags(POP3Message msg) throws MessagingException {
+        msg.getFlags();
+        return msg;
+    }
 
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithContentInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithContentInfo.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithContentInfo.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithContentInfo.java Fri Mar 31 14:24:52 2006
@@ -24,24 +24,23 @@
 import org.apache.geronimo.javamail.store.pop3.POP3Connection;
 
 /**
- * light-weight Message object
- * will be created in response to FetchProfile.CONTENT_INFO
- * other details will be filled on demand
+ * light-weight Message object will be created in response to
+ * FetchProfile.CONTENT_INFO other details will be filled on demand *
+ * 
+ * @version $Rev$ $Date$
  * 
- * * @version $Rev$ $Date$ 
- *  
  */
 
 public class POP3MessageWithContentInfo extends POP3Message {
 
-	public POP3MessageWithContentInfo(Folder folder, int msgnum,
-			Session session,POP3Connection pop3Con) throws MessagingException{
-		super(folder, msgnum, null, pop3Con);
-		this.getContentType();
-		this.getDisposition();
-		this.getDescription();
-		this.getSize();
-		this.getLineCount();
-	}
+    public POP3MessageWithContentInfo(Folder folder, int msgnum, Session session, POP3Connection pop3Con)
+            throws MessagingException {
+        super(folder, msgnum, null, pop3Con);
+        this.getContentType();
+        this.getDisposition();
+        this.getDescription();
+        this.getSize();
+        this.getLineCount();
+    }
 
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithEnvelope.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithEnvelope.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithEnvelope.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithEnvelope.java Fri Mar 31 14:24:52 2006
@@ -20,30 +20,27 @@
 import javax.mail.Folder;
 import javax.mail.MessagingException;
 import javax.mail.Session;
-import javax.mail.internet.MimeMessage.RecipientType;
 
 import org.apache.geronimo.javamail.store.pop3.POP3Connection;
 
 /**
- * light-weight Message object
- * will be created in response to FetchProfile.ENVELOPE
- * other details will be filled on demand
+ * light-weight Message object will be created in response to
+ * FetchProfile.ENVELOPE other details will be filled on demand *
  * 
- * * @version $Rev$ $Date$   
+ * @version $Rev$ $Date$
  */
 
-
 public class POP3MessageWithEnvelope extends POP3Message {
 
-	protected POP3MessageWithEnvelope(Folder folder, int msgnum,
-			Session session,POP3Connection pop3Con) throws MessagingException {
-		super(folder, msgnum, session, pop3Con);
-		this.getAllHeaders();
-		this.getSender();
-		this.getSentDate();
-		this.getSubject();
-		this.getReplyTo();
-		this.getReceivedDate();
-		this.getRecipients(RecipientType.TO);
-	}
+    protected POP3MessageWithEnvelope(Folder folder, int msgnum, Session session, POP3Connection pop3Con)
+            throws MessagingException {
+        super(folder, msgnum, session, pop3Con);
+        this.getAllHeaders();
+        this.getSender();
+        this.getSentDate();
+        this.getSubject();
+        this.getReplyTo();
+        this.getReceivedDate();
+        this.getRecipients(RecipientType.TO);
+    }
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithFlags.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithFlags.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithFlags.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/message/POP3MessageWithFlags.java Fri Mar 31 14:24:52 2006
@@ -24,18 +24,17 @@
 import org.apache.geronimo.javamail.store.pop3.POP3Connection;
 
 /**
- * light-weight Message object
- * will be created in response to FetchProfile.FLAGS
- * other details will be filled on demand
- *  
- *  * @version $Rev$ $Date$ 
+ * light-weight Message object will be created in response to FetchProfile.FLAGS
+ * other details will be filled on demand *
+ * 
+ * @version $Rev$ $Date$
  */
 
-public class POP3MessageWithFlags extends POP3Message{
+public class POP3MessageWithFlags extends POP3Message {
 
-	protected POP3MessageWithFlags(Folder folder, int msgnum,
-			Session session,POP3Connection pop3Con) throws MessagingException {
-		super(folder, msgnum, session, pop3Con);
-		this.getFlags();
-	}
+    protected POP3MessageWithFlags(Folder folder, int msgnum, Session session, POP3Connection pop3Con)
+            throws MessagingException {
+        super(folder, msgnum, session, pop3Con);
+        this.getFlags();
+    }
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/DefaultPOP3Response.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/DefaultPOP3Response.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/DefaultPOP3Response.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/DefaultPOP3Response.java Fri Mar 31 14:24:52 2006
@@ -23,35 +23,36 @@
 import org.apache.geronimo.javamail.store.pop3.POP3Response;
 
 /**
- * This class provides the basic implementation for the
- * POP3Response.
+ * This class provides the basic implementation for the POP3Response.
  * 
- * @see  org.apache.geronimo.javamail.store.pop3.POP3Response
- * @version $Rev$ $Date$ 
+ * @see org.apache.geronimo.javamail.store.pop3.POP3Response
+ * @version $Rev$ $Date$
  */
 
-public class DefaultPOP3Response implements POP3Response,POP3Constants{
-	
-	private int status = ERR;
-	private String firstLine;
-	private InputStream data;
-	
-	DefaultPOP3Response(int status, String firstLine, InputStream data){
-		this.status = status;
-		this.firstLine = firstLine; 
-		this.data = data;
-	}
-
-	public int getStatus() {
-		return status;
-	}
-
-	public InputStream getData() {
-		return data;
-	}
-
-	public String getFirstLine() {
-		return firstLine;
-	}
-	
+public class DefaultPOP3Response implements POP3Response, POP3Constants {
+
+    private int status = ERR;
+
+    private String firstLine;
+
+    private InputStream data;
+
+    DefaultPOP3Response(int status, String firstLine, InputStream data) {
+        this.status = status;
+        this.firstLine = firstLine;
+        this.data = data;
+    }
+
+    public int getStatus() {
+        return status;
+    }
+
+    public InputStream getData() {
+        return data;
+    }
+
+    public String getFirstLine() {
+        return firstLine;
+    }
+
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ListResponse.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ListResponse.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ListResponse.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ListResponse.java Fri Mar 31 14:24:52 2006
@@ -17,7 +17,6 @@
 
 package org.apache.geronimo.javamail.store.pop3.response;
 
-import java.util.Hashtable;
 import java.util.Vector;
 
 import javax.mail.MessagingException;
@@ -25,73 +24,74 @@
 import org.apache.geronimo.javamail.store.pop3.POP3Response;
 
 /**
- * This class adds functionality to the basic response
- * by parsing the reply for LIST command and obtaining specific
- * information about the msgnum and the size.
- * It could be for one or more msgs depending on wether a msg number
- * was passed or not into the LIST command
+ * This class adds functionality to the basic response by parsing the reply for
+ * LIST command and obtaining specific information about the msgnum and the
+ * size. It could be for one or more msgs depending on wether a msg number was
+ * passed or not into the LIST command
  * 
- * @see  org.apache.geronimo.javamail.store.pop3.POP3Response
- * @see  org.apache.geronimo.javamail.store.pop3.response.DefaultPOP3Response
- *  
- * @version $Rev$ $Date$ 
+ * @see org.apache.geronimo.javamail.store.pop3.POP3Response
+ * @see org.apache.geronimo.javamail.store.pop3.response.DefaultPOP3Response
+ * 
+ * @version $Rev$ $Date$
  */
 
 public class POP3ListResponse extends DefaultPOP3Response {
 
-	private int msgnum = 0;
-	private int size = 0;
-	private Vector multipleMsgs = null;
-	
-	POP3ListResponse(POP3Response baseRes) throws MessagingException{
-		super(baseRes.getStatus(),baseRes.getFirstLine(),baseRes.getData());
-		
-		// if ERR not worth proceeding any further
-		if(OK == getStatus()){			
-			
-			// if data == null, then it mean it's a single line response
-			if(baseRes.getData() == null){
-				String[] args = getFirstLine().split(SPACE);
-				try {
-					msgnum = Integer.parseInt(args[0]);
-				} catch (NumberFormatException e) {
-					throw new MessagingException("Invalid response for STAT command",e);
-				}
-				try {
-					size = Integer.parseInt(args[1]);
-				} catch (NumberFormatException e) {
-					throw new MessagingException("Invalid response for STAT command",e);
-				}
-			}else{
-				int totalMsgs = 0;
-				String[] args = getFirstLine().split(SPACE);
-				try {
-					totalMsgs = Integer.parseInt(args[0]);
-				} catch (NumberFormatException e) {
-					throw new MessagingException("Invalid response for STAT command",e);
-				}
-				multipleMsgs = new Vector(totalMsgs);
-				multipleMsgs.setSize(totalMsgs);
-				// Todo : multi-line response parsing
-			}
-			
-		}
-	}
-
-	public int getMessageNumber() {
-		return msgnum;
-	}
-
-	public int getSize() {
-		return size;
-	}
-	
-	/** Messages can be accessed by
-	 *  multipleMsgs.getElementAt(msgnum)
-	 * 
-	 */
-	public Vector getMultipleMessageDetails(){
-		return multipleMsgs;
-	}
-	
+    private int msgnum = 0;
+
+    private int size = 0;
+
+    private Vector multipleMsgs = null;
+
+    POP3ListResponse(POP3Response baseRes) throws MessagingException {
+        super(baseRes.getStatus(), baseRes.getFirstLine(), baseRes.getData());
+
+        // if ERR not worth proceeding any further
+        if (OK == getStatus()) {
+
+            // if data == null, then it mean it's a single line response
+            if (baseRes.getData() == null) {
+                String[] args = getFirstLine().split(SPACE);
+                try {
+                    msgnum = Integer.parseInt(args[0]);
+                } catch (NumberFormatException e) {
+                    throw new MessagingException("Invalid response for STAT command", e);
+                }
+                try {
+                    size = Integer.parseInt(args[1]);
+                } catch (NumberFormatException e) {
+                    throw new MessagingException("Invalid response for STAT command", e);
+                }
+            } else {
+                int totalMsgs = 0;
+                String[] args = getFirstLine().split(SPACE);
+                try {
+                    totalMsgs = Integer.parseInt(args[0]);
+                } catch (NumberFormatException e) {
+                    throw new MessagingException("Invalid response for STAT command", e);
+                }
+                multipleMsgs = new Vector(totalMsgs);
+                multipleMsgs.setSize(totalMsgs);
+                // Todo : multi-line response parsing
+            }
+
+        }
+    }
+
+    public int getMessageNumber() {
+        return msgnum;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    /**
+     * Messages can be accessed by multipleMsgs.getElementAt(msgnum)
+     * 
+     */
+    public Vector getMultipleMessageDetails() {
+        return multipleMsgs;
+    }
+
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ResponseFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ResponseFactory.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ResponseFactory.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3ResponseFactory.java Fri Mar 31 14:24:52 2006
@@ -24,25 +24,24 @@
 import org.apache.geronimo.javamail.store.pop3.POP3Response;
 
 /**
- * This factory provides a uniform way of handling the 
- * creation of response objects.
- *  
- * @version $Rev$ $Date$ 
+ * This factory provides a uniform way of handling the creation of response
+ * objects.
+ * 
+ * @version $Rev$ $Date$
  */
 
-public final class POP3ResponseFactory implements POP3Constants{
-	
-	public static POP3Response getDefaultResponse(int status,String line,InputStream data){
-		return new DefaultPOP3Response(status,line,data);
-	}
-	
-	public static POP3Response getStatusResponse(POP3Response baseRes) throws MessagingException{
-		return new POP3StatusResponse(baseRes);
-	}
-	
-	public static POP3Response getListResponse(POP3Response baseRes) throws MessagingException{
-		return new POP3StatusResponse(baseRes);
-	}
-	
+public final class POP3ResponseFactory implements POP3Constants {
+
+    public static POP3Response getDefaultResponse(int status, String line, InputStream data) {
+        return new DefaultPOP3Response(status, line, data);
+    }
+
+    public static POP3Response getStatusResponse(POP3Response baseRes) throws MessagingException {
+        return new POP3StatusResponse(baseRes);
+    }
+
+    public static POP3Response getListResponse(POP3Response baseRes) throws MessagingException {
+        return new POP3StatusResponse(baseRes);
+    }
 
 }

Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3StatusResponse.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3StatusResponse.java?rev=390524&r1=390523&r2=390524&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3StatusResponse.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/store/pop3/response/POP3StatusResponse.java Fri Mar 31 14:24:52 2006
@@ -18,49 +18,50 @@
 package org.apache.geronimo.javamail.store.pop3.response;
 
 import javax.mail.MessagingException;
+
 import org.apache.geronimo.javamail.store.pop3.POP3Response;
 
 /**
- * This class adds functionality to the basic response
- * by parsing the status line and obtaining specific
- * information about num of msgs and the size
+ * This class adds functionality to the basic response by parsing the status
+ * line and obtaining specific information about num of msgs and the size
+ * 
+ * @see org.apache.geronimo.javamail.store.pop3.POP3Response
+ * @see org.apache.geronimo.javamail.store.pop3.response.DefaultPOP3Response
  * 
- * @see  org.apache.geronimo.javamail.store.pop3.POP3Response
- * @see  org.apache.geronimo.javamail.store.pop3.response.DefaultPOP3Response
- *  
- * @version $Rev$ $Date$ 
+ * @version $Rev$ $Date$
  */
 
 public class POP3StatusResponse extends DefaultPOP3Response {
 
-	private int numMessages = 0;
-	private int size = 0;
-	
-	POP3StatusResponse(POP3Response baseRes) throws MessagingException{
-		super(baseRes.getStatus(),baseRes.getFirstLine(),baseRes.getData());
-		
-		// if ERR not worth proceeding any further
-		if(OK == getStatus()){			
-			String[] args = getFirstLine().split(SPACE);
-			try {
-				numMessages = Integer.parseInt(args[0]);
-			} catch (NumberFormatException e) {
-				throw new MessagingException("Invalid response for STAT command",e);
-			}
-			try {
-				size = Integer.parseInt(args[1]);
-			} catch (NumberFormatException e) {
-				throw new MessagingException("Invalid response for STAT command",e);
-			}
-		}
-	}
-
-	public int getNumMessages() {
-		return numMessages;
-	}
-
-	public int getSize() {
-		return size;
-	}
+    private int numMessages = 0;
+
+    private int size = 0;
+
+    POP3StatusResponse(POP3Response baseRes) throws MessagingException {
+        super(baseRes.getStatus(), baseRes.getFirstLine(), baseRes.getData());
+
+        // if ERR not worth proceeding any further
+        if (OK == getStatus()) {
+            String[] args = getFirstLine().split(SPACE);
+            try {
+                numMessages = Integer.parseInt(args[0]);
+            } catch (NumberFormatException e) {
+                throw new MessagingException("Invalid response for STAT command", e);
+            }
+            try {
+                size = Integer.parseInt(args[1]);
+            } catch (NumberFormatException e) {
+                throw new MessagingException("Invalid response for STAT command", e);
+            }
+        }
+    }
+
+    public int getNumMessages() {
+        return numMessages;
+    }
+
+    public int getSize() {
+        return size;
+    }
 
 }



Mime
View raw message