### Eclipse Workspace Patch 1.0 #P hupa Index: server/src/test/java/org/apache/hupa/server/utils/TestUtils.java =================================================================== --- server/src/test/java/org/apache/hupa/server/utils/TestUtils.java (revision 885996) +++ server/src/test/java/org/apache/hupa/server/utils/TestUtils.java (working copy) @@ -73,24 +73,25 @@ } private String ident(int spaces, String text) { - String ret = ""; - for (int i = 0; i < spaces; i++) - ret += " "; - return ret + text; + final char[] padding = new char[spaces]; + Arrays.fill(padding, ' '); + return new String(padding) + text; } public String toString() { - String ret = ""; + final StringBuilder ret = new StringBuilder(); + String separator = ""; for (String s : this) { - ret += s + "\n"; + ret.append(separator).append(s); + separator = "\n"; } - return ret; + return ret.toString(); } } /** * Creates a FileItem which stores data in memory - * + * * @param filename * @return a new item * @throws IOException @@ -103,7 +104,7 @@ os.close(); return item; } - + public void testCreateMockFileItem() throws Exception { FileItem item = createMockFileItem("filename.jpg"); assertEquals("ABCDEFGHIJK\n", item.getString()); @@ -111,7 +112,7 @@ /** * Create a new mime-message from a file stored in the fixtures folder - * + * * @param session * @param msgFile * @return @@ -121,7 +122,7 @@ msgFile = DemoModeConstants.DEMO_MODE_MESSAGES_LOCATION + msgFile; URL url = Thread.currentThread().getContextClassLoader().getResource(msgFile); assertNotNull("Check that the file " + msgFile + " is in the classpath", url); - + FileInputStream is = new FileInputStream(url.getFile()); return new MimeMessage(session, is); } @@ -129,8 +130,8 @@ /** * Creates a new mime message. * It is possible to specify which parts to create (text, html or both) and - * the number of attachments - * + * the number of attachments + * * @param session * @param text * @param html @@ -154,7 +155,7 @@ message.setSubject("Subject"); return AbstractSendMessageHandler.composeMessage(message, text, html, items); } - + public static Message createMockMimeMessage(Session session, int nfiles) throws MessagingException, IOException { return createMockMimeMessage(session, "Body", "
Body
", nfiles); } @@ -162,7 +163,7 @@ /** * Creates a client side mock smtp message. * It is possible to say the number of attachments we want. - * + * * @param registry * @param nfiles * @return @@ -201,11 +202,11 @@ /** * Parses a mime message and returns an array of content-types. - * Each line in the array represents a mime part and is indented + * Each line in the array represents a mime part and is indented * with spaces. - * + * * It's used in testing or debugging. - * + * * @param msg * @return * @throws IOException Index: shared/src/main/java/org/apache/hupa/shared/rpc/FetchFoldersResult.java =================================================================== --- shared/src/main/java/org/apache/hupa/shared/rpc/FetchFoldersResult.java (revision 885996) +++ shared/src/main/java/org/apache/hupa/shared/rpc/FetchFoldersResult.java (working copy) @@ -28,7 +28,7 @@ public class FetchFoldersResult implements Result{ /** - * + * */ private static final long serialVersionUID = -6215610133650989605L; private ArrayList folders; @@ -36,21 +36,21 @@ public FetchFoldersResult(ArrayList folders) { this.folders=folders; } - + @SuppressWarnings("unused") private FetchFoldersResult() { - + } - + public ArrayList getFolders() { return folders; } - + public String toString() { - String ret = ""; + final StringBuilder ret = new StringBuilder(); for (IMAPFolder f: folders) { - ret += f.getFullName() + " "; + ret.append(f.getFullName()).append(" "); } - return ret; + return ret.toString(); } } Index: shared/src/main/java/org/apache/hupa/shared/data/SMTPMessage.java =================================================================== --- shared/src/main/java/org/apache/hupa/shared/data/SMTPMessage.java (revision 885996) +++ shared/src/main/java/org/apache/hupa/shared/data/SMTPMessage.java (working copy) @@ -26,33 +26,33 @@ private ArrayList bcc; private String text; private ArrayList aList; - + public String toString() { - String bccList = ""; - if (bcc !=null) + final StringBuilder bccList = new StringBuilder(); + if (bcc !=null) for (String s: bcc) - bccList += s + " "; - + bccList.append(s).append(" "); + String attachNames = ""; - for (MessageAttachment m: aList) + for (MessageAttachment m: aList) attachNames += m.getName() + " "; - + return super.toString() + "Bcc='" + bccList + "'\nAttachments=" + attachNames + "'\nMessage:\n" + text; } - + public ArrayList getBcc() { return bcc; } public void setBcc(ArrayList bcc) { this.bcc = bcc; } - + /** * Set the body text of the content - * + * * @param text */ public void setText(String text) { @@ -68,8 +68,8 @@ } /** - * Set the attachments - * + * Set the attachments + * * @param aList */ public void setMessageAttachments(ArrayList aList) { @@ -77,8 +77,8 @@ } /** - * Return the attachments - * + * Return the attachments + * * @return aList */ public ArrayList getMessageAttachments() { Index: shared/src/main/java/org/apache/hupa/shared/data/AbstractMessage.java =================================================================== --- shared/src/main/java/org/apache/hupa/shared/data/AbstractMessage.java (revision 885996) +++ shared/src/main/java/org/apache/hupa/shared/data/AbstractMessage.java (working copy) @@ -23,9 +23,9 @@ import java.util.ArrayList; public class AbstractMessage implements Serializable{ - + /** - * + * */ private static final long serialVersionUID = 5208272852772006815L; private String from; @@ -33,37 +33,43 @@ private ArrayList to; private ArrayList cc; private boolean hasAttachment; - + public String toString() { - String toList = ""; - if (to != null) - for (String s: to) - toList += s + " "; + final StringBuilder toList = new StringBuilder(); + if (to != null) { + String separator = ""; + for (String s: to) { + toList.append(separator).append(s); + separator = " "; + } + } - String ccList = ""; - if (cc != null) - for (String s: cc) - ccList += s + " "; + final StringBuilder ccList = new StringBuilder(); + if (cc != null) { + for (String s: cc) { + ccList.append(s).append(" "); + } + } - return "From='" + from + return "From='" + from + "' To='" + toList + "' CC='" + ccList + "' Subject='" + subject + "' Attachments=" + hasAttachment; } - + public boolean hasAttachment() { return hasAttachment; } - + public void setHasAttachments(boolean hasAttachments) { this.hasAttachment = hasAttachments; } - + /** * Set the From: header field - * + * * @param from */ public void setFrom(String from) { @@ -72,7 +78,7 @@ /** * Return the From: header field - * + * * @return from */ public String getFrom() { @@ -90,7 +96,7 @@ /** * Set the Subject: header field - * + * * @param subject */ public void setSubject(String subject) { @@ -99,7 +105,7 @@ /** * Return the Subject: header field - * + * * @return subject */ public String getSubject() { @@ -113,7 +119,7 @@ public void setTo(ArrayList to) { this.to = to; } - + }