james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r897163 [1/2] - in /james/mime4j/branches/cycleclean: benchmark/src/main/java/org/apache/james/mime4j/ core/src/main/java/org/apache/james/mime4j/ core/src/main/java/org/apache/james/mime4j/field/impl/ core/src/main/java/org/apache/james/mi...
Date Fri, 08 Jan 2010 10:52:13 GMT
Author: bago
Date: Fri Jan  8 10:51:51 2010
New Revision: 897163

URL: http://svn.apache.org/viewvc?rev=897163&view=rev
Log:
Renamed packages (related to MIME4J-157):
o.a.j.m.parser => o.a.j.m.stream
o.a.j.m.parser.impl => o.a.j.m.parser

Added:
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/DefaultBodyDescriptor.java   (with props)
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptor.java   (with props)
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java   (with props)
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java   (with props)
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractContentHandler.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/BasicMimeTokenStream.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/BasicMimeTokenStream.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/BodyDescriptor.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/BodyDescriptor.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/ContentDescriptor.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/ContentDescriptor.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/ContentHandler.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/ContentHandler.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/EntityStateMachine.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/EntityStateMachine.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/EntityStates.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/EntityStates.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/Event.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/Event.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/MimeEntity.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntityConfig.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/MimeParseEventException.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeParseEventException.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/MutableBodyDescriptor.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MutableBodyDescriptor.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/RawEntity.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/RawEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/RawField.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/RawField.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/RecursionMode.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/RecursionMode.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/DefaultBodyDescriptorTest.java   (with props)
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MaximalBodyDescriptorTest.java   (with props)
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/BaseTestForBodyDescriptors.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/BaseTestForBodyDescriptors.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeEntityTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamParserExampleMessagesTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamParserTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeStreamTokenMessageRfc822Test.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamTokenMessageRfc822Test.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenEmbeddedMessageTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenEmbeddedMessageTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenNoRecurseTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenNoRecurseTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamBodyDescriptorTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamBodyDescriptorTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamReaderTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamReaderTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MimeTokenStreamTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MultipartStreamTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartStreamTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/MultipartTokensTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/StrictMimeTokenStreamTest.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/StrictMimeTokenStreamTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/stream/TestHandler.java   (contents, props changed)
      - copied, changed from r895589, james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/TestHandler.java
Removed:
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/BasicMimeTokenStream.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/BodyDescriptor.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/ContentDescriptor.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/ContentHandler.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/EntityStateMachine.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/EntityStates.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/Event.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeEntityConfig.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeParseEventException.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MutableBodyDescriptor.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/RawEntity.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/RawField.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/RecursionMode.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/impl/
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/BaseTestForBodyDescriptors.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserExampleMessagesTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeStreamTokenMessageRfc822Test.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenEmbeddedMessageTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenNoRecurseTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamBodyDescriptorTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamReaderTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MimeTokenStreamTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartStreamTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/MultipartTokensTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/StrictMimeTokenStreamTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/TestHandler.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/parser/impl/
Modified:
    james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/MimeException.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/DefaultFieldParser.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/Fields.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/HeaderImpl.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/SimpleContentHandler.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java

Modified: james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java (original)
+++ james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java Fri Jan  8 10:51:51 2010
@@ -28,13 +28,13 @@
 import org.apache.james.mime4j.message.Header;
 import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.message.impl.SimpleContentHandler;
-import org.apache.james.mime4j.parser.AbstractContentHandler;
-import org.apache.james.mime4j.parser.BodyDescriptor;
-import org.apache.james.mime4j.parser.ContentHandler;
-import org.apache.james.mime4j.parser.impl.MimeStreamParser;
-import org.apache.james.mime4j.parser.impl.MimeTokenStream;
+import org.apache.james.mime4j.parser.MimeStreamParser;
+import org.apache.james.mime4j.parser.MimeTokenStream;
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
 import org.apache.james.mime4j.storage.MemoryStorageProvider;
