Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 17 18 package org.apache.james.core; 19 20 import javax.mail.MessagingException ; 21 import javax.mail.internet.InternetHeaders ; 22 import java.io.*; 23 import java.util.Enumeration ; 24 25 import org.apache.james.util.RFC2822Headers; 26 27 32 public class MailHeaders extends InternetHeaders implements Serializable, Cloneable { 33 34 39 public MailHeaders() throws MessagingException { 40 super(); 41 } 42 43 52 public MailHeaders(InputStream in) throws MessagingException { 53 super(in); 54 } 55 56 61 public void writeTo(OutputStream out) { 62 PrintStream pout; 63 if (out instanceof PrintStream) { 64 pout = (PrintStream)out; 65 } else { 66 pout = new PrintStream(out); 67 } 68 for (Enumeration e = super.getAllHeaderLines(); e.hasMoreElements(); ) { 69 pout.print((String ) e.nextElement()); 70 pout.print("\r\n"); 71 } 72 pout.print("\r\n"); 74 } 75 76 81 public byte[] toByteArray() { 82 ByteArrayOutputStream headersBytes = new ByteArrayOutputStream(); 83 writeTo(headersBytes); 84 return headersBytes.toByteArray(); 85 } 86 87 92 public boolean isSet(String name) { 93 String [] value = super.getHeader(name); 94 return (value != null && value.length != 0); 95 } 96 97 103 public boolean isValid() { 104 return (isSet(RFC2822Headers.DATE) && isSet(RFC2822Headers.TO) && isSet(RFC2822Headers.FROM)); 105 } 106 } 107
| Popular Tags
|