public interface Header extends Iterable<Field>
Modifier and Type | Method and Description |
---|---|
void |
addField(Field field)
Adds a field to the end of the list of fields.
|
Field |
getField(String name)
Gets a
Field given a field name. |
<F extends Field> |
getField(String name,
Class<F> clazz)
Gets a
Field given a field name and of the given type. |
List<Field> |
getFields()
Gets the fields of this header.
|
List<Field> |
getFields(String name)
Gets all
Field s having the specified field name. |
<F extends Field> |
getFields(String name,
Class<F> clazz)
Gets all
Field s having the specified field name
and of the given type. |
Iterator<Field> |
iterator()
Returns an iterator over the list of fields of this header.
|
int |
removeFields(String name)
Removes all
Field s having the specified field name. |
void |
setField(Field field)
Sets or replaces a field.
|
forEach, spliterator
void addField(Field field)
field
- the field to add.List<Field> getFields()
Field
objects.Field getField(String name)
Field
given a field name. If there are multiple
such fields defined in this header the first one will be returned.name
- the field name (e.g. From, Subject).null
if none found.<F extends Field> F getField(String name, Class<F> clazz)
Field
given a field name and of the given type.
If there are multiple such fields defined in this header the first
one will be returned.name
- the field name (e.g. From, Subject).clazz
- the field class.null
if none found.List<Field> getFields(String name)
Field
s having the specified field name.name
- the field name (e.g. From, Subject).<F extends Field> List<F> getFields(String name, Class<F> clazz)
Field
s having the specified field name
and of the given type.name
- the field name (e.g. From, Subject).clazz
- the field class.int removeFields(String name)
Field
s having the specified field name.name
- the field name (e.g. From, Subject).void setField(Field field)
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.field
- the field to set.Copyright © 2004–2023 The Apache Software Foundation. All rights reserved.