+import org.apache.james.mime4j.stream.AbstractContentHandler;
+import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.ContentHandler;
 
 public class LongMultipartReadBench {
 

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/MimeException.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/MimeException.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/MimeException.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/MimeException.java Fri Jan  8 10:51:51 2010
@@ -22,7 +22,7 @@
 /**
  * MIME processing exception.
  * <p>
- * A <code>MimeException</code> may be thrown by a {@link org.apache.james.mime4j.parser.ContentHandler} to
+ * A <code>MimeException</code> may be thrown by a {@link org.apache.james.mime4j.stream.ContentHandler} to
  * indicate that it has failed to process a message event and that no further
  * events should be generated.
  * <p>

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/DefaultFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/DefaultFieldParser.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/DefaultFieldParser.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/DefaultFieldParser.java Fri Jan  8 10:51:51 2010
@@ -31,7 +31,7 @@
 import org.apache.james.mime4j.field.impl.MailboxListFieldImpl;
 import org.apache.james.mime4j.field.ParsedField;
 import org.apache.james.mime4j.field.impl.UnstructuredFieldImpl;
-import org.apache.james.mime4j.parser.RawField;
+import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
 

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/Fields.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/Fields.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/Fields.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/field/impl/Fields.java Fri Jan  8 10:51:51 2010
@@ -41,7 +41,7 @@
 import org.apache.james.mime4j.field.impl.UnstructuredFieldImpl;
 import org.apache.james.mime4j.field.address.Address;
 import org.apache.james.mime4j.field.address.Mailbox;
-import org.apache.james.mime4j.parser.RawField;
+import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.util.MimeUtil;
 
 /**

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/HeaderImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/HeaderImpl.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/HeaderImpl.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/HeaderImpl.java Fri Jan  8 10:51:51 2010
@@ -27,9 +27,9 @@
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.field.impl.DefaultFieldParser;
 import org.apache.james.mime4j.message.Header;
-import org.apache.james.mime4j.parser.AbstractContentHandler;
-import org.apache.james.mime4j.parser.RawField;
-import org.apache.james.mime4j.parser.impl.MimeStreamParser;
+import org.apache.james.mime4j.parser.MimeStreamParser;
+import org.apache.james.mime4j.stream.AbstractContentHandler;
+import org.apache.james.mime4j.stream.RawField;
 
 /**
  * The header of an entity (see RFC 2045).

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java Fri Jan  8 10:51:51 2010
@@ -33,11 +33,11 @@
 import org.apache.james.mime4j.message.Header;
 import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.Multipart;
-import org.apache.james.mime4j.parser.BodyDescriptor;
-import org.apache.james.mime4j.parser.ContentHandler;
-import org.apache.james.mime4j.parser.RawField;
-import org.apache.james.mime4j.parser.impl.MimeStreamParser;
+import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.storage.StorageProvider;
+import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.ContentHandler;
+import org.apache.james.mime4j.stream.RawField;
 import org.apache.james.mime4j.util.ByteArrayBuffer;
 import org.apache.james.mime4j.util.ByteSequence;
 
@@ -75,7 +75,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startMessage()
+     * @see org.apache.james.mime4j.stream.ContentHandler#startMessage()
      */
     public void startMessage() throws MimeException {
         if (stack.isEmpty()) {
@@ -89,7 +89,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endMessage()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endMessage()
      */
     public void endMessage() throws MimeException {
         expect(Message.class);
@@ -97,14 +97,14 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startHeader()
+     * @see org.apache.james.mime4j.stream.ContentHandler#startHeader()
      */
     public void startHeader() throws MimeException {
         stack.push(new Header());
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#field(Field)
+     * @see org.apache.james.mime4j.stream.ContentHandler#field(Field)
      */
     public void field(RawField field) throws MimeException {
         expect(Header.class);
@@ -113,7 +113,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endHeader()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endHeader()
      */
     public void endHeader() throws MimeException {
         expect(Header.class);
@@ -123,7 +123,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startMultipart(org.apache.james.mime4j.parser.BodyDescriptor)
+     * @see org.apache.james.mime4j.stream.ContentHandler#startMultipart(org.apache.james.mime4j.stream.BodyDescriptor)
      */
     public void startMultipart(final BodyDescriptor bd) throws MimeException {
         expect(Entity.class);
@@ -136,7 +136,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#body(org.apache.james.mime4j.parser.BodyDescriptor, java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#body(org.apache.james.mime4j.stream.BodyDescriptor, java.io.InputStream)
      */
     public void body(BodyDescriptor bd, final InputStream is) throws MimeException, IOException {
         expect(Entity.class);
@@ -171,14 +171,14 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endMultipart()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endMultipart()
      */
     public void endMultipart() throws MimeException {
         stack.pop();
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startBodyPart()
+     * @see org.apache.james.mime4j.stream.ContentHandler#startBodyPart()
      */
     public void startBodyPart() throws MimeException {
         expect(Multipart.class);
@@ -189,7 +189,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endBodyPart()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endBodyPart()
      */
     public void endBodyPart() throws MimeException {
         expect(BodyPart.class);
@@ -197,7 +197,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#epilogue(java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#epilogue(java.io.InputStream)
      */
     public void epilogue(InputStream is) throws MimeException, IOException {
         expect(MultipartImpl.class);
@@ -206,7 +206,7 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#preamble(java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#preamble(java.io.InputStream)
      */
     public void preamble(InputStream is) throws MimeException, IOException {
         expect(MultipartImpl.class);
@@ -216,7 +216,7 @@
     
     /**
      * Unsupported.
-     * @see org.apache.james.mime4j.parser.ContentHandler#raw(java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#raw(java.io.InputStream)
      */
     public void raw(InputStream is) throws MimeException, IOException {
         throw new UnsupportedOperationException("Not supported");

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java Fri Jan  8 10:51:51 2010
@@ -50,10 +50,10 @@
 import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.Multipart;
 import org.apache.james.mime4j.message.SingleBody;
-import org.apache.james.mime4j.parser.MimeEntityConfig;
-import org.apache.james.mime4j.parser.impl.MimeStreamParser;
+import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
 import org.apache.james.mime4j.storage.StorageProvider;
+import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.util.MimeUtil;
 
 /**

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/SimpleContentHandler.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/SimpleContentHandler.java?rev=897163&r1=897162&r2=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/SimpleContentHandler.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/SimpleContentHandler.java Fri Jan  8 10:51:51 2010
@@ -23,8 +23,8 @@
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.field.impl.DefaultFieldParser;
 import org.apache.james.mime4j.message.Header;
-import org.apache.james.mime4j.parser.AbstractContentHandler;
-import org.apache.james.mime4j.parser.RawField;
+import org.apache.james.mime4j.stream.AbstractContentHandler;
+import org.apache.james.mime4j.stream.RawField;
 
 /**
  * Abstract implementation of ContentHandler that automates common
@@ -45,7 +45,7 @@
     private Header currHeader;
 
     /**
-     * @see org.apache.james.mime4j.parser.AbstractContentHandler#startHeader()
+     * @see org.apache.james.mime4j.stream.AbstractContentHandler#startHeader()
      */
     @Override
     public final void startHeader() {
@@ -53,7 +53,7 @@
     }
 
     /**
-     * @see org.apache.james.mime4j.parser.AbstractContentHandler#field(Field)
+     * @see org.apache.james.mime4j.stream.AbstractContentHandler#field(Field)
      */
     @Override
     public final void field(RawField field) throws MimeException {
@@ -62,7 +62,7 @@
     }
 
     /**
-     * @see org.apache.james.mime4j.parser.AbstractContentHandler#endHeader()
+     * @see org.apache.james.mime4j.stream.AbstractContentHandler#endHeader()
      */
     @Override
     public final void endHeader() {

Added: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/DefaultBodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/DefaultBodyDescriptor.java?rev=897163&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/DefaultBodyDescriptor.java (added)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/DefaultBodyDescriptor.java Fri Jan  8 10:51:51 2010
@@ -0,0 +1,430 @@
+/****************************************************************
+ * 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.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.MutableBodyDescriptor;
+import org.apache.james.mime4j.stream.RawField;
+import org.apache.james.mime4j.util.MimeUtil;
+
+/**
+ * Encapsulates the values of the MIME-specific header fields 
+ * (which starts with <code>Content-</code>). 
+ */
+public class DefaultBodyDescriptor implements MutableBodyDescriptor {
+    private static final String US_ASCII = "us-ascii";
+
+    private static final String SUB_TYPE_EMAIL = "rfc822";
+
+    private static final String MEDIA_TYPE_TEXT = "text";
+
+    private static final String MEDIA_TYPE_MESSAGE = "message";
+
+    private static final String EMAIL_MESSAGE_MIME_TYPE = MEDIA_TYPE_MESSAGE + "/" + SUB_TYPE_EMAIL;
+
+    private static final String DEFAULT_SUB_TYPE = "plain";
+
+    private static final String DEFAULT_MEDIA_TYPE = MEDIA_TYPE_TEXT;
+
+    private static final String DEFAULT_MIME_TYPE = DEFAULT_MEDIA_TYPE + "/" + DEFAULT_SUB_TYPE;
+
+    private static Log log = LogFactory.getLog(DefaultBodyDescriptor.class);
+    
+    private String mediaType = DEFAULT_MEDIA_TYPE;
+    private String subType = DEFAULT_SUB_TYPE;
+    private String mimeType = DEFAULT_MIME_TYPE;
+    private String boundary = null;
+    private String charset = US_ASCII;
+    private String transferEncoding = "7bit";
+    private Map<String, String> parameters = new HashMap<String, String>();
+    private boolean contentTypeSet;
+    private boolean contentTransferEncSet;
+    private long contentLength = -1;
+    
+    /**
+     * Creates a new root <code>BodyDescriptor</code> instance.
+     */
+    public DefaultBodyDescriptor() {
+        this(null);
+    }
+
+    /**
+     * Creates a new <code>BodyDescriptor</code> instance.
+     * 
+     * @param parent the descriptor of the parent or <code>null</code> if this
+     *        is the root descriptor.
+     */
+    public DefaultBodyDescriptor(BodyDescriptor parent) {
+        if (parent != null && MimeUtil.isSameMimeType("multipart/digest", parent.getMimeType())) {
+            mimeType = EMAIL_MESSAGE_MIME_TYPE;
+            subType = SUB_TYPE_EMAIL;
+            mediaType = MEDIA_TYPE_MESSAGE;
+        } else {
+            mimeType = DEFAULT_MIME_TYPE;
+            subType = DEFAULT_SUB_TYPE;
+            mediaType = DEFAULT_MEDIA_TYPE;
+        }
+    }
+    
+    public MutableBodyDescriptor newChild() {
+		return new DefaultBodyDescriptor(this);
+    }
+    
+    /**
+     * Should be called for each <code>Content-</code> header field of 
+     * a MIME message or part.
+     * 
+     * @param field the MIME field.
+     */
+    public void addField(RawField field) {
+        String name = field.getName();
+        String value = field.getBody();
+
+        name = name.trim().toLowerCase();
+        
+        if (name.equals("content-transfer-encoding") && !contentTransferEncSet) {
+            contentTransferEncSet = true;
+            
+            value = value.trim().toLowerCase();
+            if (value.length() > 0) {
+                transferEncoding = value;
+            }
+            
+        } else if (name.equals("content-length") && contentLength == -1) {
+            try {
+                contentLength = Long.parseLong(value.trim());
+            } catch (NumberFormatException e) {
+                log.error("Invalid content-length: " + value);
+            }
+        } else if (name.equals("content-type") && !contentTypeSet) {
+            parseContentType(value);
+        }
+    }
+
+    private void parseContentType(String value) {
+        contentTypeSet = true;
+        
+        Map<String, String> params = DefaultBodyDescriptor.getHeaderParams(value);
+        
+        String main = params.get("");
+        String type = null;
+        String subtype = null;
+        if (main != null) {
+            main = main.toLowerCase().trim();
+            int index = main.indexOf('/');
+            boolean valid = false;
+            if (index != -1) {
+                type = main.substring(0, index).trim();
+                subtype = main.substring(index + 1).trim();
+                if (type.length() > 0 && subtype.length() > 0) {
+                    main = type + "/" + subtype;
+                    valid = true;
+                }
+            }
+            
+            if (!valid) {
+                main = null;
+                type = null;
+                subtype = null;
+            }
+        }
+        String b = params.get("boundary");
+        
+        if (main != null 
+                && ((main.startsWith("multipart/") && b != null) 
+                        || !main.startsWith("multipart/"))) {
+            mimeType = main;
+            this.subType = subtype;
+            this.mediaType = type;
+        }
+        
+        if (MimeUtil.isMultipart(mimeType)) {
+            boundary = b;
+        }
+        
+        String c = params.get("charset");
+        charset = null;
+        if (c != null) {
+            c = c.trim();
+            if (c.length() > 0) {
+                charset = c.toLowerCase();
+            }
+        }
+        if (charset == null && MEDIA_TYPE_TEXT.equals(mediaType)) {
+            charset = US_ASCII;
+        }
+        
+        /*
+         * Add all other parameters to parameters.
+         */
+        parameters.putAll(params);
+        parameters.remove("");
+        parameters.remove("boundary");
+        parameters.remove("charset");
+    }
+
+    /**
+     * Return the MimeType 
+     * 
+     * @return mimeType
+     */
+    public String getMimeType() {
+        return mimeType;
+    }
+    
+    /**
+     * Return the boundary
+     * 
+     * @return boundary
+     */
+    public String getBoundary() {
+        return boundary;
+    }
+    
+    /**
+     * Return the charset
+     * 
+     * @return charset
+     */
+    public String getCharset() {
+        return charset;
+    }
+    
+    /**
+     * Return all parameters for the BodyDescriptor
+     * 
+     * @return parameters
+     */
+    public Map<String, String> getContentTypeParameters() {
+        return parameters;
+    }
+    
+    /**
+     * Return the TransferEncoding
+     * 
+     * @return transferEncoding
+     */
+    public String getTransferEncoding() {
+        return transferEncoding;
+    }
+    
+    @Override
+    public String toString() {
+        return mimeType;
+    }
+
+    public long getContentLength() {
+        return contentLength;
+    }
+
+    public String getMediaType() {
+        return mediaType;
+    }
+
+    public String getSubType() {
+        return subType;
+    }
+
+    /**
+     * <p>Parses a complex field value into a map of key/value pairs. You may
+     * use this, for example, to parse a definition like
+     * <pre>
+     *   text/plain; charset=UTF-8; boundary=foobar
+     * </pre>
+     * The above example would return a map with the keys "", "charset",
+     * and "boundary", and the values "text/plain", "UTF-8", and "foobar".
+     * </p><p>
+     * Header value will be unfolded and excess white space trimmed.
+     * </p>
+     * @param pValue The field value to parse.
+     * @return The result map; use the key "" to retrieve the first value.
+     */
+    public static Map<String, String> getHeaderParams(String pValue) {
+        pValue = pValue.trim();
+        
+        Map<String, String> result = new HashMap<String, String>();
+    
+        // split main value and parameters
+        String main;
+        String rest;
+        if (pValue.indexOf(";") == -1) {
+            main = pValue;
+            rest = null;
+        } else {
+            main = pValue.substring(0, pValue.indexOf(";"));
+            rest = pValue.substring(main.length() + 1);
+        }
+    
+        result.put("", main);
+        if (rest != null) {
+            char[] chars = rest.toCharArray();
+            StringBuilder paramName = new StringBuilder(64);
+            StringBuilder paramValue = new StringBuilder(64);
+    
+            final byte READY_FOR_NAME = 0;
+            final byte IN_NAME = 1;
+            final byte READY_FOR_VALUE = 2;
+            final byte IN_VALUE = 3;
+            final byte IN_QUOTED_VALUE = 4;
+            final byte VALUE_DONE = 5;
+            final byte ERROR = 99;
+    
+            byte state = READY_FOR_NAME;
+            boolean escaped = false;
+            for (char c : chars) {
+                switch (state) {
+                    case ERROR:
+                        if (c == ';')
+                            state = READY_FOR_NAME;
+                        break;
+    
+                    case READY_FOR_NAME:
+                        if (c == '=') {
+                            log.error("Expected header param name, got '='");
+                            state = ERROR;
+                            break;
+                        }
+    
+                        paramName.setLength(0);
+                        paramValue.setLength(0);
+    
+                        state = IN_NAME;
+                        // fall-through
+    
+                    case IN_NAME:
+                        if (c == '=') {
+                            if (paramName.length() == 0)
+                                state = ERROR;
+                            else
+                                state = READY_FOR_VALUE;
+                            break;
+                        }
+    
+                        // not '='... just add to name
+                        paramName.append(c);
+                        break;
+    
+                    case READY_FOR_VALUE:
+                        boolean fallThrough = false;
+                        switch (c) {
+                            case ' ':
+                            case '\t':
+                                break;  // ignore spaces, especially before '"'
+    
+                            case '"':
+                                state = IN_QUOTED_VALUE;
+                                break;
+    
+                            default:
+                                state = IN_VALUE;
+                                fallThrough = true;
+                                break;
+                        }
+                        if (!fallThrough)
+                            break;
+    
+                        // fall-through
+    
+                    case IN_VALUE:
+                        fallThrough = false;
+                        switch (c) {
+                            case ';':
+                            case ' ':
+                            case '\t':
+                                result.put(
+                                   paramName.toString().trim().toLowerCase(),
+                                   paramValue.toString().trim());
+                                state = VALUE_DONE;
+                                fallThrough = true;
+                                break;
+                            default:
+                                paramValue.append(c);
+                                break;
+                        }
+                        if (!fallThrough)
+                            break;
+    
+                    case VALUE_DONE:
+                        switch (c) {
+                            case ';':
+                                state = READY_FOR_NAME;
+                                break;
+    
+                            case ' ':
+                            case '\t':
+                                break;
+    
+                            default:
+                                state = ERROR;
+                                break;
+                        }
+                        break;
+                        
+                    case IN_QUOTED_VALUE:
+                        switch (c) {
+                            case '"':
+                                if (!escaped) {
+                                    // don't trim quoted strings; the spaces could be intentional.
+                                    result.put(
+                                            paramName.toString().trim().toLowerCase(),
+                                            paramValue.toString());
+                                    state = VALUE_DONE;
+                                } else {
+                                    escaped = false;
+                                    paramValue.append(c);                                    
+                                }
+                                break;
+                                
+                            case '\\':
+                                if (escaped) {
+                                    paramValue.append('\\');
+                                }
+                                escaped = !escaped;
+                                break;
+    
+                            default:
+                                if (escaped) {
+                                    paramValue.append('\\');
+                                }
+                                escaped = false;
+                                paramValue.append(c);
+                                break;
+                        }
+                        break;
+    
+                }
+            }
+    
+            // done looping.  check if anything is left over.
+            if (state == IN_VALUE) {
+                result.put(
+                        paramName.toString().trim().toLowerCase(),
+                        paramValue.toString().trim());
+            }
+        }
+    
+        return result;
+    }
+}

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/DefaultBodyDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/DefaultBodyDescriptor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptor.java?rev=897163&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptor.java (added)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptor.java Fri Jan  8 10:51:51 2010
@@ -0,0 +1,479 @@
+/****************************************************************
+ * 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.parser;
+
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.field.datetime.DateTime;
+import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
+import org.apache.james.mime4j.field.datetime.parser.ParseException;
+import org.apache.james.mime4j.field.language.parser.ContentLanguageParser;
+import org.apache.james.mime4j.field.mimeversion.parser.MimeVersionParser;
+import org.apache.james.mime4j.field.structured.parser.StructuredFieldParser;
+import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.MutableBodyDescriptor;
+import org.apache.james.mime4j.stream.RawField;
+import org.apache.james.mime4j.util.MimeUtil;
+
+/**
+ * Parses and stores values for standard MIME header values.
+ * 
+ */
+public class MaximalBodyDescriptor extends DefaultBodyDescriptor {
+
+    private static final int DEFAULT_MINOR_VERSION = 0;
+    private static final int DEFAULT_MAJOR_VERSION = 1;
+    private boolean isMimeVersionSet;
+    private int mimeMinorVersion;
+    private int mimeMajorVersion;
+    private MimeException mimeVersionException;
+    private String contentId;
+    private boolean isContentIdSet;
+    private String contentDescription;
+    private boolean isContentDescriptionSet;
+    private String contentDispositionType;
+    private Map<String, String> contentDispositionParameters;
+    private DateTime contentDispositionModificationDate;
+    private MimeException contentDispositionModificationDateParseException;
+    private DateTime contentDispositionCreationDate;
+    private MimeException contentDispositionCreationDateParseException;
+    private DateTime contentDispositionReadDate;
+    private MimeException contentDispositionReadDateParseException;
+    private long contentDispositionSize;
+    private MimeException contentDispositionSizeParseException;
+    private boolean isContentDispositionSet;
+    private List<String> contentLanguage;
+    private MimeException contentLanguageParseException;
+    private boolean isContentLanguageSet;
+    private MimeException contentLocationParseException;
+    private String contentLocation;
+    private boolean isContentLocationSet;
+    private String contentMD5Raw;
+    private boolean isContentMD5Set;
+    
+    protected MaximalBodyDescriptor() {
+        this(null);
+    }
+
+    public MaximalBodyDescriptor(BodyDescriptor parent) {
+        super(parent);
+        isMimeVersionSet = false;
+        mimeMajorVersion = DEFAULT_MAJOR_VERSION;
+        mimeMinorVersion = DEFAULT_MINOR_VERSION;
+        this.contentId = null;
+        this.isContentIdSet = false;
+        this.contentDescription = null;
+        this.isContentDescriptionSet = false;
+        this.contentDispositionType = null;
+        this.contentDispositionParameters = Collections.emptyMap();
+        this.contentDispositionModificationDate = null;
+        this.contentDispositionModificationDateParseException = null;
+        this.contentDispositionCreationDate = null;
+        this.contentDispositionCreationDateParseException = null;
+        this.contentDispositionReadDate = null;
+        this.contentDispositionReadDateParseException = null;
+        this.contentDispositionSize = -1;
+        this.contentDispositionSizeParseException = null;
+        this.isContentDispositionSet = false;
+        this.contentLanguage = null;
+        this.contentLanguageParseException = null;
+        this.isContentIdSet = false;
+        this.contentLocation = null;
+        this.contentLocationParseException = null;
+        this.isContentLocationSet = false;
+        this.contentMD5Raw = null;
+        this.isContentMD5Set = false;
+    }
+
+    public MutableBodyDescriptor newChild() {
+		return new MaximalBodyDescriptor(this);
+    }
+
+    @Override
+    public void addField(RawField field) {
+        String name = field.getName();
+        String value = field.getBody();
+        name = name.trim().toLowerCase();
+        if (MimeUtil.MIME_HEADER_MIME_VERSION.equals(name) && !isMimeVersionSet) {
+            parseMimeVersion(value);
+        } else if (MimeUtil.MIME_HEADER_CONTENT_ID.equals(name) && !isContentIdSet) {
+            parseContentId(value);
+        } else if (MimeUtil.MIME_HEADER_CONTENT_DESCRIPTION.equals(name) && !isContentDescriptionSet) {
+            parseContentDescription(value);
+        } else if (MimeUtil.MIME_HEADER_CONTENT_DISPOSITION.equals(name) && !isContentDispositionSet) {
+            parseContentDisposition(value);
+        } else if (MimeUtil.MIME_HEADER_LANGAUGE.equals(name) && !isContentLanguageSet) {
+            parseLanguage(value);
+        } else if (MimeUtil.MIME_HEADER_LOCATION.equals(name) && !isContentLocationSet) {
+            parseLocation(value);
+        } else if (MimeUtil.MIME_HEADER_MD5.equals(name) && !isContentMD5Set) {
+            parseMD5(value);
+        } else {
+            super.addField(field);
+        }
+    }
+    
+    private void parseMD5(String value) {
+        isContentMD5Set = true;
+        if (value != null) {
+            contentMD5Raw = value.trim();
+        }
+    }
+
+    private void parseLocation(final String value) {
+        isContentLocationSet = true;
+        if (value != null) {
+            final StringReader stringReader = new StringReader(value);
+            final StructuredFieldParser parser = new StructuredFieldParser(stringReader);
+            try {
+            	// From RFC2017 3.1
+            	/*
+            	 * Extraction of the URL string from the URL-parameter is even simpler:
+            	 * The enclosing quotes and any linear whitespace are removed and the
+            	 * remaining material is the URL string.
+            	 * Read more: http://www.faqs.org/rfcs/rfc2017.html#ixzz0aufO9nRL
+            	 */
+                contentLocation = parser.parse().replaceAll("\\s", "");
+            } catch (MimeException e) { 
+                contentLocationParseException = e;
+            }
+        }
+    }
+    
+    private void parseLanguage(final String value) {
+        isContentLanguageSet = true;
+        if (value != null) {
+            try {
+                final ContentLanguageParser parser = new ContentLanguageParser(new StringReader(value));
+                contentLanguage = parser.parse();
+            } catch (MimeException e) {
+                contentLanguageParseException = e;
+            }
+        }
+    }
+
+    private void parseContentDisposition(final String value) {
+        isContentDispositionSet = true;
+        contentDispositionParameters = DefaultBodyDescriptor.getHeaderParams(value);
+        contentDispositionType = contentDispositionParameters.get("");
+        
+        final String contentDispositionModificationDate 
+            = contentDispositionParameters.get(MimeUtil.PARAM_MODIFICATION_DATE);
+        if (contentDispositionModificationDate != null) {
+            try {
+                this.contentDispositionModificationDate = parseDate(contentDispositionModificationDate);
+            } catch (ParseException e) {
+                this.contentDispositionModificationDateParseException = e;
+            } 
+        }
+        
+        final String contentDispositionCreationDate 
+            = contentDispositionParameters.get(MimeUtil.PARAM_CREATION_DATE);
+        if (contentDispositionCreationDate != null) {
+            try {
+                this.contentDispositionCreationDate = parseDate(contentDispositionCreationDate);
+            } catch (ParseException e) {
+                this.contentDispositionCreationDateParseException = e;
+            }         
+        }
+        
+        final String contentDispositionReadDate 
+            = contentDispositionParameters.get(MimeUtil.PARAM_READ_DATE);
+        if (contentDispositionReadDate != null) {
+            try {
+                this.contentDispositionReadDate = parseDate(contentDispositionReadDate);
+            } catch (ParseException e) {
+                this.contentDispositionReadDateParseException = e;
+            }         
+        }
+        
+        final String size = contentDispositionParameters.get(MimeUtil.PARAM_SIZE);
+        if (size != null) {
+            try {
+                contentDispositionSize = Long.parseLong(size);
+            } catch (NumberFormatException e) {
+                this.contentDispositionSizeParseException = (MimeException) new MimeException(e.getMessage(), e).fillInStackTrace();
+            }
+        }
+        contentDispositionParameters.remove("");
+    }
+
+    private DateTime parseDate(final String date) throws ParseException {
+        final StringReader stringReader = new StringReader(date);
+        final DateTimeParser parser = new DateTimeParser(stringReader);
+        DateTime result = parser.date_time();
+        return result;
+    }
+    
+    private void parseContentDescription(String value) {
+        if (value == null) {
+            contentDescription = "";
+        } else {
+            contentDescription = value.trim();
+        }
+        isContentDescriptionSet = true;
+    }
+
+    private void parseContentId(final String value) {
+        if (value == null) {
+            contentId = "";
+        } else {
+            contentId = value.trim();
+        }
+        isContentIdSet = true;
+    }
+
+    private void parseMimeVersion(String value) {
+        final StringReader reader = new StringReader(value);
+        final MimeVersionParser parser = new MimeVersionParser(reader);
+        try {
+            parser.parse();
+            final int major = parser.getMajorVersion();
+            if (major != MimeVersionParser.INITIAL_VERSION_VALUE) {
+                mimeMajorVersion = major;
+            }
+            final int minor = parser.getMinorVersion();
+            if (minor != MimeVersionParser.INITIAL_VERSION_VALUE) {
+                mimeMinorVersion = minor;
+            }
+        } catch (MimeException e) {
+            this.mimeVersionException = e;
+        }
+        isMimeVersionSet = true;
+    }
+    
+    /**
+     * Gets the MIME major version
+     * as specified by the <code>MIME-Version</code>
+     * header.
+     * Defaults to one.
+     * @return positive integer
+     */
+    public int getMimeMajorVersion() {
+        return mimeMajorVersion;
+    }
+    
+    /**
+     * Gets the MIME minor version
+     * as specified by the <code>MIME-Version</code>
+     * header. 
+     * Defaults to zero.
+     * @return positive integer
+     */
+    public int getMimeMinorVersion() {
+        return mimeMinorVersion;
+    }
+    
+
+    /**
+     * When the MIME version header exists but cannot be parsed
+     * this field will be contain the exception.
+     * @return <code>MimeException</code> if the mime header cannot
+     * be parsed, null otherwise
+     */
+    public MimeException getMimeVersionParseException() {
+        return mimeVersionException;
+    }
+    
+    /**
+     * Gets the value of the <a href='http://www.faqs.org/rfcs/rfc2045'>RFC</a> 
+     * <code>Content-Description</code> header.
+     * @return value of the <code>Content-Description</code> when present,
+     * null otherwise
+     */
+    public String getContentDescription() {
+        return contentDescription;
+    }
+    
+    /**
+     * Gets the value of the <a href='http://www.faqs.org/rfcs/rfc2045'>RFC</a> 
+     * <code>Content-ID</code> header.
+     * @return value of the <code>Content-ID</code> when present,
+     * null otherwise
+     */
+    public String getContentId() {
+        return contentId;
+    }
+    
+    /**
+     * Gets the disposition type of the <code>content-disposition</code> field.
+     * The value is case insensitive and will be converted to lower case.
+     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
+     * @return content disposition type, 
+     * or null when this has not been set
+     */
+    public String getContentDispositionType() {
+        return contentDispositionType;
+    }
+    
+    /**
+     * Gets the parameters of the <code>content-disposition</code> field.
+     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
+     * @return parameter value strings indexed by parameter name strings,
+     * not null
+     */
+    public Map<String, String> getContentDispositionParameters() {
+        return contentDispositionParameters;
+    }
+    
+    /**
+     * Gets the <code>filename</code> parameter value of the <code>content-disposition</code> field.
+     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
+     * @return filename parameter value, 
+     * or null when it is not present
+     */
+    public String getContentDispositionFilename() {
+        return contentDispositionParameters.get(MimeUtil.PARAM_FILENAME);
+    }
+    
+    /**
+     * Gets the <code>modification-date</code> parameter value of the <code>content-disposition</code> field.
+     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
+     * @return modification-date parameter value,
+     * or null when this is not present
+     */
+    public DateTime getContentDispositionModificationDate() {
+        return contentDispositionModificationDate;
+    }
+    
+    /**
+     * Gets any exception thrown during the parsing of {@link #getContentDispositionModificationDate()}
+     * @return <code>ParseException</code> when the modification-date parse fails,
+     * null otherwise
+     */
+    public MimeException getContentDispositionModificationDateParseException() {
+        return contentDispositionModificationDateParseException;
+    }
+    
+    /**
+     * Gets the <code>creation-date</code> parameter value of the <code>content-disposition</code> field.
+     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
+     * @return creation-date parameter value,
+     * or null when this is not present
+     */
+    public DateTime getContentDispositionCreationDate() {
+        return contentDispositionCreationDate;
+    }
+    
+    /**
+     * Gets any exception thrown during the parsing of {@link #getContentDispositionCreationDate()}
+     * @return <code>ParseException</code> when the creation-date parse fails,
+     * null otherwise
+     */
+    public MimeException getContentDispositionCreationDateParseException() {
+        return contentDispositionCreationDateParseException;
+    }
+    
+    /**
+     * Gets the <code>read-date</code> parameter value of the <code>content-disposition</code> field.
+     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
+     * @return read-date parameter value,
+     * or null when this is not present
+     */
+    public DateTime getContentDispositionReadDate() {
+        return contentDispositionReadDate;
+    }
+    
+    /**
+     * Gets any exception thrown during the parsing of {@link #getContentDispositionReadDate()}
+     * @return <code>ParseException</code> when the read-date parse fails,
+     * null otherwise
+     */
+    public MimeException getContentDispositionReadDateParseException() {
+        return contentDispositionReadDateParseException;
+    }
+    
+    /**
+     * Gets the <code>size</code> parameter value of the <code>content-disposition</code> field.
+     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
+     * @return size parameter value,
+     * or -1 if this size has not been set
+     */
+    public long getContentDispositionSize() {
+        return contentDispositionSize;
+    }
+    
+    /**
+     * Gets any exception thrown during the parsing of {@link #getContentDispositionSize()}
+     * @return <code>ParseException</code> when the read-date parse fails,
+     * null otherwise
+     */
+    public MimeException getContentDispositionSizeParseException() {
+        return contentDispositionSizeParseException;
+    }
+    
+    /**
+     * Get the <code>content-language</code> header values.
+     * Each applicable language tag will be returned in order.
+     * See <a href='http://tools.ietf.org/html/rfc4646'>RFC4646</a> 
+     * <cite>http://tools.ietf.org/html/rfc4646</cite>.
+     * @return list of language tag Strings,
+     * or null if no header exists
+     */
+    public List<String> getContentLanguage() {
+        return contentLanguage;
+    }
+
+    /**
+     * Gets any exception thrown during the parsing of {@link #getContentLanguage()}
+     * @return <code>ParseException</code> when the content-language parse fails,
+     * null otherwise
+     */
+    public MimeException getContentLanguageParseException() {
+        return contentLanguageParseException;
+    }
+    
+
+    /**
+     * Get the <code>content-location</code> header value.
+     * See <a href='http://tools.ietf.org/html/rfc2557'>RFC2557</a> 
+     * @return the URL content-location
+     * or null if no header exists
+     */
+    public String getContentLocation() {
+        return contentLocation;
+    }
+    
+    /**
+     * Gets any exception thrown during the parsing of {@link #getContentLocation()}
+     * @return <code>ParseException</code> when the content-language parse fails,
+     * null otherwise
+     */
+    public MimeException getContentLocationParseException() {
+        return contentLocationParseException;
+    }
+    
+    /**
+     * Gets the raw, Base64 encoded value of the
+     * <code>Content-MD5</code> field.
+     * See <a href='http://tools.ietf.org/html/rfc1864'>RFC1864</a>.
+     * @return raw encoded content-md5
+     * or null if no header exists
+     */
+    public String getContentMD5Raw() {
+        return contentMD5Raw;
+    }
+    
+    
+} 

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MaximalBodyDescriptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java?rev=897163&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java (added)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java Fri Jan  8 10:51:51 2010
@@ -0,0 +1,226 @@
+/****************************************************************
+ * 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.parser;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.SequenceInputStream;
+
+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.ContentHandler;
+import org.apache.james.mime4j.stream.MimeEntityConfig;
+
+/**
+ * <p>
+ * Parses MIME (or RFC822) message streams of bytes or characters and reports 
+ * parsing events to a <code>ContentHandler</code> instance.
+ * </p>
+ * <p>
+ * Typical usage:<br/>
+ * <pre>
+ *      ContentHandler handler = new MyHandler();
+ *      MimeStreamParser parser = new MimeStreamParser();
+ *      parser.setContentHandler(handler);
+ *      parser.parse(new FileInputStream("mime.msg"));
+ * </pre>
+ */
+public class MimeStreamParser {
+
+    private ContentHandler handler = null;
+    private boolean contentDecoding;
+    private final MimeEntityConfig mimeEntityConfig;
+    
+    private final MimeTokenStream mimeTokenStream;
+
+    public MimeStreamParser(MimeTokenStream tokenStream) {
+        super();
+        this.mimeTokenStream = tokenStream;
+        this.mimeEntityConfig = tokenStream.getConfig();
+        this.contentDecoding = false;
+    }
+
+    public MimeStreamParser(final MimeEntityConfig config, DecodeMonitor monitor, boolean clone) {
+        this(new MimeTokenStream(clone ? config.clone() : config, monitor));
+    }
+
+    public MimeStreamParser(final MimeEntityConfig config, boolean clone) {
+        this(new MimeTokenStream(clone ? config.clone() : config, null));
+    }
+
+    public MimeStreamParser(final MimeEntityConfig config, DecodeMonitor monitor) {
+        this(config != null ? config : new MimeEntityConfig(), monitor, config != null);
+    }
+
+    public MimeStreamParser(final MimeEntityConfig config) {
+        this(config, null);
+    }
+
+    public MimeStreamParser() {
+        this(new MimeEntityConfig(), false);
+    }
+    
+    /**
+     * Determines whether this parser automatically decodes body content
+     * based on the on the MIME fields with the standard defaults.
+     */ 
+    public boolean isContentDecoding() {
+        return contentDecoding;
+    }
+
+    /**
+     * Defines whether parser should automatically decode body content
+     * based on the on the MIME fields with the standard defaults.
+     */ 
+    public void setContentDecoding(boolean b) {
+        this.contentDecoding = b;
+    }
+
+    /**
+     * Parses a stream of bytes containing a MIME message. If the mime config of this
+     * object contains a not null defaultContentType
+     * ({@link MimeEntityConfig#getDefaultContentType()}) a headless parsing is performed.
+     * 
+     * @param is the stream to parse.
+     * @throws MimeException if the message can not be processed
+     * @throws IOException on I/O errors.
+     */
+    public void parse(InputStream is) throws MimeException, IOException {
+        boolean headless = mimeEntityConfig.getDefaultContentType() != null;
+        InputStream inputStream = is;
+        if (headless) {
+            ByteArrayInputStream headerInputStream = new ByteArrayInputStream(
+                    ("Content-Type: " + mimeEntityConfig.getDefaultContentType()
+                            + "\r\n\r\n").getBytes("iso-8859-1"));
+            inputStream = new SequenceInputStream(headerInputStream, is);
+        }
+        mimeTokenStream.parse(inputStream);
+        OUTER: for (;;) {
+            int state = mimeTokenStream.getState();
+            switch (state) {
+                case MimeTokenStream.T_BODY:
+                    BodyDescriptor desc = mimeTokenStream.getBodyDescriptor();
+                    InputStream bodyContent;
+                    if (contentDecoding) {
+                        bodyContent = mimeTokenStream.getDecodedInputStream(); 
+                    } else {
+                        bodyContent = mimeTokenStream.getInputStream(); 
+                    }
+                    handler.body(desc, bodyContent);
+                    break;
+                case MimeTokenStream.T_END_BODYPART:
+                    handler.endBodyPart();
+                    break;
+                case MimeTokenStream.T_END_HEADER:
+                    handler.endHeader();
+                    break;
+                case MimeTokenStream.T_END_MESSAGE:
+                    handler.endMessage();
+                    break;
+                case MimeTokenStream.T_END_MULTIPART:
+                    handler.endMultipart();
+                    break;
+                case MimeTokenStream.T_END_OF_STREAM:
+                    break OUTER;
+                case MimeTokenStream.T_EPILOGUE:
+                    handler.epilogue(mimeTokenStream.getInputStream());
+                    break;
+                case MimeTokenStream.T_FIELD:
+                    handler.field(mimeTokenStream.getField());
+                    break;
+                case MimeTokenStream.T_PREAMBLE:
+                    handler.preamble(mimeTokenStream.getInputStream());
+                    break;
+                case MimeTokenStream.T_RAW_ENTITY:
+                    handler.raw(mimeTokenStream.getInputStream());
+                    break;
+                case MimeTokenStream.T_START_BODYPART:
+                    handler.startBodyPart();
+                    break;
+                case MimeTokenStream.T_START_HEADER:
+                    handler.startHeader();
+                    break;
+                case MimeTokenStream.T_START_MESSAGE:
+                    handler.startMessage();
+                    break;
+                case MimeTokenStream.T_START_MULTIPART:
+                    handler.startMultipart(mimeTokenStream.getBodyDescriptor());
+                    break;
+                default:
+                    throw new IllegalStateException("Invalid state: " + state);
+            }
+            state = mimeTokenStream.next();
+        }
+    }
+    
+    /**
+     * Determines if this parser is currently in raw mode.
+     * 
+     * @return <code>true</code> if in raw mode, <code>false</code>
+     *         otherwise.
+     * @see #setRaw(boolean)
+     */
+    public boolean isRaw() {
+        return mimeTokenStream.isRaw();
+    }
+    
+    /**
+     * Enables or disables raw mode. In raw mode all future entities 
+     * (messages or body parts) in the stream will be reported to the
+     * {@link ContentHandler#raw(InputStream)} handler method only.
+     * The stream will contain the entire unparsed entity contents 
+     * including header fields and whatever is in the body.
+     * 
+     * @param raw <code>true</code> enables raw mode, <code>false</code>
+     *        disables it.
+     */
+    public void setRaw(boolean raw) {
+        mimeTokenStream.setRecursionMode(MimeTokenStream.M_RAW);
+    }
+    
+    /**
+     * Finishes the parsing and stops reading lines.
+     * NOTE: No more lines will be parsed but the parser
+     * will still call 
+     * {@link ContentHandler#endMultipart()},
+     * {@link ContentHandler#endBodyPart()},
+     * {@link ContentHandler#endMessage()}, etc to match previous calls
+     * to 
+     * {@link ContentHandler#startMultipart(BodyDescriptor)},
+     * {@link ContentHandler#startBodyPart()},
+     * {@link ContentHandler#startMessage()}, etc.
+     */
+    public void stop() {
+        mimeTokenStream.stop();
+    }
+    
+    /**
+     * Sets the <code>ContentHandler</code> to use when reporting 
+     * parsing events.
+     * 
+     * @param h the <code>ContentHandler</code>.
+     */
+    public void setContentHandler(ContentHandler h) {
+        this.handler = h;
+    }
+
+}

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java?rev=897163&view=auto
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java (added)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java Fri Jan  8 10:51:51 2010
@@ -0,0 +1,160 @@
+/****************************************************************
+ * 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.parser;
+
+import java.io.InputStream;
+
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.stream.BasicMimeTokenStream;
+import org.apache.james.mime4j.stream.BodyDescriptor;
+import org.apache.james.mime4j.stream.MimeEntityConfig;
+import org.apache.james.mime4j.stream.MutableBodyDescriptor;
+import org.apache.james.mime4j.stream.RawField;
+
+/**
+ * <p>
+ * Parses MIME (or RFC822) message streams of bytes or characters.
+ * The stream is converted into an event stream.
+ * <p>
+ * <p>
+ * Typical usage:
+ * </p>
+ * <pre>
+ *      MimeTokenStream stream = new MimeTokenStream();
+ *      stream.parse(new FileInputStream("mime.msg"));
+ *      for (int state = stream.getState();
+ *           state != MimeTokenStream.T_END_OF_STREAM;
+ *           state = stream.next()) {
+ *          switch (state) {
+ *            case MimeTokenStream.T_BODY:
+ *              System.out.println("Body detected, contents = "
+ *                + stream.getInputStream() + ", header data = "
+ *                + stream.getBodyDescriptor());
+ *              break;
+ *            case MimeTokenStream.T_FIELD:
+ *              System.out.println("Header field detected: "
+ *                + stream.getField());
+ *              break;
+ *            case MimeTokenStream.T_START_MULTIPART:
+ *              System.out.println("Multipart message detexted,"
+ *                + " header data = "
+ *                + stream.getBodyDescriptor());
+ *            ...
+ *          }
+ *      }
+ * </pre>
+ * <p>Instances of {@link MimeTokenStream} are reusable: Invoking the
+ * method {@link #parse(InputStream)} resets the token streams internal
+ * state. However, they are definitely <em>not</em> thread safe. If you
+ * have a multi threaded application, then the suggested use is to have
+ * one instance per thread.</p>
+ */
+public class MimeTokenStream extends BasicMimeTokenStream {
+    
+    /**
+     * Creates a stream that creates a more detailed body descriptor.
+     * @return <code>MimeTokenStream</code>, not null
+     */
+    public static final MimeTokenStream createMaximalDescriptorStream() {
+        MimeEntityConfig config = new MimeEntityConfig();
+        config.setMaximalBodyDescriptor(true);
+        return new MimeTokenStream(config);
+    }
+    
+    /**
+     * Creates a stream that strictly validates the input.
+     * @return <code>MimeTokenStream</code> which throws a 
+     * <code>MimeException</code> whenever possible issues 
+     * are dedicated in the input
+     */
+    public static final MimeTokenStream createStrictValidationStream() {
+        MimeEntityConfig config = new MimeEntityConfig();
+        config.setStrictParsing(true);
+        return new MimeTokenStream(config);
+    }
+    
+    /**
+     * Constructs a standard (lax) stream.
+     * Optional validation events will be logged only.
+     * Use {@link #createStrictValidationStream()} to create
+     * a stream that strictly validates the input.
+     */
+    public MimeTokenStream() {
+        this(new MimeEntityConfig());
+    }
+    
+    public MimeTokenStream(final MimeEntityConfig config) {
+        this(config, null);
+    }
+    
+    public MimeTokenStream(final MimeEntityConfig config, DecodeMonitor monitor) {
+        super(config, monitor);
+    }
+
+    /** Instructs the {@code MimeTokenStream} to parse the given streams contents.
+     * If the {@code MimeTokenStream} has already been in use, resets the streams
+     * internal state.
+     */
+    public void parse(InputStream stream) {
+        doParse(stream, null);
+    }
+
+    /** Instructs the {@code MimeTokenStream} to parse the given content with 
+     * the content type. The message stream is assumed to have no message header
+     * and is expected to begin with a message body. This can be the case when 
+     * the message content is transmitted using a different transport protocol 
+     * such as HTTP.
+     * <p/>
+     * If the {@code MimeTokenStream} has already been in use, resets the streams
+     * internal state.
+     */    
+    public void parseHeadless(InputStream stream, String contentType) {
+        if (contentType == null) {
+            throw new IllegalArgumentException("Content type may not be null");
+        }
+        doParse(stream, contentType);
+    }
+
+    private void doParse(InputStream stream, String contentType) {
+        MutableBodyDescriptor newBodyDescriptor = newBodyDescriptor();
+        int start = T_START_MESSAGE;
+        if (contentType != null) {
+        	start = T_END_HEADER;
+        	newBodyDescriptor.addField(new RawField("Content-Type", contentType));
+        }
+        doParse(stream, newBodyDescriptor, start);
+    }
+
+    /**
+     * Creates a new instance of {@link BodyDescriptor}. Subclasses may override
+     * this in order to create body descriptors, that provide more specific
+     * information.
+     */
+    protected MutableBodyDescriptor newBodyDescriptor() {
+        final MutableBodyDescriptor result;
+        if (getConfig().isMaximalBodyDescriptor()) {
+            result = new MaximalBodyDescriptor(null);
+        } else {
+            result = new DefaultBodyDescriptor(null);
+        }
+        return result;
+    }
+
+}

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractContentHandler.java (from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java)
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractContentHandler.java?p2=james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractContentHandler.java&p1=james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java&r1=895589&r2=897163&rev=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractContentHandler.java Fri Jan  8 10:51:51 2010
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.parser;
+package org.apache.james.mime4j.stream;
 
 import org.apache.james.mime4j.MimeException;
 
@@ -33,80 +33,80 @@
 public abstract class AbstractContentHandler implements ContentHandler {
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endMultipart()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endMultipart()
      */
     public void endMultipart() throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startMultipart(org.apache.james.mime4j.parser.BodyDescriptor)
+     * @see org.apache.james.mime4j.stream.ContentHandler#startMultipart(org.apache.james.mime4j.stream.BodyDescriptor)
      */
     public void startMultipart(BodyDescriptor bd) throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#body(org.apache.james.mime4j.parser.BodyDescriptor, java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#body(org.apache.james.mime4j.stream.BodyDescriptor, java.io.InputStream)
      */
     public void body(BodyDescriptor bd, InputStream is)
             throws MimeException, IOException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endBodyPart()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endBodyPart()
      */
     public void endBodyPart() throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endHeader()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endHeader()
      */
     public void endHeader() throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#endMessage()
+     * @see org.apache.james.mime4j.stream.ContentHandler#endMessage()
      */
     public void endMessage() throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#epilogue(java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#epilogue(java.io.InputStream)
      */
     public void epilogue(InputStream is) throws MimeException, IOException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#field(Field)
+     * @see org.apache.james.mime4j.stream.ContentHandler#field(Field)
      */
     public void field(RawField field) throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#preamble(java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#preamble(java.io.InputStream)
      */
     public void preamble(InputStream is) throws MimeException, IOException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startBodyPart()
+     * @see org.apache.james.mime4j.stream.ContentHandler#startBodyPart()
      */
     public void startBodyPart() throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startHeader()
+     * @see org.apache.james.mime4j.stream.ContentHandler#startHeader()
      */
     public void startHeader() throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#startMessage()
+     * @see org.apache.james.mime4j.stream.ContentHandler#startMessage()
      */
     public void startMessage() throws MimeException {
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#raw(java.io.InputStream)
+     * @see org.apache.james.mime4j.stream.ContentHandler#raw(java.io.InputStream)
      */
     public void raw(InputStream is) throws MimeException, IOException {
     }

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractContentHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java (from r895589, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java)
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java?p2=james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java&p1=james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java&r1=895589&r2=897163&rev=897163&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java Fri Jan  8 10:51:51 2010
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.parser;
+package org.apache.james.mime4j.stream;
 
 import java.io.IOException;
 

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/stream/AbstractEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message