james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1061294 - in /james/mime4j/branches/dom-api-refactoring: dom/src/main/java/org/apache/james/mime4j/message/ dom/src/test/java/org/apache/james/mime4j/dom/ examples/src/main/java/org/apache/james/mime4j/samples/transform/ examples/src/main/...
Date Thu, 20 Jan 2011 13:32:04 GMT
Author: olegk
Date: Thu Jan 20 13:32:03 2011
New Revision: 1061294

URL: http://svn.apache.org/viewvc?rev=1061294&view=rev
Log:
Made methods of AddressFormatter, AddressBuilder and MimeBuilder non-static; renamed MessageWriter
to MimeWriter

Modified:
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
    james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
    james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
Thu Jan 20 13:32:03 2011
@@ -34,12 +34,12 @@ public class MessageBuilderImpl extends 
 
     @Override
     public Message newMessage(Message source) {
-        return MimeBuilder.copy(source);
+        return MimeBuilder.DEFAULT.copy(source);
     }
 
     @Override
     public Message parse(InputStream source) throws MimeException, IOException {
-        return MimeBuilder.parse(source, 
+        return MimeBuilder.DEFAULT.parse(source, 
                 mimeEntityConfig, 
                 storageProvider, 
                 mutableBodyDescriptorFactory, 

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java
Thu Jan 20 13:32:03 2011
@@ -45,9 +45,12 @@ import org.apache.james.mime4j.stream.Ra
 /**
  * Utility class for copying message and parsing message elements.
  */
-public final class MimeBuilder {
+public class MimeBuilder {
 
-    private MimeBuilder() {
+    public static final MimeBuilder DEFAULT = new MimeBuilder();
+    
+    protected MimeBuilder() {
+        super();
     }
 
     /**
@@ -60,7 +63,7 @@ public final class MimeBuilder {
      * @param other
      *            header to copy.
      */
-    public static Header copy(Header other) {
+    public Header copy(Header other) {
         HeaderImpl copy = new HeaderImpl();
         for (Field otherField : other.getFields()) {
             copy.addField(otherField);
@@ -85,7 +88,7 @@ public final class MimeBuilder {
      *             is neither a {@link Message}, {@link Multipart} or
      *             {@link SingleBody}.
      */
-    public static BodyPart copy(Entity other) {
+    public BodyPart copy(Entity other) {
         BodyPart copy = new BodyPart(); 
         if (other.getHeader() != null) {
             copy.setHeader(copy(other.getHeader()));
@@ -114,7 +117,7 @@ public final class MimeBuilder {
      *             is neither a {@link Message}, {@link Multipart} or
      *             {@link SingleBody}.
      */
-    public static Multipart copy(Multipart other) {
+    public Multipart copy(Multipart other) {
         MultipartImpl copy = new MultipartImpl(other.getSubType());
         for (Entity otherBodyPart : other.getBodyParts()) {
             copy.addBodyPart(copy(otherBodyPart));
@@ -147,7 +150,7 @@ public final class MimeBuilder {
      *             a {@link MessageImpl}, {@link Multipart} or {@link SingleBody}
      *             (or contains such a <code>Body</code>).
      */
-    public static Body copy(Body body) {
+    public Body copy(Body body) {
         if (body == null)
             throw new IllegalArgumentException("Body is null");
 
@@ -181,7 +184,7 @@ public final class MimeBuilder {
      *             is neither a {@link MessageImpl}, {@link Multipart} or
      *             {@link SingleBody}.
      */
-    public static Message copy(Message other) {
+    public Message copy(Message other) {
         MessageImpl copy = new MessageImpl();
         if (other.getHeader() != null) {
             copy.setHeader(copy(other.getHeader()));
@@ -200,7 +203,7 @@ public final class MimeBuilder {
      * @throws IOException on I/O errors.
      * @throws MimeIOException on MIME protocol violations.
      */
-    public static Header parse(
+    public Header parse(
             final InputStream is,
             final DecodeMonitor monitor) throws IOException, MimeIOException {
         final HeaderImpl header = new HeaderImpl();
@@ -242,7 +245,7 @@ public final class MimeBuilder {
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public static Message parse(
+    public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
             final StorageProvider storageProvider, 
@@ -282,7 +285,7 @@ public final class MimeBuilder {
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public static Message parse(
+    public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
             final StorageProvider storageProvider, 
@@ -291,7 +294,7 @@ public final class MimeBuilder {
         return parse(is, config, storageProvider, bodyDescFactory, monitor, true, false);
     }
     
-    public static Message parse(
+    public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
             final StorageProvider storageProvider,
@@ -299,7 +302,7 @@ public final class MimeBuilder {
         return parse(is, config, storageProvider, bodyDescFactory, null);
     }
 
-    public static Message parse(
+    public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
             final StorageProvider storageProvider) throws IOException, MimeIOException {
@@ -317,7 +320,7 @@ public final class MimeBuilder {
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public static Message parse(InputStream is) throws IOException, MimeIOException {
+    public Message parse(InputStream is) throws IOException, MimeIOException {
         return parse(is, null, DefaultStorageProvider.getInstance());
     }
 
@@ -332,7 +335,7 @@ public final class MimeBuilder {
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public static Message parse(InputStream is, MimeEntityConfig config) throws IOException,
+    public Message parse(InputStream is, MimeEntityConfig config) throws IOException,
             MimeIOException {
         return parse(is, config, DefaultStorageProvider.getInstance());
     }

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
Thu Jan 20 13:32:03 2011
@@ -58,7 +58,7 @@ public class ExampleMessagesRoundtripTes
             config.setMalformedHeaderStartsBody(true);
         }
         config.setMaxLineLen(-1);
-        Message inputMessage = MimeBuilder.parse(url.openStream(), config);
+        Message inputMessage = MimeBuilder.DEFAULT.parse(url.openStream(), config);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         inputMessage.writeTo(out);
         

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
Thu Jan 20 13:32:03 2011
@@ -55,7 +55,7 @@ public class MessageCompleteMailTest ext
 
     private Message createMessage(byte[] octets) throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(octets);
-        Message message = MimeBuilder.parse(in);
+        Message message = MimeBuilder.DEFAULT.parse(in);
         return message;
     }
 }

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
Thu Jan 20 13:32:03 2011
@@ -44,7 +44,7 @@ public class MessageHeadlessParserTest e
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setMalformedHeaderStartsBody(true);
-		Message message = MimeBuilder.parse(new ByteArrayInputStream(headlessContent
+		Message message = MimeBuilder.DEFAULT.parse(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("text/plain", message.getMimeType());
 		assertEquals(1, message.getHeader().getFields().size());
@@ -62,7 +62,7 @@ public class MessageHeadlessParserTest e
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setMalformedHeaderStartsBody(true);
-		Message message = MimeBuilder.parse(new ByteArrayInputStream(headlessContent
+		Message message = MimeBuilder.DEFAULT.parse(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("text/plain", message.getMimeType());
 		assertEquals(0, message.getHeader().getFields().size());
@@ -89,7 +89,7 @@ public class MessageHeadlessParserTest e
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setHeadlessParsing(contentType);
-		Message message = MimeBuilder.parse(new ByteArrayInputStream(headlessContent
+		Message message = MimeBuilder.DEFAULT.parse(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("multipart/form-data", message.getMimeType());
 		assertEquals(1, message.getHeader().getFields().size());

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
Thu Jan 20 13:32:03 2011
@@ -102,7 +102,7 @@ public class MessageParserTest extends T
             config.setMalformedHeaderStartsBody(true);
         }
         config.setMaxLineLen(-1);
-        Message m = MimeBuilder.parse(url.openStream(), config);
+        Message m = MimeBuilder.DEFAULT.parse(url.openStream(), config);
         
         String s = url.toString();
         String prefix = s.substring(0, s.lastIndexOf('.'));

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
Thu Jan 20 13:32:03 2011
@@ -133,7 +133,7 @@ public class MessageTest extends TestCas
     public void testWriteTo() throws Exception {
         byte[] inputByte = getRawMessageAsByteArray();
 
-        Message m = MimeBuilder.parse(new ByteArrayInputStream(inputByte));
+        Message m = MimeBuilder.DEFAULT.parse(new ByteArrayInputStream(inputByte));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
         m.writeTo(out);
@@ -155,7 +155,7 @@ public class MessageTest extends TestCas
 
         byte[] inputByte = getRawMessageAsByteArray();
 
-        Message m = MimeBuilder.parse(new ByteArrayInputStream(inputByte));
+        Message m = MimeBuilder.DEFAULT.parse(new ByteArrayInputStream(inputByte));
         m.getHeader().addField(DefaultFieldParser.parse(testheader));
 
         assertEquals("header added", m.getHeader().getField(headerName)

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
Thu Jan 20 13:32:03 2011
@@ -83,7 +83,7 @@ public class MessageWriteToTest extends 
     
     private Message createMessage(byte[] octets) throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(octets);
-        Message message = MimeBuilder.parse(in);
+        Message message = MimeBuilder.DEFAULT.parse(in);
         return message;
     }
 }

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
Thu Jan 20 13:32:03 2011
@@ -42,7 +42,7 @@ public class MimeBuilderCopyTest extends
     public void testCopyEmptyMessage() throws Exception {
         MessageImpl original = new MessageImpl();
 
-        Message copy = MimeBuilder.copy(original);
+        Message copy = MimeBuilder.DEFAULT.copy(original);
 
         assertNull(copy.getHeader());
         assertNull(copy.getBody());
@@ -59,7 +59,7 @@ public class MimeBuilderCopyTest extends
         original.setBody(body);
         original.setParent(parent);
 
-        Message copy = MimeBuilder.copy(original);
+        Message copy = MimeBuilder.DEFAULT.copy(original);
 
         assertNotNull(copy.getHeader());
         assertNotSame(header, copy.getHeader());
@@ -75,7 +75,7 @@ public class MimeBuilderCopyTest extends
     public void testCopyEmptyBodyPart() throws Exception {
         BodyPart original = new BodyPart();
 
-        BodyPart copy = MimeBuilder.copy(original);
+        BodyPart copy = MimeBuilder.DEFAULT.copy(original);
 
         assertNull(copy.getHeader());
         assertNull(copy.getBody());
@@ -92,7 +92,7 @@ public class MimeBuilderCopyTest extends
         original.setBody(body);
         original.setParent(parent);
 
-        BodyPart copy = MimeBuilder.copy(original);
+        BodyPart copy = MimeBuilder.DEFAULT.copy(original);
 
         assertNotNull(copy.getHeader());
         assertNotSame(header, copy.getHeader());
@@ -108,7 +108,7 @@ public class MimeBuilderCopyTest extends
     public void testCopyEmptyMultipart() throws Exception {
         Multipart original = new MultipartImpl("mixed");
 
-        Multipart copy = MimeBuilder.copy(original);
+        Multipart copy = MimeBuilder.DEFAULT.copy(original);
 
         assertSame(original.getPreamble(), copy.getPreamble());
         assertSame(original.getEpilogue(), copy.getEpilogue());
@@ -127,7 +127,7 @@ public class MimeBuilderCopyTest extends
         original.setParent(parent);
         original.addBodyPart(bodyPart);
 
-        Multipart copy = MimeBuilder.copy(original);
+        Multipart copy = MimeBuilder.DEFAULT.copy(original);
 
         assertSame(original.getPreamble(), copy.getPreamble());
         assertSame(original.getEpilogue(), copy.getEpilogue());
@@ -154,7 +154,7 @@ public class MimeBuilderCopyTest extends
         original.setHeader(new HeaderImpl());
         original.setBody(multipart);
 
-        Message copy = MimeBuilder.copy(original);
+        Message copy = MimeBuilder.DEFAULT.copy(original);
 
         Multipart multipartCopy = (Multipart) copy.getBody();
         List<Entity> bodyParts = multipartCopy.getBodyParts();
@@ -180,7 +180,7 @@ public class MimeBuilderCopyTest extends
         original.addField(f2);
         original.addField(f3);
 
-        Header copy = MimeBuilder.copy(original);
+        Header copy = MimeBuilder.DEFAULT.copy(original);
 
         // copy must have same fields as original
         assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());

Modified: james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
Thu Jan 20 13:32:03 2011
@@ -91,7 +91,7 @@ public class TransformMessage {
     private static Message transform(Message original) throws IOException, ParseException
{
         // Create a copy of the template. The copy can be modified without
         // affecting the original.
-        Message message = MimeBuilder.copy(original);
+        Message message = MimeBuilder.DEFAULT.copy(original);
 
         // In this example we know we have a multipart message. Use
         // Message#isMultipart() if uncertain.

Modified: james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java?rev=1061294&r1=1061293&r2=1061294&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java
(original)
+++ james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java
Thu Jan 20 13:32:03 2011
@@ -366,7 +366,7 @@ public class MessageTree extends JPanel 
     public static void main(String[] args) {
         try {
 
-            final Message message = MimeBuilder.parse(new FileInputStream(args[0]));
+            final Message message = MimeBuilder.DEFAULT.parse(new FileInputStream(args[0]));
 
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                 public void run() {



Mime
View raw message