james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1221887 - in /james/mime4j/trunk: core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java src/site/apt/usage.apt
Date Wed, 21 Dec 2011 21:12:25 GMT
Author: olegk
Date: Wed Dec 21 21:12:24 2011
New Revision: 1221887

URL: http://svn.apache.org/viewvc?rev=1221887&view=rev
Log:
Updated usage page and MimeStreamParser javadocs

Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
    james/mime4j/trunk/src/site/apt/usage.apt

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=1221887&r1=1221886&r2=1221887&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
(original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/parser/MimeStreamParser.java
Wed Dec 21 21:12:24 2011
@@ -41,7 +41,7 @@ import org.apache.james.mime4j.stream.Re
  * Typical usage:<br/>
  * <pre>
  *      ContentHandler handler = new MyHandler();
- *      MimeEntityConfig config = new MimeEntityConfig();
+ *      MimeConfig config = new MimeConfig();
  *      MimeStreamParser parser = new MimeStreamParser(config);
  *      parser.setContentHandler(handler);
  *      InputStream instream = new FileInputStream("mime.msg");

Modified: james/mime4j/trunk/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/site/apt/usage.apt?rev=1221887&r1=1221886&r2=1221887&view=diff
==============================================================================
--- james/mime4j/trunk/src/site/apt/usage.apt (original)
+++ james/mime4j/trunk/src/site/apt/usage.apt Wed Dec 21 21:12:24 2011
@@ -47,21 +47,21 @@
 
 --------------------------------------------------------------------
   MimeTokenStream stream = new MimeTokenStream();
-  stream.parse(new BufferedInputStream(new FileInputStream("mime.msg")));
-  for (int state = stream.getState();
-       state != MimeTokenStream.T_END_OF_STREAM;
+  stream.parse(new FileInputStream("mime.msg"));
+  for (EntityState state = stream.getState();
+       state != EntityState.T_END_OF_STREAM;
        state = stream.next()) {
     switch (state) {
-      case MimeTokenStream.T_BODY:
+      case T_BODY:
         System.out.println("Body detected, contents = "
           + stream.getInputStream() + ", header data = "
           + stream.getBodyDescriptor());
         break;
-      case MimeTokenStream.T_FIELD:
+      case T_FIELD:
         System.out.println("Header field detected: "
           + stream.getField());
         break;
-      case MimeTokenStream.T_START_MULTIPART:
+      case T_START_MULTIPART:
         System.out.println("Multipart message detexted,"
           + " header data = "
           + stream.getBodyDescriptor());
@@ -126,8 +126,9 @@
   implement an event handler:
 
 --------------------------------------------------------------------  
-  public class MyContentHandler extends org.apache.james.mime4j.parser.ContentHandler {
-      public body(BodyDescriptor bd, InputStream is)
+  public class MyContentHandler extends AbstractContentHandler {
+      
+      public void body(BodyDescriptor bd, InputStream is)
               throws MimeException, IOException {
           System.out.println("Body detected, contents = "
               + is + ", header data = " + bd);
@@ -152,7 +153,7 @@
   ContentHandler handler = new MyContentHandler();
   MimeStreamParser parser = new MimeStreamParser();
   parser.setContentHandler(handler);
-  parser.parse(new BufferedInputStream(new FileInputStream("mime.msg")));
+  parser.parse(new FileInputStream("mime.msg"));
 --------------------------------------------------------------------  
 
 {Sample Event Stream}



Mime
View raw message