james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1064133 - in /james/mime4j/trunk: dom/src/main/java/org/apache/james/mime4j/message/ dom/src/main/java/org/apache/james/mime4j/storage/ dom/src/test/java/org/apache/james/mime4j/dom/ dom/src/test/java/org/apache/james/mime4j/message/ dom/s...
Date Thu, 27 Jan 2011 14:34:55 GMT
Author: olegk
Date: Thu Jan 27 14:34:53 2011
New Revision: 1064133

URL: http://svn.apache.org/viewvc?rev=1064133&view=rev
Log:
Decoupled storage and message code: the message package contains only a very basic BodyFactory interface and its default implementation whereas the storage package provides a feature complete version of BodyFactory with different storage backends

Added:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBinaryBody.java
      - copied, changed from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageBinaryBody.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBodyFactory.java
      - copied, changed from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageTextBody.java
      - copied, changed from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageTextBody.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StringTextBody.java
      - copied, changed from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringTextBody.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/storage/SingleBodyCopyTest.java
      - copied, changed from r1064123, james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/SingleBodyCopyTest.java
Removed:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageBinaryBody.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageTextBody.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringTextBody.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/SingleBodyCopyTest.java
Modified:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
    james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java
    james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java
    james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java?rev=1064133&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java Thu Jan 27 14:34:53 2011
@@ -0,0 +1,47 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.message;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.james.mime4j.dom.BinaryBody;
+
+class BasicBinaryBody extends BinaryBody {
+
+    private final byte[] content;
+    
+    BasicBinaryBody(final byte[] content) {
+        super();
+        this.content = content;
+    }
+    
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return new ByteArrayInputStream(this.content);
+    }
+    
+    @Override
+    public BasicBinaryBody copy() {
+        return new BasicBinaryBody(this.content);
+    }
+    
+}

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java?rev=1064133&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java Thu Jan 27 14:34:53 2011
@@ -0,0 +1,74 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.message;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.james.mime4j.dom.BinaryBody;
+import org.apache.james.mime4j.dom.TextBody;
+import org.apache.james.mime4j.util.CharsetUtil;
+
+/**
+ * Factory for creating message bodies.
+ */
+public class BasicBodyFactory implements BodyFactory {
+
+    private static String DEFAULT_CHARSET = CharsetUtil.DEFAULT_CHARSET.name();
+    
+    public BinaryBody binaryBody(final InputStream is) throws IOException {
+        return new BasicBinaryBody(bufferContent(is));
+    }
+
+    public TextBody textBody(final InputStream is, final String mimeCharset) throws IOException {
+        return new BasicTextBody(bufferContent(is), mimeCharset);
+    }
+ 
+    private static byte[] bufferContent(final InputStream is) throws IOException {
+        if (is == null) {
+            throw new IllegalArgumentException("Input stream may not be null");
+        }
+        ByteArrayOutputStream buf = new ByteArrayOutputStream();
+        byte[] tmp = new byte[2048];
+        int l;
+        while ((l = is.read(tmp)) != -1) {
+            buf.write(tmp, 0, l);
+        }
+        return buf.toByteArray();
+    }
+    
+    public TextBody textBody(final String text, final String mimeCharset) throws UnsupportedEncodingException {
+        if (text == null) {
+            throw new IllegalArgumentException("Text may not be null");
+        }
+        return new BasicTextBody(text.getBytes(mimeCharset), mimeCharset);
+    }
+
+    public TextBody textBody(final String text) throws UnsupportedEncodingException {
+        return textBody(text, DEFAULT_CHARSET);
+    }
+    
+    public BinaryBody binaryBody(final byte[] buf) {
+        return new BasicBinaryBody(buf);
+    }
+
+}

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java?rev=1064133&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java Thu Jan 27 14:34:53 2011
@@ -0,0 +1,62 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.message;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.apache.james.mime4j.dom.SingleBody;
+import org.apache.james.mime4j.dom.TextBody;
+
+class BasicTextBody extends TextBody {
+
+    private final byte[] content;
+    private final String charset;
+    
+    BasicTextBody(final byte[] content, final String charset) {
+        super();
+        this.content = content;
+        this.charset = charset;
+    }
+    
+    @Override
+    public String getMimeCharset() {
+        return this.charset;
+    }
+
+    @Override
+    public Reader getReader() throws IOException {
+        return new InputStreamReader(getInputStream(), this.charset);
+    }
+
+    @Override
+    public InputStream getInputStream() throws IOException {
+        return new ByteArrayInputStream(this.content);
+    }
+
+    @Override
+    public SingleBody copy() {
+        return new BasicTextBody(this.content, this.charset);
+    }
+    
+}

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java Thu Jan 27 14:34:53 2011
@@ -21,63 +21,14 @@ package org.apache.james.mime4j.message;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.Charset;
 
