Skip to content
Permalink
Browse files
MIME4J-299 Access to the Header map
Preserving the "grouped by name" structure can ease the work of callers.
  • Loading branch information
chibenwa committed May 25, 2021
1 parent 302e49d commit 0079d7e9653944ffe1a17ba881c9a3f3f89a0c84
Showing 2 changed files with 20 additions and 0 deletions.
@@ -21,6 +21,7 @@

import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.james.mime4j.stream.Field;

@@ -44,6 +45,14 @@ public interface Header extends Iterable<Field> {
*/
List<Field> getFields();

/**
* Gets the fields of this header. The returned map will not be
* modifiable.
*
* @return the map of <code>Field</code> objects indexed by names.
*/
Map<String, List<Field>> getFieldsAsMap();

/**
* Gets a <code>Field</code> given a field name. If there are multiple
* such fields defined in this header the first one will be returned.
@@ -86,6 +86,17 @@ public List<Field> getFields() {
return Collections.unmodifiableList(fields);
}

/**
* Gets the fields of this header. The returned map will not be
* modifiable.
*
* @return the map of <code>Field</code> objects indexed by names.
*/
@Override
public Map<String, List<Field>> getFieldsAsMap() {
return Collections.unmodifiableMap(fieldMap);
}

/**
* Gets a <code>Field</code> given a field name. If there are multiple
* such fields defined in this header the first one will be returned.

0 comments on commit 0079d7e

Please sign in to comment.