org.apache.james.mime4j.message
Class Header

java.lang.Object
  extended by org.apache.james.mime4j.message.Header

public class Header
extends java.lang.Object

The header of an entity (see RFC 2045).

Version:
$Id: Header.java,v 1.3 2004/10/04 15:36:44 ntherning Exp $

Constructor Summary
Header()
          Creates a new empty Header.
Header(java.io.InputStream is)
          Creates a new Header from the specified stream.
 
Method Summary
 void addField(Field field)
          Adds a field to the end of the list of fields.
 Field getField(java.lang.String name)
          Gets a Field given a field name.
 java.util.List getFields()
          Gets the fields of this header.
 java.util.List getFields(java.lang.String name)
          Gets all Fields having the specified field name.
 java.lang.String toString()
          Return Header Object as String representation.
 void writeTo(java.io.OutputStream out, int mode)
          Write the Header to the given OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Header

public Header()
Creates a new empty Header.


Header

public Header(java.io.InputStream is)
       throws java.io.IOException
Creates a new Header from the specified stream.

Parameters:
is - the stream to read the header from.
Throws:
java.io.IOException
Method Detail

addField

public void addField(Field field)
Adds a field to the end of the list of fields.

Parameters:
field - the field to add.

getFields

public java.util.List getFields()
Gets the fields of this header. The returned list will not be modifiable.

Returns:
the list of Field objects.

getField

public Field getField(java.lang.String name)
Gets a Field given a field name. If there are multiple such fields defined in this header the first one will be returned.

Parameters:
name - the field name (e.g. From, Subject).
Returns:
the field or null if none found.

getFields

public java.util.List getFields(java.lang.String name)
Gets all Fields having the specified field name.

Parameters:
name - the field name (e.g. From, Subject).
Returns:
the list of fields.

toString

public java.lang.String toString()
Return Header Object as String representation. Each headerline is seperated by "\r\n"

Overrides:
toString in class java.lang.Object
Returns:
headers

writeTo

public void writeTo(java.io.OutputStream out,
                    int mode)
             throws java.io.IOException,
                    MimeException
Write the Header to the given OutputStream.

Parameters:
out - the OutputStream to write to
mode - compatibility mode
Throws:
java.io.IOException - if case of an I/O error
MimeException - if case of a MIME protocol violation


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.