james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r937688 - in /james/mime4j/trunk: core/src/main/java/org/apache/james/mime4j/parser/ core/src/main/java/org/apache/james/mime4j/stream/ dom/src/test/java/org/apache/james/mime4j/dom/
Date Sat, 24 Apr 2010 20:02:35 GMT
Author: bago
Date: Sat Apr 24 20:02:34 2010
New Revision: 937688

URL: http://svn.apache.org/viewvc?rev=937688&view=rev
Log:
Changed MimeEntityConfig property "defaultContentType" to "headlessParsing", so it better
self-describe the impact on parsing, as it is not only a default, but a directive for parsing
behaviour. (MIME4J-178 and MIME4J-128)

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java?rev=937688&r1=937687&r2=937688&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
Sat Apr 24 20:02:34 2010
@@ -113,12 +113,11 @@ public class MimeStreamParser {
      * @throws IOException on I/O errors.
      */
     public void parse(InputStream inputStream) throws MimeException, IOException {
-        boolean headless = mimeEntityConfig.getDefaultContentType() != null;
-        if (headless) {
-            mimeTokenStream.parseHeadless(inputStream, mimeEntityConfig.getDefaultContentType());
+        if (mimeEntityConfig.getHeadlessParsing() != null) {
+            mimeTokenStream.parseHeadless(inputStream, mimeEntityConfig.getHeadlessParsing());
             handler.startMessage();
             handler.startHeader();
-            handler.field(new RawField("Content-Type", mimeEntityConfig.getDefaultContentType()));
+            handler.field(new RawField("Content-Type", mimeEntityConfig.getHeadlessParsing()));
             handler.endHeader();
         } else {
             mimeTokenStream.parse(inputStream);

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java?rev=937688&r1=937687&r2=937688&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/stream/MimeEntityConfig.java
Sat Apr 24 20:02:34 2010
@@ -32,18 +32,18 @@ public final class MimeEntityConfig impl
     private int maxHeaderLen;
     private long maxContentLen;
     private boolean countLineNumbers;
-    private String defaultContentType;
+    private String headlessParsing;
     private boolean malformedHeaderStartsBody;
     
 	public MimeEntityConfig() {
         this.strictParsing = false;
+        this.countLineNumbers = false;
+        this.malformedHeaderStartsBody = false;
         this.maxLineLen = 1000;
         this.maxHeaderCount = 1000;
         this.maxHeaderLen = 10000;
         this.maxContentLen = -1;
-        this.countLineNumbers = false;
-        this.defaultContentType = null;
-        this.malformedHeaderStartsBody = false;
+        this.headlessParsing = null;
     }
     
     /**
@@ -225,8 +225,8 @@ public final class MimeEntityConfig impl
      * null otherwise
      * @see org.apache.james.mime4j.parser.MimeStreamParser#parse(java.io.InputStream)
      */
-    public String getDefaultContentType() {
-        return defaultContentType;
+    public String getHeadlessParsing() {
+        return headlessParsing;
     }
 
     /**
@@ -235,13 +235,13 @@ public final class MimeEntityConfig impl
      * <p>
      * Default value: <code>null</code>
      * 
-     * @param defaultContentType
+     * @param contentType
      *            value of the default content type when parsing headless,
      *            null otherwise
      * @see org.apache.james.mime4j.parser.MimeStreamParser#parse(java.io.InputStream)
      */
-    public void setDefaultContentType(String defaultContentType) {
-        this.defaultContentType = defaultContentType;
+    public void setHeadlessParsing(String contentType) {
+        this.headlessParsing = contentType;
     }
 
     @Override

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java?rev=937688&r1=937687&r2=937688&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
Sat Apr 24 20:02:34 2010
@@ -88,7 +88,7 @@ public class MessageHeadlessParserTest e
 				+ "all kind of stuff\r\n" + "--foo--\r\n";
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
-		mimeEntityConfig.setDefaultContentType(contentType);
+		mimeEntityConfig.setHeadlessParsing(contentType);
 		MessageImpl message = new MessageImpl(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("multipart/form-data", message.getMimeType());



Mime
View raw message