james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1086652 - in /james/mime4j/trunk: core/src/main/java/org/apache/james/mime4j/parser/ core/src/main/java/org/apache/james/mime4j/stream/ core/src/test/java/org/apache/james/mime4j/stream/ dom/src/main/java/org/apache/james/mime4j/message/
Date Tue, 29 Mar 2011 17:52:23 GMT
Author: olegk
Date: Tue Mar 29 17:52:22 2011
New Revision: 1086652

URL: http://svn.apache.org/viewvc?rev=1086652&view=rev
Log:
MIME4J-165: Use FieldBuilder to build MIME fields from individual lines. Concrete implementations
of this interface can choose to truncate MIME fields that exceed a particular limit or to
ignore certain fields altogether. 

Added:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java
  (with props)
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java
  (with props)
Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeEntityTest.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/MimeBuilder.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java?rev=1086652&r1=1086651&r2=1086652&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
Tue Mar 29 17:52:22 2011
@@ -64,9 +64,9 @@ public class MimeStreamParser {
     public MimeStreamParser(
             final MimeEntityConfig config, 
             boolean clone,
-            final MutableBodyDescriptorFactory bodyDescFactory,
-            final DecodeMonitor monitor) {
-        this(new MimeTokenStream(clone ? config.clone() : config, bodyDescFactory, monitor));
+            final DecodeMonitor monitor,
+            final MutableBodyDescriptorFactory bodyDescFactory) {
+        this(new MimeTokenStream(clone ? config.clone() : config, monitor, bodyDescFactory));
     }
 
     public MimeStreamParser(final MimeEntityConfig config, boolean clone) {
@@ -74,11 +74,11 @@ public class MimeStreamParser {
     }
 
     public MimeStreamParser(
-            final MimeEntityConfig config, 
-            final MutableBodyDescriptorFactory bodyDescFactory,
-            final DecodeMonitor monitor) {
+            final MimeEntityConfig config,
+            final DecodeMonitor monitor,
+            final MutableBodyDescriptorFactory bodyDescFactory) {
         this(config != null ? config : new MimeEntityConfig(), config != null, 
-                bodyDescFactory, monitor);
+                monitor, bodyDescFactory);
     }
 
     public MimeStreamParser(final MimeEntityConfig config) {

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java?rev=1086652&r1=1086651&r2=1086652&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java
Tue Mar 29 17:52:22 2011
@@ -24,7 +24,6 @@ import java.io.IOException;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.io.LineReaderInputStream;
-import org.apache.james.mime4j.io.MaxHeaderLengthLimitException;
 import org.apache.james.mime4j.io.MaxHeaderLimitException;
 import org.apache.james.mime4j.io.MaxLineLimitException;
 import org.apache.james.mime4j.util.ByteArrayBuffer;
@@ -33,39 +32,42 @@ import org.apache.james.mime4j.util.Char
 /**
  * Abstract MIME entity.
  */
-public abstract class AbstractEntity implements EntityStateMachine {
+abstract class AbstractEntity implements EntityStateMachine {
 
     protected final EntityState startState;
     protected final EntityState endState;
     protected final MimeEntityConfig config;
+    protected final DecodeMonitor monitor;
+    protected final FieldBuilder fieldBuilder;
     protected final MutableBodyDescriptor body;
-    
-    protected EntityState state;
 
     private final ByteArrayBuffer linebuf;
 
+    protected EntityState state;
     private int lineCount;
-    private RawField field;
     private boolean endOfHeader;
     private int headerCount;
-    protected final DecodeMonitor monitor;
+    private RawField field;
 
     AbstractEntity(
-            MutableBodyDescriptor body,
-            EntityState startState, 
-            EntityState endState,
             MimeEntityConfig config,
-            DecodeMonitor monitor) {
+            EntityState startState,
+            EntityState endState,
+            DecodeMonitor monitor,
+            FieldBuilder fieldBuilder,
+            MutableBodyDescriptor body) {
+        this.config = config;
         this.state = startState;
         this.startState = startState;
         this.endState = endState;
-        this.config = config;
+        this.monitor = monitor;
+        this.fieldBuilder = fieldBuilder;
         this.body = body;
+
         this.linebuf = new ByteArrayBuffer(64);
         this.lineCount = 0;
         this.endOfHeader = false;
         this.headerCount = 0;
-        this.monitor = monitor;
     }
 
     public EntityState getState() {
@@ -77,27 +79,20 @@ public abstract class AbstractEntity imp
      * information is not available.
      */
     protected abstract int getLineNumber();
-    
+
     protected abstract LineReaderInputStream getDataStream();
-    
-    private ByteArrayBuffer fillFieldBuffer() throws IOException, MimeException {
-        if (endOfHeader) 
-            throw new IllegalStateException();
 
-        int maxHeaderLen = config.getMaxHeaderLen();
+    private void readRawField() throws IOException, MimeException {
+        if (endOfHeader)
+            throw new IllegalStateException();
         LineReaderInputStream instream = getDataStream();
-        ByteArrayBuffer fieldbuf = new ByteArrayBuffer(64);
-
         try {
             for (;;) {
                 // If there's still data stuck in the line buffer
                 // copy it to the field buffer
                 int len = linebuf.length();
-                if (maxHeaderLen > 0 && fieldbuf.length() + len >= maxHeaderLen)
{
-                    throw new MaxHeaderLengthLimitException("Maximum header length limit
exceeded");
-                }
                 if (len > 0) {
-                    fieldbuf.append(linebuf.buffer(), 0, len);
+                    fieldBuilder.append(linebuf);
                 }
                 linebuf.clear();
                 if (instream.readLine(linebuf) == -1) {
@@ -113,7 +108,7 @@ public abstract class AbstractEntity imp
                     len--;
                 }
                 if (len == 0) {
-                    // empty line detected 
+                    // empty line detected
                     endOfHeader = true;
                     break;
                 }
@@ -129,11 +124,9 @@ public abstract class AbstractEntity imp
         } catch (MaxLineLimitException e) {
             throw new MimeException(e);
         }
-
-        return fieldbuf;
     }
 
-    protected boolean parseField() throws MimeException, IOException {
+    protected boolean nextField() throws MimeException, IOException {
         int maxHeaderCount = config.getMaxHeaderCount();
         // the loop is here to transparently skip invalid headers
         for (;;) {
@@ -143,35 +136,27 @@ public abstract class AbstractEntity imp
             if (maxHeaderCount > 0 && headerCount >= maxHeaderCount) {
                 throw new MaxHeaderLimitException("Maximum header limit exceeded");
             }
-
-            ByteArrayBuffer fieldbuf = fillFieldBuffer();
             headerCount++;
-
-            // Strip away line delimiter
-            int origLen = fieldbuf.length();
-            int len = fieldbuf.length();
-            if (len > 0 && fieldbuf.byteAt(len - 1) == '\n') {
-                len--;
-            }
-            if (len > 0 && fieldbuf.byteAt(len - 1) == '\r') {
-                len--;
-            }
-            fieldbuf.setLength(len);
-            
+            fieldBuilder.reset();
+            readRawField();
             try {
-            	field = new RawField(fieldbuf);
-            	if (field.isObsoleteSyntax()) {
-            		monitor(Event.OBSOLETE_HEADER);
-            	}
+                field = fieldBuilder.build();
+                if (field == null) {
+                    continue;
+                }
+                if (field.isObsoleteSyntax()) {
+                    monitor(Event.OBSOLETE_HEADER);
+                }
                 body.addField(field);
                 return true;
             } catch (MimeException e) {
                 monitor(Event.INVALID_HEADER);
                 if (config.isMalformedHeaderStartsBody()) {
-	                fieldbuf.setLength(origLen);
-	                LineReaderInputStream instream = getDataStream();
-	                if (!instream.unread(fieldbuf)) throw new MimeParseEventException(Event.INVALID_HEADER);
-	                return false;
+                    LineReaderInputStream instream = getDataStream();
+                    if (!instream.unread(fieldBuilder.getRaw())) {
+                        throw new MimeParseEventException(Event.INVALID_HEADER);
+                    }
+                    return false;
                 }
             }
         }
@@ -233,7 +218,7 @@ public abstract class AbstractEntity imp
             }
         }
     }
-    
+
     /**
      * Creates an indicative message suitable for display
      * based on the given event and the current state of the system.
@@ -264,7 +249,7 @@ public abstract class AbstractEntity imp
 
     /**
      * Renders a state as a string suitable for logging.
-     * @param state 
+     * @param state
      * @return rendered as string, not null
      */
     public static final String stateToString(EntityState state) {
@@ -318,5 +303,5 @@ public abstract class AbstractEntity imp
         }
         return result;
     }
-    
+
 }

Added: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java?rev=1086652&view=auto
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java
(added)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java
Tue Mar 29 17:52:22 2011
@@ -0,0 +1,69 @@
+/****************************************************************
+ * 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.stream;
+
+import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.io.MaxHeaderLengthLimitException;
+import org.apache.james.mime4j.util.ByteArrayBuffer;
+
+public class DefaultFieldBuilder implements FieldBuilder {
+
+    private final ByteArrayBuffer buf;
+    private final int maxlen;
+
+    public DefaultFieldBuilder(int maxlen) {
+        this.buf = new ByteArrayBuffer(1024);
+        this.maxlen = maxlen;
+    }
+    
+    public void reset() {
+        this.buf.clear();
+    }
+    
+    public void append(final ByteArrayBuffer line) throws MaxHeaderLengthLimitException {
+        if (line == null) {
+            return;
+        }
+        int len = line.length();
+        if (this.maxlen > 0 && this.buf.length() + len >= this.maxlen) {
+            throw new MaxHeaderLengthLimitException("Maximum header length limit exceeded");
+        }        
+        this.buf.append(line.buffer(), 0, line.length());
+    }
+    
+    public RawField build() throws MimeException {
+        int len = this.buf.length();
+        if (len > 0) {
+            if (this.buf.byteAt(len - 1) == '\n') {
+                len --;
+            }
+            if (this.buf.byteAt(len - 1) == '\r') {
+                len --;
+            }
+        }
+        ByteArrayBuffer copy = new ByteArrayBuffer(this.buf.buffer(), len, false);
+        return new RawField(copy);
+    }
+    
+    public ByteArrayBuffer getRaw() {
+        return this.buf;
+    }
+    
+}

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/DefaultFieldBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java?rev=1086652&view=auto
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java
(added)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java
Tue Mar 29 17:52:22 2011
@@ -0,0 +1,35 @@
+/****************************************************************
+ * 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.stream;
+
+import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.util.ByteArrayBuffer;
+
+public interface FieldBuilder {
+
+    void reset(); 
+    
+    void append(ByteArrayBuffer line) throws MimeException;
+    
+    RawField build() throws MimeException;
+    
+    ByteArrayBuffer getRaw();
+    
+}

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/FieldBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java?rev=1086652&r1=1086651&r2=1086652&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java Tue
Mar 29 17:52:22 2011
@@ -34,7 +34,7 @@ import org.apache.james.mime4j.io.LineRe
 import org.apache.james.mime4j.io.MimeBoundaryInputStream;
 import org.apache.james.mime4j.util.MimeUtil;
 
-public class MimeEntity extends AbstractEntity {
+class MimeEntity extends AbstractEntity {
 
     private final LineNumberSource lineSource;
     private final BufferedLineReaderInputStream inbuffer;
@@ -45,15 +45,16 @@ public class MimeEntity extends Abstract
     
     private byte[] tmpbuf;
     
-    public MimeEntity(
+    MimeEntity(
             LineNumberSource lineSource,
             InputStream instream,
-            MutableBodyDescriptor body, 
+            MimeEntityConfig config,
             EntityState startState, 
             EntityState endState,
-            MimeEntityConfig config, 
-            DecodeMonitor monitor) {
-        super(body, startState, endState, config, monitor);
+            DecodeMonitor monitor,
+            FieldBuilder fieldBuilder,
+            MutableBodyDescriptor body) {
+        super(config, startState, endState, monitor, fieldBuilder, body);
         this.lineSource = lineSource;
         this.inbuffer = new BufferedLineReaderInputStream(
                 instream,
@@ -64,22 +65,37 @@ public class MimeEntity extends Abstract
                 config.getMaxLineLen());
     }
 
-    public MimeEntity(
+    MimeEntity(
             LineNumberSource lineSource,
             InputStream instream,
-            MutableBodyDescriptor body, 
+            MimeEntityConfig config,
             EntityState startState, 
             EntityState endState,
-            MimeEntityConfig config) {
-        this(lineSource, instream, body, startState, endState, config, config.isStrictParsing()
? DecodeMonitor.STRICT : DecodeMonitor.SILENT);
+            MutableBodyDescriptor body) {
+        this(lineSource, instream, config, startState, endState,
+                config.isStrictParsing() ? DecodeMonitor.STRICT : DecodeMonitor.SILENT,
+                new DefaultFieldBuilder(config.getMaxHeaderLen()), body);
     }
 
-    public MimeEntity(
+    MimeEntity(
             LineNumberSource lineSource,
             InputStream instream,
+            MimeEntityConfig config,
             MutableBodyDescriptor body) {
-        this(lineSource, instream, body, EntityState.T_START_MESSAGE, EntityState.T_END_MESSAGE,

-                new MimeEntityConfig(), DecodeMonitor.SILENT);
+        this(lineSource, instream, config, 
+                EntityState.T_START_MESSAGE, EntityState.T_END_MESSAGE, 
+                config.isStrictParsing() ? DecodeMonitor.STRICT : DecodeMonitor.SILENT,
+                new DefaultFieldBuilder(config.getMaxHeaderLen()), body);
+    }
+
+    MimeEntity(
+            LineNumberSource lineSource,
+            InputStream instream,
+            MutableBodyDescriptor body) {
+        this(lineSource, instream, new MimeEntityConfig(), 
+                EntityState.T_START_MESSAGE, EntityState.T_END_MESSAGE,
+                DecodeMonitor.SILENT,
+                new DefaultFieldBuilder(-1), body);
     }
 
     public RecursionMode getRecursionMode() {
@@ -117,7 +133,7 @@ public class MimeEntity extends Abstract
             break;
         case T_START_HEADER:
         case T_FIELD:
-            state = parseField() ? EntityState.T_FIELD : EntityState.T_END_HEADER;
+            state = nextField() ? EntityState.T_FIELD : EntityState.T_END_HEADER;
             break;
         case T_END_HEADER:
             String mimeType = body.getMimeType();
@@ -247,11 +263,12 @@ public class MimeEntity extends Abstract
             MimeEntity mimeentity = new MimeEntity(
                     lineSource, 
                     instream,
-                    body.newChild(), 
+                    config,
                     startState, 
                     endState,
-                    config,
-                    monitor);
+                    monitor,
+                    fieldBuilder,
+                    body.newChild());
             mimeentity.setRecursionMode(recursionMode);
             return mimeentity;
         }

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java?rev=1086652&r1=1086651&r2=1086652&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeTokenStream.java
Tue Mar 29 17:52:22 2011
@@ -76,6 +76,7 @@ public class MimeTokenStream {
     
     private final MimeEntityConfig config;
     private final DecodeMonitor monitor;
+    private final FieldBuilder fieldBuilder;
     private final MutableBodyDescriptorFactory bodyDescFactory;
     private final LinkedList<EntityStateMachine> entities = new LinkedList<EntityStateMachine>();
     
@@ -97,21 +98,31 @@ public class MimeTokenStream {
     }
 
     public MimeTokenStream(final MimeEntityConfig config) {
-        this(config, null, null);
+        this(config, null, null, null);
     }
         
     public MimeTokenStream(
             final MimeEntityConfig config, 
             final MutableBodyDescriptorFactory bodyDescFactory) {
-        this(config, bodyDescFactory, null);
+        this(config, null, null, bodyDescFactory);
     }
 
     public MimeTokenStream(
             final MimeEntityConfig config, 
-            final MutableBodyDescriptorFactory bodyDescFactory,
-            final DecodeMonitor monitor) {
+            final DecodeMonitor monitor,
+            final MutableBodyDescriptorFactory bodyDescFactory) {
+        this(config, monitor, null, bodyDescFactory);
+    }
+
+    public MimeTokenStream(
+            final MimeEntityConfig config, 
+            final DecodeMonitor monitor,
+            final FieldBuilder fieldBuilder,
+            final MutableBodyDescriptorFactory bodyDescFactory) {
         super();
         this.config = config;
+        this.fieldBuilder = fieldBuilder != null ? fieldBuilder : 
+            new DefaultFieldBuilder(config.getMaxHeaderLen());
         this.monitor = monitor != null ? monitor : 
             (config.isStrictParsing() ? DecodeMonitor.STRICT : DecodeMonitor.SILENT);
         this.bodyDescFactory = bodyDescFactory;
@@ -184,11 +195,12 @@ public class MimeTokenStream {
         rootentity = new MimeEntity(
                 lineSource,
                 stream,
-                newBodyDescriptor, 
+                config,
                 start, 
                 EntityState.T_END_MESSAGE,
-                config,
-                monitor);
+                monitor,
+                fieldBuilder,
+                newBodyDescriptor);
 
         rootentity.setRecursionMode(recursionMode);
         currentStateMachine = rootentity;

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeEntityTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeEntityTest.java?rev=1086652&r1=1086651&r2=1086652&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeEntityTest.java
(original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeEntityTest.java
Tue Mar 29 17:52:22 2011
@@ -414,10 +414,8 @@ public class MimeEntityTest extends Test
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                new DefaultBodyDescriptor(),
-                EntityState.T_START_MESSAGE,
-                EntityState.T_END_MESSAGE,
-                config);
+                config,
+                new DefaultBodyDescriptor());
         
         assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance(); // advances to T_START_HEADER
@@ -468,10 +466,8 @@ public class MimeEntityTest extends Test
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                new DefaultBodyDescriptor(),
-                EntityState.T_START_MESSAGE,
-                EntityState.T_END_MESSAGE,
-                config);
+                config,
+                new DefaultBodyDescriptor());
         
         assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
@@ -516,10 +512,8 @@ public class MimeEntityTest extends Test
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                new DefaultBodyDescriptor(),
-                EntityState.T_START_MESSAGE,
-                EntityState.T_END_MESSAGE,
-                config);
+                config,
+                new DefaultBodyDescriptor());
         
         assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
@@ -567,10 +561,8 @@ public class MimeEntityTest extends Test
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                new DefaultBodyDescriptor(),
-                EntityState.T_START_MESSAGE,
-                EntityState.T_END_MESSAGE,
-                config);
+                config,
+                new DefaultBodyDescriptor());
         
         assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
@@ -615,10 +607,8 @@ public class MimeEntityTest extends Test
         MimeEntity entity = new MimeEntity(
                 lineInput,
                 rawstream,
-                new DefaultBodyDescriptor(),
-                EntityState.T_START_MESSAGE,
-                EntityState.T_END_MESSAGE,
-                config);
+                config,
+                new DefaultBodyDescriptor());
         
         assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();

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=1086652&r1=1086651&r2=1086652&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
Tue Mar 29 17:52:22 2011
@@ -65,12 +65,12 @@ public class MessageBuilderImpl implemen
 
     public Message parse(InputStream source) throws MimeException, IOException {
         return getMimeBuilder().parse(source, 
-                mimeEntityConfig, 
+                mimeEntityConfig,
+                decodeMonitor,
                 bodyFactory, 
                 mutableBodyDescriptorFactory, 
                 contentDecoding,
-                flatMode,
-                decodeMonitor);
+                flatMode);
     }
     
     public void setBodyFactory(BodyFactory bodyFactory) {

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=1086652&r1=1086651&r2=1086652&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
Tue Mar 29 17:52:22 2011
@@ -246,15 +246,15 @@ public class MimeBuilder {
     public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
+            final DecodeMonitor monitor,
             final BodyFactory bodyFactory, 
             final MutableBodyDescriptorFactory bodyDescFactory,
             final boolean contentDecoding,
-            final boolean flatMode,
-            final DecodeMonitor monitor) throws IOException, MimeIOException {
+            final boolean flatMode) throws IOException, MimeIOException {
         try {
             MessageImpl message = new MessageImpl();
             DecodeMonitor mon = monitor != null ? monitor : DecodeMonitor.SILENT;
-            MimeStreamParser parser = new MimeStreamParser(config, bodyDescFactory, mon);
+            MimeStreamParser parser = new MimeStreamParser(config, mon, bodyDescFactory);
             parser.setContentHandler(new EntityBuilder(message, bodyFactory, mon));
             parser.setContentDecoding(contentDecoding);
             if (flatMode) {
@@ -290,10 +290,10 @@ public class MimeBuilder {
     public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
+            final DecodeMonitor monitor,
             final BodyFactory bodyFactory, 
-            final MutableBodyDescriptorFactory bodyDescFactory,
-            final DecodeMonitor monitor) throws IOException, MimeIOException {
-        return parse(is, config, bodyFactory, bodyDescFactory, true, false, monitor);
+            final MutableBodyDescriptorFactory bodyDescFactory) throws IOException, MimeIOException
{
+        return parse(is, config, monitor, bodyFactory, bodyDescFactory, true, false);
     }
     
     public Message parse(
@@ -301,14 +301,14 @@ public class MimeBuilder {
             final MimeEntityConfig config,
             final BodyFactory bodyFactory, 
             final MutableBodyDescriptorFactory bodyDescFactory) throws IOException, MimeIOException
{
-        return parse(is, config, bodyFactory, bodyDescFactory, null);
+        return parse(is, config, null, bodyFactory, bodyDescFactory);
     }
 
     public Message parse(
             final InputStream is, 
             final MimeEntityConfig config,
             final BodyFactory bodyFactory) throws IOException, MimeIOException {
-        return parse(is, config, bodyFactory, null, null);
+        return parse(is, config, null, bodyFactory, null);
     }
 
     /**



Mime
View raw message