-import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.dom.BinaryBody;
-import org.apache.james.mime4j.dom.Disposable;
-import org.apache.james.mime4j.dom.SingleBody;
 import org.apache.james.mime4j.dom.TextBody;
-import org.apache.james.mime4j.storage.DefaultStorageProvider;
-import org.apache.james.mime4j.storage.MultiReferenceStorage;
-import org.apache.james.mime4j.storage.Storage;
-import org.apache.james.mime4j.storage.StorageProvider;
-import org.apache.james.mime4j.util.CharsetUtil;
 
 /**
  * Factory for creating message bodies.
  */
-public class BodyFactory {
-
-    private static final Charset FALLBACK_CHARSET = CharsetUtil.DEFAULT_CHARSET;
-
-    private final StorageProvider storageProvider;
-    private final DecodeMonitor monitor;
-
-    /**
-     * Creates a new <code>BodyFactory</code> instance that uses the default
-     * storage provider for creating message bodies from input streams.
-     */
-    public BodyFactory() {
-        this(null, null);
-    }
-
-    /**
-     * Creates a new <code>BodyFactory</code> instance that uses the given
-     * storage provider for creating message bodies from input streams.
-     * 
-     * @param storageProvider
-     *            a storage provider or <code>null</code> to use the default
-     *            one.
-     */
-    public BodyFactory(
-            final StorageProvider storageProvider,
-            final DecodeMonitor monitor) {
-        this.storageProvider = 
-            storageProvider != null ? storageProvider : DefaultStorageProvider.getInstance();
-        this.monitor = 
-            monitor != null ? monitor : DecodeMonitor.SILENT;
-    }
-
-    /**
-     * Returns the <code>StorageProvider</code> this <code>BodyFactory</code>
-     * uses to create message bodies from input streams.
-     * 
-     * @return a <code>StorageProvider</code>.
-     */
-    public StorageProvider getStorageProvider() {
-        return storageProvider;
-    }
+public interface BodyFactory {
 
     /**
      * Creates a {@link BinaryBody} that holds the content of the given input
@@ -89,59 +40,7 @@ public class BodyFactory {
      * @throws IOException
      *             if an I/O error occurs.
      */
-    public BinaryBody binaryBody(InputStream is) throws IOException {
-        if (is == null)
-            throw new IllegalArgumentException();
-
-        Storage storage = storageProvider.store(is);
-        return new StorageBinaryBody(new MultiReferenceStorage(storage));
-    }
-
-    /**
-     * Creates a {@link BinaryBody} that holds the content of the given
-     * {@link Storage}.
-     * <p>
-     * Note that the caller must not invoke {@link Storage#delete() delete()} on
-     * the given <code>Storage</code> object after it has been passed to this
-     * method. Instead the message body created by this method takes care of
-     * deleting the storage when it gets disposed of (see
-     * {@link Disposable#dispose()}).
-     * 
-     * @param storage
-     *            storage to create a message body from.
-     * @return a binary body.
-     * @throws IOException
-     *             if an I/O error occurs.
-     */
-    public BinaryBody binaryBody(Storage storage) throws IOException {
-        if (storage == null)
-            throw new IllegalArgumentException();
-
-        return new StorageBinaryBody(new MultiReferenceStorage(storage));
-    }
-
-    /**
-     * Creates a {@link TextBody} that holds the content of the given input
-     * stream.
-     * <p>
-     * &quot;us-ascii&quot; is used to decode the byte content of the
-     * <code>Storage</code> into a character stream when calling
-     * {@link TextBody#getReader() getReader()} on the returned object.
-     * 
-     * @param is
-     *            input stream to create a message body from.
-     * @return a text body.
-     * @throws IOException
-     *             if an I/O error occurs.
-     */
-    public TextBody textBody(InputStream is) throws IOException {
-        if (is == null)
-            throw new IllegalArgumentException();
-
-        Storage storage = storageProvider.store(is);
-        return new StorageTextBody(new MultiReferenceStorage(storage),
-                CharsetUtil.DEFAULT_CHARSET);
-    }
+    BinaryBody binaryBody(InputStream is) throws IOException;
 
     /**
      * Creates a {@link TextBody} that holds the content of the given input
@@ -161,163 +60,6 @@ public class BodyFactory {
      * @throws IOException
      *             if an I/O error occurs.
      */
-    public TextBody textBody(InputStream is, String mimeCharset)
-            throws IOException {
-        if (is == null)
-            throw new IllegalArgumentException();
-        if (mimeCharset == null)
-            throw new IllegalArgumentException();
-
-        Storage storage = storageProvider.store(is);
-        Charset charset = toJavaCharset(mimeCharset, false, monitor);
-        return new StorageTextBody(new MultiReferenceStorage(storage), charset);
-    }
-
-    /**
-     * Creates a {@link TextBody} that holds the content of the given
-     * {@link Storage}.
-     * <p>
-     * &quot;us-ascii&quot; is used to decode the byte content of the
-     * <code>Storage</code> into a character stream when calling
-     * {@link TextBody#getReader() getReader()} on the returned object.
-     * <p>
-     * Note that the caller must not invoke {@link Storage#delete() delete()} on
-     * the given <code>Storage</code> object after it has been passed to this
-     * method. Instead the message body created by this method takes care of
-     * deleting the storage when it gets disposed of (see
-     * {@link Disposable#dispose()}).
-     * 
-     * @param storage
-     *            storage to create a message body from.
-     * @return a text body.
-     * @throws IOException
-     *             if an I/O error occurs.
-     */
-    public TextBody textBody(Storage storage) throws IOException {
-        if (storage == null)
-            throw new IllegalArgumentException();
-
-        return new StorageTextBody(new MultiReferenceStorage(storage),
-                CharsetUtil.DEFAULT_CHARSET);
-    }
-
-    /**
-     * Creates a {@link TextBody} that holds the content of the given
-     * {@link Storage}.
-     * <p>
-     * The charset corresponding to the given MIME charset name is used to
-     * decode the byte content of the <code>Storage</code> into a character
-     * stream when calling {@link TextBody#getReader() getReader()} on the
-     * returned object. If the MIME charset has no corresponding Java charset or
-     * the Java charset cannot be used for decoding then &quot;us-ascii&quot; is
-     * used instead.
-     * <p>
-     * Note that the caller must not invoke {@link Storage#delete() delete()} on
-     * the given <code>Storage</code> object after it has been passed to this
-     * method. Instead the message body created by this method takes care of
-     * deleting the storage when it gets disposed of (see
-     * {@link Disposable#dispose()}).
-     * 
-     * @param storage
-     *            storage to create a message body from.
-     * @param mimeCharset
-     *            name of a MIME charset.
-     * @return a text body.
-     * @throws IOException
-     *             if an I/O error occurs.
-     */
-    public TextBody textBody(Storage storage, String mimeCharset)
-            throws IOException {
-        if (storage == null)
-            throw new IllegalArgumentException();
-        if (mimeCharset == null)
-            throw new IllegalArgumentException();
-
-        Charset charset = toJavaCharset(mimeCharset, false, monitor);
-        return new StorageTextBody(new MultiReferenceStorage(storage), charset);
-    }
-
-    /**
-     * Creates a {@link TextBody} that holds the content of the given string.
-     * <p>
-     * &quot;us-ascii&quot; is used to encode the characters of the string into
-     * a byte stream when calling
-     * {@link SingleBody#writeTo(java.io.OutputStream) writeTo(OutputStream)} on
-     * the returned object.
-     * 
-     * @param text
-     *            text to create a message body from.
-     * @return a text body.
-     */
-    public TextBody textBody(String text) {
-        if (text == null)
-            throw new IllegalArgumentException();
-
-        return new StringTextBody(text, CharsetUtil.DEFAULT_CHARSET);
-    }
-
-    /**
-     * Creates a {@link TextBody} that holds the content of the given string.
-     * <p>
-     * The charset corresponding to the given MIME charset name is used to
-     * encode the characters of the string into a byte stream when calling
-     * {@link SingleBody#writeTo(java.io.OutputStream) writeTo(OutputStream)} on
-     * the returned object. If the MIME charset has no corresponding Java
-     * charset or the Java charset cannot be used for encoding then
-     * &quot;us-ascii&quot; is used instead.
-     * 
-     * @param text
-     *            text to create a message body from.
-     * @param mimeCharset
-     *            name of a MIME charset.
-     * @return a text body.
-     */
-    public TextBody textBody(String text, String mimeCharset) {
-        if (text == null)
-            throw new IllegalArgumentException();
-        if (mimeCharset == null)
-            throw new IllegalArgumentException();
-
-        Charset charset = toJavaCharset(mimeCharset, true, monitor);
-        return new StringTextBody(text, charset);
-    }
-
-    private static Charset toJavaCharset(
-            final String mimeCharset, 
-            boolean forEncoding,
-            final DecodeMonitor monitor) {
-        String charset = CharsetUtil.toJavaCharset(mimeCharset);
-        if (charset == null) {
-            if (monitor.isListening()) {
-                monitor.warn(
-                        "MIME charset '" + mimeCharset + "' has no "
-                        + "corresponding Java charset", "Using "
-                        + FALLBACK_CHARSET + " instead.");
-            }
-            return FALLBACK_CHARSET;
-        }
-
-        if (forEncoding && !CharsetUtil.isEncodingSupported(charset)) {
-            if (monitor.isListening()) {
-                monitor.warn(
-                        "MIME charset '" + mimeCharset
-                        + "' does not support encoding", "Using "
-                        + FALLBACK_CHARSET + " instead.");
-            }
-            return FALLBACK_CHARSET;
-        }
-
-        if (!forEncoding && !CharsetUtil.isDecodingSupported(charset)) {
-            if (monitor.isListening()) {
-                monitor.warn(
-                        "MIME charset '" + mimeCharset
-                        + "' does not support decoding", "Using "
-                        + FALLBACK_CHARSET + " instead.");
-            }
-            return FALLBACK_CHARSET;
-        }
-
-        return Charset.forName(charset);
-    }
+    TextBody textBody(InputStream is, String mimeCharset) throws IOException;
 
 }

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java Thu Jan 27 14:34:53 2011
@@ -33,7 +33,6 @@ import org.apache.james.mime4j.dom.Multi
 import org.apache.james.mime4j.dom.field.Field;
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.parser.ContentHandler;
-import org.apache.james.mime4j.storage.StorageProvider;
 import org.apache.james.mime4j.stream.BodyDescriptor;
 import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.util.ByteArrayBuffer;
@@ -56,12 +55,12 @@ class EntityBuilder implements ContentHa
     
     public EntityBuilder(
             final Entity entity, 
-            final StorageProvider storageProvider, 
+            final BodyFactory bodyFactory, 
             final DecodeMonitor monitor) {
         this.entity = entity;
         this.stack = new Stack<Object>();
         this.monitor = monitor != null ? monitor : DecodeMonitor.SILENT;
-        this.bodyFactory = new BodyFactory(storageProvider, this.monitor);
+        this.bodyFactory = bodyFactory != null ? bodyFactory : new BasicBodyFactory();
     }
     
     private void expect(Class<?> c) {

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java Thu Jan 27 14:34:53 2011
@@ -27,7 +27,6 @@ import org.apache.james.mime4j.codec.Dec
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.MessageBuilder;
 import org.apache.james.mime4j.dom.ParseParams;
-import org.apache.james.mime4j.storage.StorageProvider;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 
@@ -38,7 +37,7 @@ import org.apache.james.mime4j.stream.Mu
 public class MessageBuilderImpl implements MessageBuilder {
 
     private MimeBuilder mimeBuilder = null;
-    private StorageProvider storageProvider = null;
+    private BodyFactory bodyFactory = null;
     private MimeEntityConfig mimeEntityConfig = null;
     private MutableBodyDescriptorFactory mutableBodyDescriptorFactory = null;
 
@@ -65,7 +64,7 @@ public class MessageBuilderImpl implemen
     public Message parse(InputStream source) throws MimeException, IOException {
         return getMimeBuilder().parse(source, 
                 mimeEntityConfig, 
-                storageProvider, 
+                bodyFactory, 
                 mutableBodyDescriptorFactory, 
                 null,
                 null);
@@ -76,14 +75,14 @@ public class MessageBuilderImpl implemen
             ParseParams params, DecodeMonitor decodeMonitor) throws MimeException, IOException {
         return getMimeBuilder().parse(source, 
                 mimeEntityConfig, 
-                storageProvider, 
+                bodyFactory, 
                 mutableBodyDescriptorFactory, 
                 params,
                 decodeMonitor);
     }
     
-    public void setStorageProvider(StorageProvider storageProvider) {
-        this.storageProvider = storageProvider;
+    public void setBodyFactory(BodyFactory bodyFactory) {
+        this.bodyFactory = bodyFactory;
     }
 
     public void setMimeEntityConfig(MimeEntityConfig mimeEntityConfig) {

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java Thu Jan 27 14:34:53 2011
@@ -21,7 +21,6 @@ package org.apache.james.mime4j.message;
 import org.apache.james.mime4j.dom.MessageBuilder;
 import org.apache.james.mime4j.dom.MessageServiceFactory;
 import org.apache.james.mime4j.dom.MessageFormatter;
-import org.apache.james.mime4j.storage.StorageProvider;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 
@@ -33,14 +32,14 @@ import org.apache.james.mime4j.stream.Mu
  */
 public class MessageServiceFactoryImpl extends MessageServiceFactory {
 
-    private StorageProvider storageProvider = null;
+    private BodyFactory bodyFactory = null;
     private MimeEntityConfig mimeEntityConfig = null;
     private MutableBodyDescriptorFactory mutableBodyDescriptorFactory = null;
 
     @Override
     public MessageBuilder newMessageBuilder() {
         MessageBuilderImpl m = new MessageBuilderImpl();
-        if (storageProvider != null) m.setStorageProvider(storageProvider);
+        if (bodyFactory != null) m.setBodyFactory(bodyFactory);
         if (mimeEntityConfig != null) m.setMimeEntityConfig(mimeEntityConfig);
         if (mutableBodyDescriptorFactory != null) m.setMutableBodyDescriptorFactory(mutableBodyDescriptorFactory);
         return m;
@@ -55,11 +54,11 @@ public class MessageServiceFactoryImpl e
     @Override
     public void setAttribute(String name, Object value)
             throws IllegalArgumentException {
-        if ("StorageProvider".equals(name)) {
-            if (value instanceof StorageProvider) {
-                this.storageProvider  = (StorageProvider) value;
+        if ("BodyFactory".equals(name)) {
+            if (value instanceof BodyFactory) {
+                this.bodyFactory  = (BodyFactory) value;
                 return;
-            } else throw new IllegalArgumentException("Unsupported attribute value type for "+name+", expected a StorageProvider");
+            } else throw new IllegalArgumentException("Unsupported attribute value type for "+name+", expected a BodyFactory");
         } else if ("MimeEntityConfig".equals(name)) {
             if (value instanceof MimeEntityConfig) {
                 this.mimeEntityConfig = (MimeEntityConfig) value;

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MimeBuilder.java Thu Jan 27 14:34:53 2011
@@ -37,8 +37,6 @@ import org.apache.james.mime4j.dom.field
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.parser.AbstractContentHandler;
 import org.apache.james.mime4j.parser.MimeStreamParser;
-import org.apache.james.mime4j.storage.DefaultStorageProvider;
-import org.apache.james.mime4j.storage.StorageProvider;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 import org.apache.james.mime4j.stream.RawField;
@@ -236,8 +234,8 @@ public class MimeBuilder {
      *            the stream to parse.
      * @param config
      *            {@link MimeEntityConfig} to use.
-     * @param storageProvider
-     *            {@link StorageProvider} to use for storing text and binary
+     * @param bodyFactory
+     *            {@link BodyFactory} to use for storing text and binary
      *            message bodies.
      * @param bodyDescFactory
      *            {@link MutableBodyDescriptorFactory} to use for creating body descriptors.
@@ -249,7 +247,7 @@ public class MimeBuilder {
     public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
-            final StorageProvider storageProvider, 
+            final BodyFactory bodyFactory, 
             final MutableBodyDescriptorFactory bodyDescFactory,
             final ParseParams params,
             final DecodeMonitor monitor) throws IOException, MimeIOException {
@@ -257,7 +255,7 @@ public class MimeBuilder {
             MessageImpl message = new MessageImpl();
             DecodeMonitor mon = monitor != null ? monitor : DecodeMonitor.SILENT;
             MimeStreamParser parser = new MimeStreamParser(config, bodyDescFactory, mon);
-            parser.setContentHandler(new EntityBuilder(message, storageProvider, mon));
+            parser.setContentHandler(new EntityBuilder(message, bodyFactory, mon));
             if (params != null) {
                 parser.setContentDecoding(params.isContentDecoding());
                 if (params.isFlatMode()) {
@@ -297,25 +295,25 @@ public class MimeBuilder {
     public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
-            final StorageProvider storageProvider, 
+            final BodyFactory bodyFactory, 
             final MutableBodyDescriptorFactory bodyDescFactory,
             final DecodeMonitor monitor) throws IOException, MimeIOException {
-        return parse(is, config, storageProvider, bodyDescFactory, null, monitor);
+        return parse(is, config, bodyFactory, bodyDescFactory, null, monitor);
     }
     
     public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
-            final StorageProvider storageProvider,
+            final BodyFactory bodyFactory, 
             final MutableBodyDescriptorFactory bodyDescFactory) throws IOException, MimeIOException {
-        return parse(is, config, storageProvider, bodyDescFactory, null);
+        return parse(is, config, bodyFactory, bodyDescFactory, null);
     }
 
     public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
-            final StorageProvider storageProvider) throws IOException, MimeIOException {
-        return parse(is, config, storageProvider, null, null);
+            final BodyFactory bodyFactory) throws IOException, MimeIOException {
+        return parse(is, config, bodyFactory, null, null);
     }
 
     /**
@@ -330,7 +328,7 @@ public class MimeBuilder {
      *             on MIME protocol violations.
      */
     public Message parse(InputStream is) throws IOException, MimeIOException {
-        return parse(is, null, DefaultStorageProvider.getInstance());
+        return parse(is, null, null);
     }
 
     /**
@@ -346,7 +344,7 @@ public class MimeBuilder {
      */
     public Message parse(InputStream is, MimeEntityConfig config) throws IOException,
             MimeIOException {
-        return parse(is, config, DefaultStorageProvider.getInstance());
+        return parse(is, config, null);
     }
     
 }

Copied: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBinaryBody.java (from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageBinaryBody.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBinaryBody.java?p2=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBinaryBody.java&p1=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageBinaryBody.java&r1=1064123&r2=1064133&rev=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageBinaryBody.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBinaryBody.java Thu Jan 27 14:34:53 2011
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.message;
+package org.apache.james.mime4j.storage;
 
 import java.io.IOException;
 import java.io.InputStream;

Copied: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBodyFactory.java (from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBodyFactory.java?p2=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBodyFactory.java&p1=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java&r1=1064123&r2=1064133&rev=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageBodyFactory.java Thu Jan 27 14:34:53 2011
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.message;
+package org.apache.james.mime4j.storage;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -28,6 +28,7 @@ import org.apache.james.mime4j.dom.Binar
 import org.apache.james.mime4j.dom.Disposable;
 import org.apache.james.mime4j.dom.SingleBody;
 import org.apache.james.mime4j.dom.TextBody;
+import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
 import org.apache.james.mime4j.storage.MultiReferenceStorage;
 import org.apache.james.mime4j.storage.Storage;
@@ -37,7 +38,7 @@ import org.apache.james.mime4j.util.Char
 /**
  * Factory for creating message bodies.
  */
-public class BodyFactory {
+public class StorageBodyFactory implements BodyFactory {
 
     private static final Charset FALLBACK_CHARSET = CharsetUtil.DEFAULT_CHARSET;
 
@@ -48,7 +49,7 @@ public class BodyFactory {
      * Creates a new <code>BodyFactory</code> instance that uses the default
      * storage provider for creating message bodies from input streams.
      */
-    public BodyFactory() {
+    public StorageBodyFactory() {
         this(null, null);
     }
 
@@ -60,7 +61,7 @@ public class BodyFactory {
      *            a storage provider or <code>null</code> to use the default
      *            one.
      */
-    public BodyFactory(
+    public StorageBodyFactory(
             final StorageProvider storageProvider,
             final DecodeMonitor monitor) {
         this.storageProvider = 

Copied: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageTextBody.java (from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageTextBody.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageTextBody.java?p2=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageTextBody.java&p1=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageTextBody.java&r1=1064123&r2=1064133&rev=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StorageTextBody.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StorageTextBody.java Thu Jan 27 14:34:53 2011
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.message;
+package org.apache.james.mime4j.storage;
 
 import java.io.IOException;
 import java.io.InputStream;

Copied: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StringTextBody.java (from r1064123, james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringTextBody.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StringTextBody.java?p2=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StringTextBody.java&p1=james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringTextBody.java&r1=1064123&r2=1064133&rev=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringTextBody.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/storage/StringTextBody.java Thu Jan 27 14:34:53 2011
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.message;
+package org.apache.james.mime4j.storage;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java Thu Jan 27 14:34:53 2011
@@ -23,7 +23,7 @@ import org.apache.james.mime4j.dom.Body;
 import org.apache.james.mime4j.dom.Entity;
 import org.apache.james.mime4j.dom.Header;
 import org.apache.james.mime4j.field.DefaultFieldParser;
-import org.apache.james.mime4j.message.BodyFactory;
+import org.apache.james.mime4j.message.BasicBodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.HeaderImpl;
 
@@ -35,7 +35,7 @@ public class EntityTest extends TestCase
         Entity entity = new BodyPart();
         assertNull(entity.getBody());
 
-        Body body = new BodyFactory().textBody("test");
+        Body body = new BasicBodyFactory().textBody("test");
         assertNull(body.getParent());
 
         entity.setBody(body);
@@ -46,8 +46,8 @@ public class EntityTest extends TestCase
     public void testSetBodyTwice() throws Exception {
         Entity entity = new BodyPart();
 
-        Body b1 = new BodyFactory().textBody("foo");
-        Body b2 = new BodyFactory().textBody("bar");
+        Body b1 = new BasicBodyFactory().textBody("foo");
+        Body b2 = new BasicBodyFactory().textBody("bar");
 
         entity.setBody(b1);
         try {
@@ -59,7 +59,7 @@ public class EntityTest extends TestCase
 
     public void testRemoveBody() throws Exception {
         Entity entity = new BodyPart();
-        Body body = new BodyFactory().textBody("test");
+        Body body = new BasicBodyFactory().textBody("test");
         entity.setBody(body);
 
         Body removed = entity.removeBody();

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MimeBuilderCopyTest.java Thu Jan 27 14:34:53 2011
@@ -28,7 +28,7 @@ import org.apache.james.mime4j.dom.Heade
 import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.dom.field.Field;
 import org.apache.james.mime4j.field.DefaultFieldParser;
-import org.apache.james.mime4j.message.BodyFactory;
+import org.apache.james.mime4j.message.BasicBodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.MessageImpl;
@@ -52,7 +52,7 @@ public class MimeBuilderCopyTest extends
     public void testCopyMessage() throws Exception {
         MessageImpl parent = new MessageImpl();
         Header header = new HeaderImpl();
-        Body body = new BodyFactory().textBody("test");
+        Body body = new BasicBodyFactory().textBody("test");
 
         MessageImpl original = new MessageImpl();
         original.setHeader(header);
@@ -85,7 +85,7 @@ public class MimeBuilderCopyTest extends
     public void testCopyBodyPart() throws Exception {
         MessageImpl parent = new MessageImpl();
         Header header = new HeaderImpl();
-        Body body = new BodyFactory().textBody("test");
+        Body body = new BasicBodyFactory().textBody("test");
 
         BodyPart original = new BodyPart();
         original.setHeader(header);

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java Thu Jan 27 14:34:53 2011
@@ -26,7 +26,7 @@ import junit.framework.TestCase;
 import org.apache.james.mime4j.dom.Header;
 import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.field.DefaultFieldParser;
-import org.apache.james.mime4j.message.BodyFactory;
+import org.apache.james.mime4j.message.BasicBodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.MessageImpl;
@@ -36,7 +36,7 @@ import org.apache.james.mime4j.message.M
 public class MultipartFormTest extends TestCase {
 
     public void testMultipartFormContent() throws Exception {
-        BodyFactory bodyFactory = new BodyFactory();
+        BasicBodyFactory bodyFactory = new BasicBodyFactory();
         
         MessageImpl message = new MessageImpl();
         Header header = new HeaderImpl();

Copied: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/storage/SingleBodyCopyTest.java (from r1064123, james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/SingleBodyCopyTest.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/storage/SingleBodyCopyTest.java?p2=james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/storage/SingleBodyCopyTest.java&p1=james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/SingleBodyCopyTest.java&r1=1064123&r2=1064133&rev=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/SingleBodyCopyTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/storage/SingleBodyCopyTest.java Thu Jan 27 14:34:53 2011
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.message;
+package org.apache.james.mime4j.storage;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -26,12 +26,6 @@ import junit.framework.TestCase;
 
 import org.apache.james.mime4j.dom.SingleBody;
 import org.apache.james.mime4j.message.MessageImpl;
-import org.apache.james.mime4j.message.StorageBinaryBody;
-import org.apache.james.mime4j.message.StorageTextBody;
-import org.apache.james.mime4j.message.StringTextBody;
-import org.apache.james.mime4j.storage.MemoryStorageProvider;
-import org.apache.james.mime4j.storage.MultiReferenceStorage;
-import org.apache.james.mime4j.storage.Storage;
 import org.apache.james.mime4j.util.CharsetUtil;
 
 public class SingleBodyCopyTest extends TestCase {

Modified: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java (original)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java Thu Jan 27 14:34:53 2011
@@ -33,12 +33,12 @@ import org.apache.james.mime4j.dom.Binar
 import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.field.address.AddressBuilder;
-import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.MessageImpl;
 import org.apache.james.mime4j.message.MimeWriter;
 import org.apache.james.mime4j.message.MultipartImpl;
 import org.apache.james.mime4j.storage.Storage;
+import org.apache.james.mime4j.storage.StorageBodyFactory;
 import org.apache.james.mime4j.storage.StorageOutputStream;
 import org.apache.james.mime4j.storage.StorageProvider;
 
@@ -75,7 +75,7 @@ public class MultipartMessage {
         multipart.setPreamble("This is a multi-part message in MIME format.");
 
         // first part is text/plain
-        BodyFactory bodyFactory = new BodyFactory();
+        StorageBodyFactory bodyFactory = new StorageBodyFactory();
         BodyPart textPart = createTextPart(bodyFactory, "Why so serious?");
         multipart.addBodyPart(textPart);
 
@@ -99,7 +99,7 @@ public class MultipartMessage {
     /**
      * Creates a text part from the specified string.
      */
-    private static BodyPart createTextPart(BodyFactory bodyFactory, String text) {
+    private static BodyPart createTextPart(StorageBodyFactory bodyFactory, String text) {
         // Use UTF-8 to encode the specified text
         TextBody body = bodyFactory.textBody(text, "UTF-8");
 
@@ -114,7 +114,7 @@ public class MultipartMessage {
     /**
      * Creates a binary part from the specified image.
      */
-    private static BodyPart createImagePart(BodyFactory bodyFactory,
+    private static BodyPart createImagePart(StorageBodyFactory bodyFactory,
             BufferedImage image) throws IOException {
         // Create a binary message body from the image
         StorageProvider storageProvider = bodyFactory.getStorageProvider();

Modified: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java (original)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java Thu Jan 27 14:34:53 2011
@@ -25,9 +25,9 @@ import java.util.Date;
 import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.field.address.ParseException;
-import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.MessageImpl;
 import org.apache.james.mime4j.message.MimeWriter;
+import org.apache.james.mime4j.storage.StorageBodyFactory;
 
 /**
  * This example generates a message very similar to the one from RFC 5322
@@ -54,7 +54,7 @@ public class TextPlainMessage {
 
         // 3) set a text body
 
-        BodyFactory bodyFactory = new BodyFactory();
+        StorageBodyFactory bodyFactory = new StorageBodyFactory();
         TextBody body = bodyFactory.textBody("This is a message just to "
                 + "say hello.\r\nSo, \"Hello\".");
 

Modified: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java?rev=1064133&r1=1064132&r2=1064133&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java (original)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java Thu Jan 27 14:34:53 2011
@@ -31,13 +31,13 @@ import org.apache.james.mime4j.dom.Multi
 import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.dom.field.ParseException;
 import org.apache.james.mime4j.field.address.AddressBuilder;
-import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.MessageImpl;
 import org.apache.james.mime4j.message.MimeBuilder;
 import org.apache.james.mime4j.message.MimeWriter;
 import org.apache.james.mime4j.message.MultipartImpl;
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
+import org.apache.james.mime4j.storage.StorageBodyFactory;
 import org.apache.james.mime4j.storage.StorageProvider;
 import org.apache.james.mime4j.storage.TempFileStorageProvider;
 
@@ -152,7 +152,7 @@ public class TransformMessage {
      * Creates a text part from the specified string.
      */
     private static BodyPart createTextPart(String text) {
-        TextBody body = new BodyFactory().textBody(text, "UTF-8");
+        TextBody body = new StorageBodyFactory().textBody(text, "UTF-8");
 
         BodyPart bodyPart = new BodyPart();
         bodyPart.setText(body);
@@ -169,7 +169,7 @@ public class TransformMessage {
         byte[] data = new byte[numberOfBytes];
         new Random().nextBytes(data);
 
-        Body body = new BodyFactory()
+        Body body = new StorageBodyFactory()
                 .binaryBody(new ByteArrayInputStream(data));
 
         BodyPart bodyPart = new BodyPart();



Mime
View raw message