Interface Header
- All Known Implementing Classes:
AbstractHeader, HeaderImpl
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a field to the end of the list of fields.Gets aFieldgiven a field name.<F extends Field>
FGets aFieldgiven a field name and of the given type.Gets the fields of this header.Gets allFields having the specified field name.Gets allFields having the specified field name and of the given type.Gets the fields of this header.iterator()Returns an iterator over the list of fields of this header.intremoveFields(String name) Removes allFields having the specified field name.voidSets or replaces a field.Methods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
addField
Adds a field to the end of the list of fields.- Parameters:
field- the field to add.
-
getFields
-
getFieldsAsMap
-
getField
-
getField
Gets aFieldgiven a field name and of the given type. 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).clazz- the field class.- Returns:
- the field or
nullif none found.
-
getFields
-
getFields
-
iterator
-
removeFields
Removes allFields having the specified field name.- Parameters:
name- the field name (e.g. From, Subject).- Returns:
- number of fields removed.
-
setField
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 thisHeaderdoes 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 asaddField(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.
-