org.apache.james.mime4j.dom
Interface Header

All Superinterfaces:
java.lang.Iterable<Field>
All Known Implementing Classes:
AbstractHeader, HeaderImpl

public interface Header
extends java.lang.Iterable<Field>

A header of an MIME entity (as defined in RFC 2045).


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<Field> getFields()
          Gets the fields of this header.
 java.util.List<Field> getFields(java.lang.String name)
          Gets all Fields having the specified field name.
 java.util.Iterator<Field> iterator()
          Returns an iterator over the list of fields of this header.
 int removeFields(java.lang.String name)
          Removes all Fields having the specified field name.
 void setField(Field field)
          Sets or replaces a field.
 

Method Detail

addField

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

Parameters:
field - the field to add.

getFields

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

Returns:
the list of Field objects.

getField

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

java.util.List<Field> 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.

iterator

java.util.Iterator<Field> iterator()
Returns an iterator over the list of fields of this header.

Specified by:
iterator in interface java.lang.Iterable<Field>
Returns:
an iterator.

removeFields

int removeFields(java.lang.String name)
Removes all Fields having the specified field name.

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

setField

void setField(Field field)
Sets or replaces a field. This method is useful for header fields such as Subject or Message-ID that should not occur more than once in a message. If this Header does not already contain a header field of the same name as the given field then it is added to the end of the list of fields (same behavior as addField(Field)). Otherwise the first occurrence of a field with the same name is replaced by the given field and all further occurrences are removed.

Parameters:
field - the field to set.


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