james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1082286 [1/2] - in /james/mime4j/trunk: benchmark/src/main/java/org/apache/james/mime4j/ 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/strea...
Date Wed, 16 Mar 2011 20:21:40 GMT
Author: olegk
Date: Wed Mar 16 20:21:39 2011
New Revision: 1082286

URL: http://svn.apache.org/viewvc?rev=1082286&view=rev
Log:
EntityState and RecursionMode changed from a set of int values defined by an interface to enum types

Added:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityState.java
      - copied, changed from r1082282, james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStates.java
Removed:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStates.java
Modified:
    james/mime4j/trunk/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java
    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/EntityStateMachine.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/main/java/org/apache/james/mime4j/stream/RawEntity.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RecursionMode.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeEntityTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamTokenMessageRfc822Test.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamBodyDescriptorTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamReaderTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartStreamTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java
    james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/MaximalBodyDescriptorTest.java

Modified: james/mime4j/trunk/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java?rev=1082286&r1=1082285&r2=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java (original)
+++ james/mime4j/trunk/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java Wed Mar 16 20:21:39 2011
@@ -34,6 +34,7 @@ import org.apache.james.mime4j.parser.Mi
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
 import org.apache.james.mime4j.storage.MemoryStorageProvider;
 import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.EntityState;
 import org.apache.james.mime4j.stream.MimeTokenStream;
 
 public class LongMultipartReadBench {
@@ -122,7 +123,7 @@ public class LongMultipartReadBench {
             MimeTokenStream stream = new MimeTokenStream();
             for (int i = 0; i < repetitions; i++) {
                 stream.parse(new ByteArrayInputStream(content));
-                for (int state = stream.getState(); state != MimeTokenStream.T_END_OF_STREAM; state = stream
+                for (EntityState state = stream.getState(); state != EntityState.T_END_OF_STREAM; state = stream
                         .next()) {
                 }
             }

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=1082286&r1=1082285&r2=1082286&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 Wed Mar 16 20:21:39 2011
@@ -25,10 +25,12 @@ import java.io.InputStream;
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.EntityState;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.stream.MimeTokenStream;
 import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 import org.apache.james.mime4j.stream.RawField;
+import org.apache.james.mime4j.stream.RecursionMode;
 
 /**
  * <p>
@@ -123,9 +125,9 @@ public class MimeStreamParser {
             mimeTokenStream.parse(inputStream);
         }
         OUTER: for (;;) {
-            int state = mimeTokenStream.getState();
+            EntityState state = mimeTokenStream.getState();
             switch (state) {
-                case MimeTokenStream.T_BODY:
+                case T_BODY:
                     BodyDescriptor desc = mimeTokenStream.getBodyDescriptor();
                     InputStream bodyContent;
                     if (contentDecoding) {
@@ -135,42 +137,42 @@ public class MimeStreamParser {
                     }
                     handler.body(desc, bodyContent);
                     break;
-                case MimeTokenStream.T_END_BODYPART:
+                case T_END_BODYPART:
                     handler.endBodyPart();
                     break;
-                case MimeTokenStream.T_END_HEADER:
+                case T_END_HEADER:
                     handler.endHeader();
                     break;
-                case MimeTokenStream.T_END_MESSAGE:
+                case T_END_MESSAGE:
                     handler.endMessage();
                     break;
-                case MimeTokenStream.T_END_MULTIPART:
+                case T_END_MULTIPART:
                     handler.endMultipart();
                     break;
-                case MimeTokenStream.T_END_OF_STREAM:
+                case T_END_OF_STREAM:
                     break OUTER;
-                case MimeTokenStream.T_EPILOGUE:
+                case T_EPILOGUE:
                     handler.epilogue(mimeTokenStream.getInputStream());
                     break;
-                case MimeTokenStream.T_FIELD:
+                case T_FIELD:
                     handler.field(mimeTokenStream.getField());
                     break;
-                case MimeTokenStream.T_PREAMBLE:
+                case T_PREAMBLE:
                     handler.preamble(mimeTokenStream.getInputStream());
                     break;
-                case MimeTokenStream.T_RAW_ENTITY:
+                case T_RAW_ENTITY:
                     handler.raw(mimeTokenStream.getInputStream());
                     break;
-                case MimeTokenStream.T_START_BODYPART:
+                case T_START_BODYPART:
                     handler.startBodyPart();
                     break;
-                case MimeTokenStream.T_START_HEADER:
+                case T_START_HEADER:
                     handler.startHeader();
                     break;
-                case MimeTokenStream.T_START_MESSAGE:
+                case T_START_MESSAGE:
                     handler.startMessage();
                     break;
-                case MimeTokenStream.T_START_MULTIPART:
+                case T_START_MULTIPART:
                     handler.startMultipart(mimeTokenStream.getBodyDescriptor());
                     break;
                 default:
@@ -199,7 +201,7 @@ public class MimeStreamParser {
      * including header fields and whatever is in the body.
      */
     public void setRaw() {
-        mimeTokenStream.setRecursionMode(MimeTokenStream.M_RAW);
+        mimeTokenStream.setRecursionMode(RecursionMode.M_RAW);
     }
     
     /**
@@ -207,7 +209,7 @@ public class MimeStreamParser {
      * parsed and multipart content is handled as a single "simple" stream.
      */
     public void setFlat() {
-        mimeTokenStream.setRecursionMode(MimeTokenStream.M_FLAT);
+        mimeTokenStream.setRecursionMode(RecursionMode.M_FLAT);
     }
     
     /**
@@ -215,7 +217,7 @@ public class MimeStreamParser {
      * parsed.
      */
     public void setRecurse() {
-        mimeTokenStream.setRecursionMode(MimeTokenStream.M_RECURSE);
+        mimeTokenStream.setRecursionMode(RecursionMode.M_RECURSE);
     }
 
     /**

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=1082286&r1=1082285&r2=1082286&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 Wed Mar 16 20:21:39 2011
@@ -35,12 +35,12 @@ import org.apache.james.mime4j.util.Char
  */
 public abstract class AbstractEntity implements EntityStateMachine {
 
-    protected final int startState;
-    protected final int endState;
+    protected final EntityState startState;
+    protected final EntityState endState;
     protected final MimeEntityConfig config;
     protected final MutableBodyDescriptor body;
     
-    protected int state;
+    protected EntityState state;
 
     private final ByteArrayBuffer linebuf;
 
@@ -50,19 +50,10 @@ public abstract class AbstractEntity imp
     private int headerCount;
     protected final DecodeMonitor monitor;
 
-    /**
-     * Internal state, not exposed.
-     */
-    private static final int T_IN_BODYPART = -2;
-    /**
-     * Internal state, not exposed.
-     */
-    private static final int T_IN_MESSAGE = -3;
-
     AbstractEntity(
             MutableBodyDescriptor body,
-            int startState, 
-            int endState,
+            EntityState startState, 
+            EntityState endState,
             MimeEntityConfig config,
             DecodeMonitor monitor) {
         this.state = startState;
@@ -77,7 +68,7 @@ public abstract class AbstractEntity imp
         this.monitor = monitor;
     }
 
-    public int getState() {
+    public EntityState getState() {
         return state;
     }
 
@@ -190,20 +181,20 @@ public abstract class AbstractEntity imp
      * <p>Gets a descriptor for the current entity.
      * This method is valid if {@link #getState()} returns:</p>
      * <ul>
-     * <li>{@link EntityStates#T_BODY}</li>
-     * <li>{@link EntityStates#T_START_MULTIPART}</li>
-     * <li>{@link EntityStates#T_EPILOGUE}</li>
-     * <li>{@link EntityStates#T_PREAMBLE}</li>
+     * <li>{@link EntityState#T_BODY}</li>
+     * <li>{@link EntityState#T_START_MULTIPART}</li>
+     * <li>{@link EntityState#T_EPILOGUE}</li>
+     * <li>{@link EntityState#T_PREAMBLE}</li>
      * </ul>
      * @return <code>BodyDescriptor</code>, not nulls
      */
     public BodyDescriptor getBodyDescriptor() {
         switch (getState()) {
-        case EntityStates.T_BODY:
-        case EntityStates.T_START_MULTIPART:
-        case EntityStates.T_PREAMBLE:
-        case EntityStates.T_EPILOGUE:
-        case EntityStates.T_END_OF_STREAM:
+        case T_BODY:
+        case T_START_MULTIPART:
+        case T_PREAMBLE:
+        case T_EPILOGUE:
+        case T_END_OF_STREAM:
             return body;
         default:
             throw new IllegalStateException("Invalid state :" + stateToString(state));
@@ -211,14 +202,14 @@ public abstract class AbstractEntity imp
     }
 
     /**
-     * This method is valid, if {@link #getState()} returns {@link EntityStates#T_FIELD}.
+     * This method is valid, if {@link #getState()} returns {@link EntityState#T_FIELD}.
      * @return String with the fields raw contents.
      * @throws IllegalStateException {@link #getState()} returns another
-     *   value than {@link EntityStates#T_FIELD}.
+     *   value than {@link EntityState#T_FIELD}.
      */
     public RawField getField() {
         switch (getState()) {
-        case EntityStates.T_FIELD:
+        case T_FIELD:
             return field;
         default:
             throw new IllegalStateException("Invalid state :" + stateToString(state));
@@ -276,57 +267,51 @@ public abstract class AbstractEntity imp
      * @param state 
      * @return rendered as string, not null
      */
-    public static final String stateToString(int state) {
+    public static final String stateToString(EntityState state) {
         final String result;
         switch (state) {
-            case EntityStates.T_END_OF_STREAM:
+            case T_END_OF_STREAM:
                 result = "End of stream";
                 break;
-            case EntityStates.T_START_MESSAGE:
+            case T_START_MESSAGE:
                 result = "Start message";
                 break;
-            case EntityStates.T_END_MESSAGE:
+            case T_END_MESSAGE:
                 result = "End message";
                 break;
-            case EntityStates.T_RAW_ENTITY:
+            case T_RAW_ENTITY:
                 result = "Raw entity";
                 break;
-            case EntityStates.T_START_HEADER:
+            case T_START_HEADER:
                 result = "Start header";
                 break;
-            case EntityStates.T_FIELD:
+            case T_FIELD:
                 result = "Field";
                 break;
-            case EntityStates.T_END_HEADER:
+            case T_END_HEADER:
                 result = "End header";
                 break;
-            case EntityStates.T_START_MULTIPART:
+            case T_START_MULTIPART:
                 result = "Start multipart";
                 break;
-            case EntityStates.T_END_MULTIPART:
+            case T_END_MULTIPART:
                 result = "End multipart";
                 break;
-            case EntityStates.T_PREAMBLE:
+            case T_PREAMBLE:
                 result = "Preamble";
                 break;
-            case EntityStates.T_EPILOGUE:
+            case T_EPILOGUE:
                 result = "Epilogue";
                 break;
-            case EntityStates.T_START_BODYPART:
+            case T_START_BODYPART:
                 result = "Start bodypart";
                 break;
-            case EntityStates.T_END_BODYPART:
+            case T_END_BODYPART:
                 result = "End bodypart";
                 break;
-            case EntityStates.T_BODY:
+            case T_BODY:
                 result = "Body";
                 break;
-            case T_IN_BODYPART:
-                result = "Bodypart";
-                break;
-            case T_IN_MESSAGE:
-                result = "In message";
-                break;
             default:
                 result = "Unknown";
                 break;

Copied: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityState.java (from r1082282, james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStates.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityState.java?p2=james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityState.java&p1=james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStates.java&r1=1082282&r2=1082286&rev=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStates.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityState.java Wed Mar 16 20:21:39 2011
@@ -23,73 +23,72 @@ package org.apache.james.mime4j.stream;
  * Enumeration of states an entity is expected to go through
  * in the process of the MIME stream parsing.
  */
-public interface EntityStates {
-
-    /**
-     * This token indicates, that the MIME stream has been completely
-     * and successfully parsed, and no more data is available.
-     */
-    int T_END_OF_STREAM = -1;
+public enum EntityState {
     /**
      * This token indicates, that the MIME stream is currently
      * at the beginning of a message.
      */
-    int T_START_MESSAGE = 0;
+    T_START_MESSAGE,
     /**
      * This token indicates, that the MIME stream is currently
      * at the end of a message.
      */
-    int T_END_MESSAGE = 1;
+    T_END_MESSAGE,
     /**
      * This token indicates, that a raw entity is currently being processed.
      */
-    int T_RAW_ENTITY = 2;
+    T_RAW_ENTITY,
     /**
      * This token indicates, that a message parts headers are now
      * being parsed.
      */
-    int T_START_HEADER = 3;
+    T_START_HEADER,
     /**
      * This token indicates, that a message parts field has now
      * been parsed. 
      */
-    int T_FIELD = 4;
+    T_FIELD,
     /**
      * This token indicates, that part headers have now been
      * parsed.
      */
-    int T_END_HEADER = 5;
+    T_END_HEADER,
     /**
      * This token indicates, that a multipart body is being parsed.
      */
-    int T_START_MULTIPART = 6;
+    T_START_MULTIPART,
     /**
      * This token indicates, that a multipart body has been parsed.
      */
-    int T_END_MULTIPART = 7;
+    T_END_MULTIPART,
     /**
      * This token indicates, that a multiparts preamble is being
      * parsed. 
      */
-    int T_PREAMBLE = 8;
+    T_PREAMBLE,
     /**
      * This token indicates, that a multiparts epilogue is being
      * parsed. 
      */
-    int T_EPILOGUE = 9;
+    T_EPILOGUE,
     /**
      * This token indicates, that the MIME stream is currently
      * at the beginning of a body part.
      */
-    int T_START_BODYPART = 10;
+    T_START_BODYPART,
     /**
      * This token indicates, that the MIME stream is currently
      * at the end of a body part.
      */
-    int T_END_BODYPART = 11;
+    T_END_BODYPART,
     /**
      * This token indicates, that an atomic entity is being parsed.
      */
-    int T_BODY = 12;
+    T_BODY,
+    /**
+     * This token indicates, that the MIME stream has been completely
+     * and successfully parsed, and no more data is available.
+     */
+    T_END_OF_STREAM
 
 }

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStateMachine.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStateMachine.java?rev=1082286&r1=1082285&r2=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStateMachine.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/EntityStateMachine.java Wed Mar 16 20:21:39 2011
@@ -33,11 +33,11 @@ public interface EntityStateMachine {
     /**
      * Return the current state of the entity.
      * 
-     * @see EntityStates
+     * @see EntityState
      * 
      * @return current state
      */
-    int getState();
+    EntityState getState();
     
     /**
      * Sets the current recursion mode.
@@ -51,7 +51,7 @@ public interface EntityStateMachine {
      * 
      * @param recursionMode
      */
-    void setRecursionMode(int recursionMode);
+    void setRecursionMode(RecursionMode recursionMode);
     
     /**
      * Advances the state machine to the next state in the 

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=1082286&r1=1082285&r2=1082286&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 Wed Mar 16 20:21:39 2011
@@ -39,7 +39,7 @@ public class MimeEntity extends Abstract
     private final LineNumberSource lineSource;
     private final BufferedLineReaderInputStream inbuffer;
     
-    private int recursionMode;
+    private RecursionMode recursionMode;
     private MimeBoundaryInputStream currentMimePartStream;
     private LineReaderInputStreamAdaptor dataStream;
     
@@ -49,8 +49,8 @@ public class MimeEntity extends Abstract
             LineNumberSource lineSource,
             InputStream instream,
             MutableBodyDescriptor body, 
-            int startState, 
-            int endState,
+            EntityState startState, 
+            EntityState endState,
             MimeEntityConfig config, 
             DecodeMonitor monitor) {
         super(body, startState, endState, config, monitor);
@@ -68,8 +68,8 @@ public class MimeEntity extends Abstract
             LineNumberSource lineSource,
             InputStream instream,
             MutableBodyDescriptor body, 
-            int startState, 
-            int endState,
+            EntityState startState, 
+            EntityState endState,
             MimeEntityConfig config) {
         this(lineSource, instream, body, startState, endState, config, config.isStrictParsing() ? DecodeMonitor.STRICT : DecodeMonitor.SILENT);
     }
@@ -78,15 +78,15 @@ public class MimeEntity extends Abstract
             LineNumberSource lineSource,
             InputStream instream,
             MutableBodyDescriptor body) {
-        this(lineSource, instream, body, EntityStates.T_START_MESSAGE, EntityStates.T_END_MESSAGE, 
+        this(lineSource, instream, body, EntityState.T_START_MESSAGE, EntityState.T_END_MESSAGE, 
                 new MimeEntityConfig(), DecodeMonitor.SILENT);
     }
 
-    public int getRecursionMode() {
+    public RecursionMode getRecursionMode() {
         return recursionMode;
     }
 
-    public void setRecursionMode(int recursionMode) {
+    public void setRecursionMode(RecursionMode recursionMode) {
         this.recursionMode = recursionMode;
     }
 
@@ -109,44 +109,44 @@ public class MimeEntity extends Abstract
     
     public EntityStateMachine advance() throws IOException, MimeException {
         switch (state) {
-        case EntityStates.T_START_MESSAGE:
-            state = EntityStates.T_START_HEADER;
+        case T_START_MESSAGE:
+            state = EntityState.T_START_HEADER;
             break;
-        case EntityStates.T_START_BODYPART:
-            state = EntityStates.T_START_HEADER;
+        case T_START_BODYPART:
+            state = EntityState.T_START_HEADER;
             break;
-        case EntityStates.T_START_HEADER:
-        case EntityStates.T_FIELD:
-            state = parseField() ? EntityStates.T_FIELD : EntityStates.T_END_HEADER;
+        case T_START_HEADER:
+        case T_FIELD:
+            state = parseField() ? EntityState.T_FIELD : EntityState.T_END_HEADER;
             break;
-        case EntityStates.T_END_HEADER:
+        case T_END_HEADER:
             String mimeType = body.getMimeType();
             if (recursionMode == RecursionMode.M_FLAT) {
-                state = EntityStates.T_BODY;
+                state = EntityState.T_BODY;
             } else if (MimeUtil.isMultipart(mimeType)) {
-                state = EntityStates.T_START_MULTIPART;
+                state = EntityState.T_START_MULTIPART;
                 clearMimePartStream();
             } else if (recursionMode != RecursionMode.M_NO_RECURSE 
                     && MimeUtil.isMessage(mimeType)) {
-                state = EntityStates.T_BODY;
+                state = EntityState.T_BODY;
                 return nextMessage();
             } else {
-                state = EntityStates.T_BODY;
+                state = EntityState.T_BODY;
             }
             break;
-        case EntityStates.T_START_MULTIPART:
+        case T_START_MULTIPART:
             if (dataStream.isUsed()) {
                 advanceToBoundary();            
-                state = EntityStates.T_END_MULTIPART;
+                state = EntityState.T_END_MULTIPART;
                 break;
             } else {
                 createMimePartStream();
-                state = EntityStates.T_PREAMBLE;
+                state = EntityState.T_PREAMBLE;
                 
                 if (!currentMimePartStream.isEmptyStream()) break;
                 // continue to next state
             }
-        case EntityStates.T_PREAMBLE:
+        case T_PREAMBLE:
         	// removed specific code. Fallback to T_IN_BODYPART that
         	// better handle missing parts.
         	// Removed the T_IN_BODYPART state (always use T_PREAMBLE)
@@ -161,18 +161,18 @@ public class MimeEntity extends Abstract
                 }
             }
             clearMimePartStream();
-            state = EntityStates.T_EPILOGUE;
+            state = EntityState.T_EPILOGUE;
             break;
-        case EntityStates.T_EPILOGUE:
-            state = EntityStates.T_END_MULTIPART;
+        case T_EPILOGUE:
+            state = EntityState.T_END_MULTIPART;
             break;
-        case EntityStates.T_BODY:
-        case EntityStates.T_END_MULTIPART:
+        case T_BODY:
+        case T_END_MULTIPART:
             state = endState;
             break;
         default:
             if (state == endState) {
-                state = EntityStates.T_END_OF_STREAM;
+                state = EntityState.T_END_OF_STREAM;
                 break;
             }
             throw new IllegalStateException("Invalid state: " + stateToString(state));
@@ -222,7 +222,7 @@ public class MimeEntity extends Abstract
         // always return dataStream (that would add a LineReaderInputStreamAdaptor in the chain)
         InputStream instream = currentMimePartStream != null ? currentMimePartStream : inbuffer;
         instream = decodedStream(instream);
-        return nextMimeEntity(EntityStates.T_START_MESSAGE, EntityStates.T_END_MESSAGE, instream);
+        return nextMimeEntity(EntityState.T_START_MESSAGE, EntityState.T_END_MESSAGE, instream);
     }
 
     private InputStream decodedStream(InputStream instream) {
@@ -236,10 +236,10 @@ public class MimeEntity extends Abstract
     }
     
     private EntityStateMachine nextMimeEntity() {
-    	return nextMimeEntity(EntityStates.T_START_BODYPART, EntityStates.T_END_BODYPART, currentMimePartStream);
+    	return nextMimeEntity(EntityState.T_START_BODYPART, EntityState.T_END_BODYPART, currentMimePartStream);
     }
     
-    private EntityStateMachine nextMimeEntity(int startState, int endState, InputStream instream) {
+    private EntityStateMachine nextMimeEntity(EntityState startState, EntityState endState, InputStream instream) {
         if (recursionMode == RecursionMode.M_RAW) {
             RawEntity message = new RawEntity(instream);
             return message;
@@ -271,10 +271,10 @@ public class MimeEntity extends Abstract
      */
     public InputStream getContentStream() {
         switch (state) {
-        case EntityStates.T_START_MULTIPART:
-        case EntityStates.T_PREAMBLE:
-        case EntityStates.T_EPILOGUE:
-        case EntityStates.T_BODY:
+        case T_START_MULTIPART:
+        case T_PREAMBLE:
+        case T_EPILOGUE:
+        case T_BODY:
             return getLimitedContentStream();
         default:
             throw new IllegalStateException("Invalid state: " + stateToString(state));

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=1082286&r1=1082285&r2=1082286&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 Wed Mar 16 20:21:39 2011
@@ -72,16 +72,16 @@ import org.apache.james.mime4j.util.Char
  * have a multi threaded application, then the suggested use is to have
  * one instance per thread.</p>
  */
-public class MimeTokenStream implements EntityStates, RecursionMode {
+public class MimeTokenStream {
     
     private final MimeEntityConfig config;
     private final DecodeMonitor monitor;
     private final MutableBodyDescriptorFactory bodyDescFactory;
     private final LinkedList<EntityStateMachine> entities = new LinkedList<EntityStateMachine>();
     
-    private int state = T_END_OF_STREAM;
+    private EntityState state = EntityState.T_END_OF_STREAM;
     private EntityStateMachine currentStateMachine;
-    private int recursionMode = M_RECURSE;
+    private RecursionMode recursionMode = RecursionMode.M_RECURSE;
     private MimeEntity rootentity;
     
     /**
@@ -122,7 +122,7 @@ public class MimeTokenStream implements 
      * internal state.
      */
     public void parse(InputStream stream) {
-        doParse(stream, newBodyDescriptor(), T_START_MESSAGE);
+        doParse(stream, newBodyDescriptor(), EntityState.T_START_MESSAGE);
     }
 
     /** Instructs the {@code MimeTokenStream} to parse the given content with 
@@ -145,7 +145,7 @@ public class MimeTokenStream implements 
             // should never happen
             throw new IllegalArgumentException(ex.getMessage());
         }
-        doParse(stream, newBodyDescriptor, T_END_HEADER);
+        doParse(stream, newBodyDescriptor, EntityState.T_END_HEADER);
         try {
             next();
         } catch (IOException e) {
@@ -173,7 +173,7 @@ public class MimeTokenStream implements 
     }
 
     public void doParse(InputStream stream,
-            MutableBodyDescriptor newBodyDescriptor, int start) {
+            MutableBodyDescriptor newBodyDescriptor, EntityState start) {
         LineNumberSource lineSource = null;
         if (config.isCountLineNumbers()) {
             LineNumberInputStream lineInput = new LineNumberInputStream(stream);
@@ -186,7 +186,7 @@ public class MimeTokenStream implements 
                 stream,
                 newBodyDescriptor, 
                 start, 
-                T_END_MESSAGE,
+                EntityState.T_END_MESSAGE,
                 config,
                 monitor);
 
@@ -205,7 +205,7 @@ public class MimeTokenStream implements 
      * @see #setRecursionMode(int)
      */
     public boolean isRaw() {
-        return recursionMode == M_RAW;
+        return recursionMode == RecursionMode.M_RAW;
     }
     
     /**
@@ -217,7 +217,7 @@ public class MimeTokenStream implements 
      * {@link #M_NO_RECURSE} does not.
      * @return {@link #M_RECURSE}, {@link #M_RAW} or {@link #M_NO_RECURSE}
      */
-    public int getRecursionMode() {
+    public RecursionMode getRecursionMode() {
         return recursionMode;
     }
     
@@ -230,7 +230,7 @@ public class MimeTokenStream implements 
      * {@link #M_NO_RECURSE} does not.
      * @param mode {@link #M_RECURSE}, {@link #M_RAW} or {@link #M_NO_RECURSE}
      */
-    public void setRecursionMode(int mode) {
+    public void setRecursionMode(RecursionMode mode) {
         recursionMode = mode;
         if (currentStateMachine != null) {
             currentStateMachine.setRecursionMode(mode);
@@ -250,7 +250,7 @@ public class MimeTokenStream implements 
     /**
      * Returns the current state.
      */
-    public int getState() {
+    public EntityState getState() {
         return state;
     }
 
@@ -343,8 +343,8 @@ public class MimeTokenStream implements 
      * @throws IllegalStateException The method has been called, although
      *   {@link #getState()} was already {@link #T_END_OF_STREAM}.
      */
-    public int next() throws IOException, MimeException {
-        if (state == T_END_OF_STREAM  ||  currentStateMachine == null) {
+    public EntityState next() throws IOException, MimeException {
+        if (state == EntityState.T_END_OF_STREAM  ||  currentStateMachine == null) {
             throw new IllegalStateException("No more tokens are available.");
         }
         while (currentStateMachine != null) {
@@ -354,7 +354,7 @@ public class MimeTokenStream implements 
                 currentStateMachine = next;
             }
             state = currentStateMachine.getState();
-            if (state != T_END_OF_STREAM) {
+            if (state != EntityState.T_END_OF_STREAM) {
                 return state;
             }
             entities.removeLast();
@@ -365,7 +365,7 @@ public class MimeTokenStream implements 
                 currentStateMachine.setRecursionMode(recursionMode);
             }
         }
-        state = T_END_OF_STREAM;
+        state = EntityState.T_END_OF_STREAM;
         return state;
     }
 
@@ -374,7 +374,7 @@ public class MimeTokenStream implements 
      * @param state 
      * @return rendered as string, not null
      */
-    public static final String stateToString(int state) {
+    public static final String stateToString(EntityState state) {
         return AbstractEntity.stateToString(state);
     }
 

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawEntity.java?rev=1082286&r1=1082285&r2=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawEntity.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RawEntity.java Wed Mar 16 20:21:39 2011
@@ -31,25 +31,25 @@ public class RawEntity implements Entity
 
     private final InputStream stream;
 
-    private int state;
+    private EntityState state;
     
     RawEntity(InputStream stream) {
         this.stream = stream;
-        this.state = EntityStates.T_RAW_ENTITY;
+        this.state = EntityState.T_RAW_ENTITY;
     }
     
-    public int getState() {
+    public EntityState getState() {
         return state;
     }
 
     /**
      * This method has no effect.
      */
-    public void setRecursionMode(int recursionMode) {
+    public void setRecursionMode(RecursionMode recursionMode) {
     }
 
     public EntityStateMachine advance() {
-        state = EntityStates.T_END_OF_STREAM;
+        state = EntityState.T_END_OF_STREAM;
         return null;
     }
     

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RecursionMode.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RecursionMode.java?rev=1082286&r1=1082285&r2=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RecursionMode.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/RecursionMode.java Wed Mar 16 20:21:39 2011
@@ -22,24 +22,24 @@ package org.apache.james.mime4j.stream;
 /**
  * Enumeration of parsing modes.
  */
-public interface RecursionMode {
+public enum RecursionMode {
 
     /** 
      * Recursively parse every <code>message/rfc822</code> part 
      */
-    int M_RECURSE = 0;
+    M_RECURSE,
     /**
      * Do not recurse <code>message/rfc822</code> parts 
      */
-    int M_NO_RECURSE = 1;
+    M_NO_RECURSE,
     /** 
      * Parse into raw entities
      */
-    int M_RAW = 2;
+    M_RAW,
     /**
      * Do not recurse <code>message/rfc822</code> parts
      * and treat multiparts as a single flat body. 
      */
-    int M_FLAT = 3;
+    M_FLAT
     
 }

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=1082286&r1=1082285&r2=1082286&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 Wed Mar 16 20:21:39 2011
@@ -53,31 +53,31 @@ public class MimeEntityTest extends Test
                 rawstream, new DefaultBodyDescriptor());
         
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("To", entity.getField().getName());
         assertEquals("Road Runner <runner@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("From", entity.getField().getName());
         assertEquals("Wile E. Cayote <wile@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Date", entity.getField().getName());
         assertEquals("Tue, 12 Feb 2008 17:34:09 +0000 (GMT)", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Subject", entity.getField().getName());
         assertEquals("Mail", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Content-Type", entity.getField().getName());
         assertEquals("text/plain", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_END_HEADER, entity.getState());
+        assertEquals(EntityState.T_END_HEADER, entity.getState());
         try {
             entity.getField().getName();
             fail("IllegalStateException should have been thrown");
@@ -90,17 +90,17 @@ public class MimeEntityTest extends Test
         }
         
         entity.advance();
-        assertEquals(EntityStates.T_BODY, entity.getState());
+        assertEquals(EntityState.T_BODY, entity.getState());
         assertEquals("a very important message", IOUtils.toString(entity.getContentStream()));
         entity.advance();
-        assertEquals(EntityStates.T_END_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_END_MESSAGE, entity.getState());
         try {
             entity.getContentStream();
             fail("IllegalStateException should have been thrown");
         } catch (IllegalStateException expected) {
         }
         entity.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, entity.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, entity.getState());
         try {
             entity.advance();
             fail("IllegalStateException should have been thrown");
@@ -129,31 +129,31 @@ public class MimeEntityTest extends Test
                 rawstream, new DefaultBodyDescriptor());
         
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("To", entity.getField().getName());
         assertEquals("Road Runner <runner@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("From", entity.getField().getName());
         assertEquals("Wile E. Cayote <wile@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Date", entity.getField().getName());
         assertEquals("Tue, 12 Feb 2008 17:34:09 +0000 (GMT)", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Subject", entity.getField().getName());
         assertEquals("Mail      with a folded subject ", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Content-Type", entity.getField().getName());
         assertEquals("text/plain", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_END_HEADER, entity.getState());
+        assertEquals(EntityState.T_END_HEADER, entity.getState());
         try {
             entity.getField().getName();
             fail("IllegalStateException should have been thrown");
@@ -166,17 +166,17 @@ public class MimeEntityTest extends Test
         }
         
         entity.advance();
-        assertEquals(EntityStates.T_BODY, entity.getState());
+        assertEquals(EntityState.T_BODY, entity.getState());
         assertEquals("a very important message", IOUtils.toString(entity.getContentStream()));
         entity.advance();
-        assertEquals(EntityStates.T_END_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_END_MESSAGE, entity.getState());
         try {
             entity.getContentStream();
             fail("IllegalStateException should have been thrown");
         } catch (IllegalStateException expected) {
         }
         entity.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, entity.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, entity.getState());
         try {
             entity.advance();
             fail("IllegalStateException should have been thrown");
@@ -212,86 +212,86 @@ public class MimeEntityTest extends Test
                 lineInput,
                 rawstream, new DefaultBodyDescriptor());
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("To", entity.getField().getName());
         assertEquals("Road Runner <runner@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("From", entity.getField().getName());
         assertEquals("Wile E. Cayote <wile@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Date", entity.getField().getName());
         assertEquals("Tue, 12 Feb 2008 17:34:09 +0000 (GMT)", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Subject", entity.getField().getName());
         assertEquals("Mail", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Content-Type", entity.getField().getName());
         assertEquals("multipart/mixed;boundary=1729", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_END_HEADER, entity.getState());
+        assertEquals(EntityState.T_END_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_MULTIPART, entity.getState());
+        assertEquals(EntityState.T_START_MULTIPART, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_PREAMBLE, entity.getState());
+        assertEquals(EntityState.T_PREAMBLE, entity.getState());
         assertEquals("Hello!", IOUtils.toString(entity.getContentStream()));
         
         EntityStateMachine p1 = entity.advance();
         assertNotNull(p1);
         
-        assertEquals(EntityStates.T_START_BODYPART, p1.getState());
+        assertEquals(EntityState.T_START_BODYPART, p1.getState());
         p1.advance();
-        assertEquals(EntityStates.T_START_HEADER, p1.getState());
+        assertEquals(EntityState.T_START_HEADER, p1.getState());
         p1.advance();
-        assertEquals(EntityStates.T_FIELD, p1.getState());
+        assertEquals(EntityState.T_FIELD, p1.getState());
         assertEquals("Content-Type", p1.getField().getName());
         assertEquals("text/plain; charset=US-ASCII", p1.getField().getBody());
         p1.advance();
-        assertEquals(EntityStates.T_END_HEADER, p1.getState());
+        assertEquals(EntityState.T_END_HEADER, p1.getState());
         p1.advance();
-        assertEquals(EntityStates.T_BODY, p1.getState());
+        assertEquals(EntityState.T_BODY, p1.getState());
         assertEquals("blah blah blah", IOUtils.toString(p1.getContentStream()));
         p1.advance();
-        assertEquals(EntityStates.T_END_BODYPART, p1.getState());
+        assertEquals(EntityState.T_END_BODYPART, p1.getState());
         p1.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, p1.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, p1.getState());
 
         EntityStateMachine p2 = entity.advance();
         assertNotNull(p2);
         
-        assertEquals(EntityStates.T_START_BODYPART, p2.getState());
+        assertEquals(EntityState.T_START_BODYPART, p2.getState());
         p2.advance();
-        assertEquals(EntityStates.T_START_HEADER, p2.getState());
+        assertEquals(EntityState.T_START_HEADER, p2.getState());
         p2.advance();
-        assertEquals(EntityStates.T_FIELD, p2.getState());
+        assertEquals(EntityState.T_FIELD, p2.getState());
         assertEquals("Content-Type", p2.getField().getName());
         assertEquals("text/plain; charset=US-ASCII", p2.getField().getBody());
         p2.advance();
-        assertEquals(EntityStates.T_END_HEADER, p2.getState());
+        assertEquals(EntityState.T_END_HEADER, p2.getState());
         p2.advance();
-        assertEquals(EntityStates.T_BODY, p2.getState());
+        assertEquals(EntityState.T_BODY, p2.getState());
         assertEquals("yada yada yada", IOUtils.toString(p2.getContentStream()));
         p2.advance();
-        assertEquals(EntityStates.T_END_BODYPART, p2.getState());
+        assertEquals(EntityState.T_END_BODYPART, p2.getState());
         p2.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, p2.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, p2.getState());
 
         entity.advance();
-        assertEquals(EntityStates.T_EPILOGUE, entity.getState());
+        assertEquals(EntityState.T_EPILOGUE, entity.getState());
         assertEquals("Goodbye!", IOUtils.toString(entity.getContentStream()));
         entity.advance();
-        assertEquals(EntityStates.T_END_MULTIPART, entity.getState());
+        assertEquals(EntityState.T_END_MULTIPART, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_END_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_END_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, entity.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, entity.getState());
     }
     
     public void testRawEntity() throws Exception {
@@ -324,42 +324,42 @@ public class MimeEntityTest extends Test
         
         entity.setRecursionMode(RecursionMode.M_RAW);
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("To", entity.getField().getName());
         assertEquals("Road Runner <runner@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("From", entity.getField().getName());
         assertEquals("Wile E. Cayote <wile@example.org>", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Date", entity.getField().getName());
         assertEquals("Tue, 12 Feb 2008 17:34:09 +0000 (GMT)", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Subject", entity.getField().getName());
         assertEquals("Mail", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         assertEquals("Content-Type", entity.getField().getName());
         assertEquals("multipart/mixed;boundary=1729", entity.getField().getBody());
         entity.advance();
-        assertEquals(EntityStates.T_END_HEADER, entity.getState());
+        assertEquals(EntityState.T_END_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_MULTIPART, entity.getState());
+        assertEquals(EntityState.T_START_MULTIPART, entity.getState());
         
         entity.advance();
-        assertEquals(EntityStates.T_PREAMBLE, entity.getState());
+        assertEquals(EntityState.T_PREAMBLE, entity.getState());
         assertEquals("Hello!", IOUtils.toString(entity.getContentStream()));
         
         EntityStateMachine p1 = entity.advance();
         assertNotNull(p1);
         
-        assertEquals(EntityStates.T_RAW_ENTITY, p1.getState());
+        assertEquals(EntityState.T_RAW_ENTITY, p1.getState());
         assertNull(p1.getBodyDescriptor());
         assertNull(p1.getField());
         assertEquals(
@@ -367,12 +367,12 @@ public class MimeEntityTest extends Test
                 "\r\n" +
                 "blah blah blah", IOUtils.toString(p1.getContentStream()));
         p1.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, p1.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, p1.getState());
 
         EntityStateMachine p2 = entity.advance();
         assertNotNull(p2);
         
-        assertEquals(EntityStates.T_RAW_ENTITY, p2.getState());
+        assertEquals(EntityState.T_RAW_ENTITY, p2.getState());
         assertNull(p2.getBodyDescriptor());
         assertNull(p2.getField());
         assertEquals(
@@ -380,17 +380,17 @@ public class MimeEntityTest extends Test
                 "\r\n" +
                 "yada yada yada", IOUtils.toString(p2.getContentStream()));
         p2.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, p2.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, p2.getState());
 
         entity.advance();
-        assertEquals(EntityStates.T_EPILOGUE, entity.getState());
+        assertEquals(EntityState.T_EPILOGUE, entity.getState());
         assertEquals("Goodbye!", IOUtils.toString(entity.getContentStream()));
         entity.advance();
-        assertEquals(EntityStates.T_END_MULTIPART, entity.getState());
+        assertEquals(EntityState.T_END_MULTIPART, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_END_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_END_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_END_OF_STREAM, entity.getState());
+        assertEquals(EntityState.T_END_OF_STREAM, entity.getState());
     }
 
     public void testMaxLineLimitCheck() throws Exception {
@@ -415,19 +415,19 @@ public class MimeEntityTest extends Test
                 lineInput,
                 rawstream,
                 new DefaultBodyDescriptor(),
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE,
+                EntityState.T_START_MESSAGE,
+                EntityState.T_END_MESSAGE,
                 config);
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance(); // advances to T_START_HEADER
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         entity.advance(); // reads To: into field buffer, From: into line buffer
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance(); // reads Date: into line buffer
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance(); // reads Subject: into line buffer
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         try {
             entity.advance(); // reads DoS: into line buffer
             fail("MimeException caused by MaxLineLimitException should have been thrown");
@@ -469,21 +469,21 @@ public class MimeEntityTest extends Test
                 lineInput,
                 rawstream,
                 new DefaultBodyDescriptor(),
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE,
+                EntityState.T_START_MESSAGE,
+                EntityState.T_END_MESSAGE,
                 config);
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         try {
             entity.advance();
             fail("MimeException caused by MaxLineLimitException should have been thrown");
@@ -517,19 +517,19 @@ public class MimeEntityTest extends Test
                 lineInput,
                 rawstream,
                 new DefaultBodyDescriptor(),
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE,
+                EntityState.T_START_MESSAGE,
+                EntityState.T_END_MESSAGE,
                 config);
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         for (int i = 0; i < 6; i++) {
             entity.advance();
-            assertEquals(EntityStates.T_FIELD, entity.getState());
+            assertEquals(EntityState.T_FIELD, entity.getState());
         }
         entity.advance();
-        assertEquals(EntityStates.T_END_HEADER, entity.getState());
+        assertEquals(EntityState.T_END_HEADER, entity.getState());
     }
     
     public void testMaxHeaderCount() throws Exception {
@@ -568,17 +568,17 @@ public class MimeEntityTest extends Test
                 lineInput,
                 rawstream,
                 new DefaultBodyDescriptor(),
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE,
+                EntityState.T_START_MESSAGE,
+                EntityState.T_END_MESSAGE,
                 config);
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         
         for (int i = 0; i < 20; i++) {
             entity.advance();
-            assertEquals(EntityStates.T_FIELD, entity.getState());
+            assertEquals(EntityState.T_FIELD, entity.getState());
         }
         try {
             entity.advance();
@@ -616,27 +616,27 @@ public class MimeEntityTest extends Test
                 lineInput,
                 rawstream,
                 new DefaultBodyDescriptor(),
-                EntityStates.T_START_MESSAGE,
-                EntityStates.T_END_MESSAGE,
+                EntityState.T_START_MESSAGE,
+                EntityState.T_END_MESSAGE,
                 config);
         
-        assertEquals(EntityStates.T_START_MESSAGE, entity.getState());
+        assertEquals(EntityState.T_START_MESSAGE, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_START_HEADER, entity.getState());
+        assertEquals(EntityState.T_START_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_FIELD, entity.getState());
+        assertEquals(EntityState.T_FIELD, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_END_HEADER, entity.getState());
+        assertEquals(EntityState.T_END_HEADER, entity.getState());
         entity.advance();
-        assertEquals(EntityStates.T_BODY, entity.getState());
+        assertEquals(EntityState.T_BODY, entity.getState());
         try {
             IOUtils.toByteArray(entity.getContentStream());
             fail("IOException should have been thrown");

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamTokenMessageRfc822Test.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamTokenMessageRfc822Test.java?rev=1082286&r1=1082285&r2=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamTokenMessageRfc822Test.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamTokenMessageRfc822Test.java Wed Mar 16 20:21:39 2011
@@ -42,58 +42,58 @@ public class MimeStreamTokenMessageRfc82
     }
     
     public void testShouldParseMessageRFC822CorrectWithDefaultConfiguration() throws Exception {
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_START_MESSAGE);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
-        nextIs(MimeTokenStream.T_END_MESSAGE);
-        nextIs(MimeTokenStream.T_END_MESSAGE);
-        nextIs(MimeTokenStream.T_END_OF_STREAM);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_START_MESSAGE);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
+        nextIs(EntityState.T_END_MESSAGE);
+        nextIs(EntityState.T_END_MESSAGE);
+        nextIs(EntityState.T_END_OF_STREAM);
     }
     
     public void testShouldParseMessageRFC822CorrectWithNoRecurse() throws Exception {
         stream.setRecursionMode(RecursionMode.M_NO_RECURSE);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
-        nextIs(MimeTokenStream.T_END_MESSAGE);
-        nextIs(MimeTokenStream.T_END_OF_STREAM);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
+        nextIs(EntityState.T_END_MESSAGE);
+        nextIs(EntityState.T_END_OF_STREAM);
     }
     
     public void testShouldParseMessageRFC822CorrectWithFlat() throws Exception {
         stream.setRecursionMode(RecursionMode.M_FLAT);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
-        nextIs(MimeTokenStream.T_END_MESSAGE);
-        nextIs(MimeTokenStream.T_END_OF_STREAM);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
+        nextIs(EntityState.T_END_MESSAGE);
+        nextIs(EntityState.T_END_OF_STREAM);
     }
     
-    private void nextIs(int state) throws Exception {
+    private void nextIs(EntityState state) throws Exception {
         assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(stream.next()));
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java?rev=1082286&r1=1082285&r2=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java Wed Mar 16 20:21:39 2011
@@ -44,158 +44,158 @@ public class MimeTokenEmbeddedMessageTes
     }
 
     public void testWhenRecurseShouldVisitInnerMailsAndInnerMultiparts() throws Exception {
-        stream.setRecursionMode(MimeTokenStream.M_RECURSE);
+        stream.setRecursionMode(RecursionMode.M_RECURSE);
 
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
         
-        nextIs(MimeTokenStream.T_START_MULTIPART);
+        nextIs(EntityState.T_START_MULTIPART);
         
-        nextIs(MimeTokenStream.T_PREAMBLE);
+        nextIs(EntityState.T_PREAMBLE);
 
         // PART ONE
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream("Rhubarb!\r\n");
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_END_BODYPART);
         
         // PART TWO
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream("987654321AHPLA\r\n");
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_END_BODYPART);
         
         // PART THREE
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_START_MESSAGE);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_START_MULTIPART);
-        nextIs(MimeTokenStream.T_PREAMBLE);
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_START_MESSAGE);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_START_MULTIPART);
+        nextIs(EntityState.T_PREAMBLE);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream("Custard!\r\n");
-        nextIs(MimeTokenStream.T_END_BODYPART);
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_END_BODYPART);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream("CUSTARDCUSTARDCUSTARD\r\n");
-        nextIs(MimeTokenStream.T_END_BODYPART);
-        nextIs(MimeTokenStream.T_EPILOGUE);
-        nextIs(MimeTokenStream.T_END_MULTIPART);   
-        nextIs(MimeTokenStream.T_END_MESSAGE);
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_END_BODYPART);
+        nextIs(EntityState.T_EPILOGUE);
+        nextIs(EntityState.T_END_MULTIPART);   
+        nextIs(EntityState.T_END_MESSAGE);
+        nextIs(EntityState.T_END_BODYPART);
         
         // PART FOUR
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_START_MULTIPART);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_START_MULTIPART);
         checkInputStream(ExampleMail.MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MULTIPART_MIXED);
-        nextIs(MimeTokenStream.T_END_MULTIPART);
-        nextIs(MimeTokenStream.T_END_BODYPART);
-        nextIs(MimeTokenStream.T_EPILOGUE);
-        nextIs(MimeTokenStream.T_END_MULTIPART);
-        nextIs(MimeTokenStream.T_END_MESSAGE);
-        nextIs(MimeTokenStream.T_END_OF_STREAM);
+        nextIs(EntityState.T_END_MULTIPART);
+        nextIs(EntityState.T_END_BODYPART);
+        nextIs(EntityState.T_EPILOGUE);
+        nextIs(EntityState.T_END_MULTIPART);
+        nextIs(EntityState.T_END_MESSAGE);
+        nextIs(EntityState.T_END_OF_STREAM);
     }
     
     
     public void testWhenFlatAtStartShouldIgnoreMultipartStructure() throws Exception {
-        stream.setRecursionMode(MimeTokenStream.M_FLAT);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
+        stream.setRecursionMode(RecursionMode.M_FLAT);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
         
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_BODY);
         
         checkInputStream(ExampleMail.MIME_MULTIPART_EMBEDDED_MESSAGES_BODY);
         
-        nextIs(MimeTokenStream.T_END_MESSAGE);
+        nextIs(EntityState.T_END_MESSAGE);
     }
     
     public void testWhenFlatShouldIgnoreInnerMailsAndInnerMultiparts() throws Exception {
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
         
-        nextIs(MimeTokenStream.T_START_MULTIPART);
+        nextIs(EntityState.T_START_MULTIPART);
         
-        stream.setRecursionMode(MimeTokenStream.M_FLAT);
-        nextIs(MimeTokenStream.T_PREAMBLE);
+        stream.setRecursionMode(RecursionMode.M_FLAT);
+        nextIs(EntityState.T_PREAMBLE);
 
         // PART ONE
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream("Rhubarb!\r\n");
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_END_BODYPART);
         
         // PART TWO
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream("987654321AHPLA\r\n");
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_END_BODYPART);
         
         // PART THREE
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream(ExampleMail.MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MAIL);
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_END_BODYPART);
         
         // PART FOUR
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         checkInputStream(ExampleMail.MIME_MULTIPART_EMBEDDED_MESSAGES_INNER_MULTIPART_MIXED);
-        nextIs(MimeTokenStream.T_END_BODYPART);
-        nextIs(MimeTokenStream.T_EPILOGUE);
-        nextIs(MimeTokenStream.T_END_MULTIPART);
+        nextIs(EntityState.T_END_BODYPART);
+        nextIs(EntityState.T_EPILOGUE);
+        nextIs(EntityState.T_END_MULTIPART);
     }
     
     private void checkInputStream(String expected) throws Exception {
@@ -209,7 +209,7 @@ public class MimeTokenEmbeddedMessageTes
         assertEquals(expected.length(), i);
     }
     
-    private void nextIs(int state) throws Exception {
+    private void nextIs(EntityState state) throws Exception {
         assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(stream.next()));
     }
 }

Modified: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java?rev=1082286&r1=1082285&r2=1082286&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java (original)
+++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java Wed Mar 16 20:21:39 2011
@@ -79,92 +79,92 @@ public class MimeTokenNoRecurseTest exte
     }
 
     public void testWhenRecurseShouldRecurseInnerMail() throws Exception {
-        stream.setRecursionMode(MimeTokenStream.M_RECURSE);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
+        stream.setRecursionMode(RecursionMode.M_RECURSE);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
         
-        nextIs(MimeTokenStream.T_START_MULTIPART);
-        nextIs(MimeTokenStream.T_PREAMBLE);
+        nextIs(EntityState.T_START_MULTIPART);
+        nextIs(EntityState.T_PREAMBLE);
         nextShouldBeStandardPart(false);
         
         nextShouldBeStandardPart(true);
         
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_START_MESSAGE);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_START_MULTIPART);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_START_MESSAGE);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_START_MULTIPART);
         // an empty preamble should not raise a T_PREAMBLE event
-        // nextIs(MimeTokenStream.T_PREAMBLE);
+        // nextIs(EntityStates.T_PREAMBLE);
         nextShouldBeStandardPart(true);
         nextShouldBeStandardPart(true);
-        nextIs(MimeTokenStream.T_EPILOGUE);
-        nextIs(MimeTokenStream.T_END_MULTIPART);
-        nextIs(MimeTokenStream.T_END_MESSAGE);
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_EPILOGUE);
+        nextIs(EntityState.T_END_MULTIPART);
+        nextIs(EntityState.T_END_MESSAGE);
+        nextIs(EntityState.T_END_BODYPART);
         nextShouldBeStandardPart(true);
-        nextIs(MimeTokenStream.T_EPILOGUE);
-        nextIs(MimeTokenStream.T_END_MULTIPART);
+        nextIs(EntityState.T_EPILOGUE);
+        nextIs(EntityState.T_END_MULTIPART);
     }
     
 
     public void testWhenRecurseShouldTreatInnerMailAsAnyOtherPart() throws Exception {
-        stream.setRecursionMode(MimeTokenStream.M_NO_RECURSE);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
+        stream.setRecursionMode(RecursionMode.M_NO_RECURSE);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
         
-        nextIs(MimeTokenStream.T_START_MULTIPART);
-        nextIs(MimeTokenStream.T_PREAMBLE);
+        nextIs(EntityState.T_START_MULTIPART);
+        nextIs(EntityState.T_PREAMBLE);
         nextShouldBeStandardPart(false);
         
         nextShouldBeStandardPart(true);
         nextShouldBeStandardPart(true);
         nextShouldBeStandardPart(true);
-        nextIs(MimeTokenStream.T_EPILOGUE);
-        nextIs(MimeTokenStream.T_END_MULTIPART);
+        nextIs(EntityState.T_EPILOGUE);
+        nextIs(EntityState.T_END_MULTIPART);
     }
     
     public void testWhenNoRecurseInputStreamShouldContainInnerMail() throws Exception {
-        stream.setRecursionMode(MimeTokenStream.M_NO_RECURSE);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
+        stream.setRecursionMode(RecursionMode.M_NO_RECURSE);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
         
-        nextIs(MimeTokenStream.T_START_MULTIPART);
-        nextIs(MimeTokenStream.T_PREAMBLE);
+        nextIs(EntityState.T_START_MULTIPART);
+        nextIs(EntityState.T_PREAMBLE);
         nextShouldBeStandardPart(false);
         
         nextShouldBeStandardPart(true);
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         InputStream inputStream = stream.getInputStream();
         int next = inputStream.read();
         int i=0;
@@ -176,26 +176,26 @@ public class MimeTokenNoRecurseTest exte
     }
     
     public void testSetNoRecurseSoInputStreamShouldContainInnerMail() throws Exception {
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
         
-        nextIs(MimeTokenStream.T_START_MULTIPART);
-        nextIs(MimeTokenStream.T_PREAMBLE);
+        nextIs(EntityState.T_START_MULTIPART);
+        nextIs(EntityState.T_PREAMBLE);
         nextShouldBeStandardPart(false);
         
         nextShouldBeStandardPart(true);
-        stream.setRecursionMode(MimeTokenStream.M_NO_RECURSE);
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
-        nextIs(MimeTokenStream.T_FIELD);
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
+        stream.setRecursionMode(RecursionMode.M_NO_RECURSE);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
+        nextIs(EntityState.T_FIELD);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
         InputStream inputStream = stream.getInputStream();
         int next = inputStream.read();
         int i=0;
@@ -207,17 +207,17 @@ public class MimeTokenNoRecurseTest exte
     }
 
     private void nextShouldBeStandardPart(boolean withHeader) throws Exception {
-        nextIs(MimeTokenStream.T_START_BODYPART);
-        nextIs(MimeTokenStream.T_START_HEADER);
+        nextIs(EntityState.T_START_BODYPART);
+        nextIs(EntityState.T_START_HEADER);
         if (withHeader) {
-            nextIs(MimeTokenStream.T_FIELD);
+            nextIs(EntityState.T_FIELD);
         }
-        nextIs(MimeTokenStream.T_END_HEADER);
-        nextIs(MimeTokenStream.T_BODY);
-        nextIs(MimeTokenStream.T_END_BODYPART);
+        nextIs(EntityState.T_END_HEADER);
+        nextIs(EntityState.T_BODY);
+        nextIs(EntityState.T_END_BODYPART);
     }
     
-    private void nextIs(int state) throws Exception {
+    private void nextIs(EntityState state) throws Exception {
         assertEquals(MimeTokenStream.stateToString(state), MimeTokenStream.stateToString(stream.next()));
     }
 }



Mime
View raw message