Fields Summary |
---|
public static final String | SENDER |
public static final String | FROM |
public static final String | TO |
public static final String | CC |
public static final String | BCC |
public static final String | REPLY_TO |
public static final String | RESENT_SENDER |
public static final String | RESENT_FROM |
public static final String | RESENT_TO |
public static final String | RESENT_CC |
public static final String | RESENT_BCC |
public static final String | DATE |
public static final String | RESENT_DATE |
public static final String | SUBJECT |
public static final String | CONTENT_TYPE |
public static final String | CONTENT_TRANSFER_ENCODING |
private static final String | FIELD_NAME_PATTERN |
private static final Pattern | fieldNamePattern |
private static final DefaultFieldParser | parser |
private final String | name |
private final String | body |
private final String | raw |
Methods Summary |
---|
public java.lang.String | getBody()Gets the unfolded, unparsed and possibly encoded (see RFC 2047) field
body string.
return body;
|
public java.lang.String | getName()Gets the name of the field (Subject ,
From , etc).
return name;
|
public static DefaultFieldParser | getParser()Gets the default parser used to parse fields.
return parser;
|
public java.lang.String | getRaw()Gets the original raw field string.
return raw;
|
public boolean | isContentType()Determines if this is a Content-Type field.
return CONTENT_TYPE.equalsIgnoreCase(name);
|
public boolean | isFrom()Determines if this is a From field.
return FROM.equalsIgnoreCase(name);
|
public boolean | isSubject()Determines if this is a Subject field.
return SUBJECT.equalsIgnoreCase(name);
|
public boolean | isTo()Determines if this is a To field.
return TO.equalsIgnoreCase(name);
|
public static org.apache.james.mime4j.field.Field | parse(java.lang.String raw)Parses the given string and returns an instance of the
Field class. The type of the class returned depends on
the field name:
Field name | Class returned |
Content-Type | org.apache.james.mime4j.field.ContentTypeField |
other | org.apache.james.mime4j.field.UnstructuredField |
/*
* Unfold the field.
*/
final String unfolded = raw.replaceAll("\r|\n", "");
/*
* Split into name and value.
*/
final Matcher fieldMatcher = fieldNamePattern.matcher(unfolded);
if (!fieldMatcher.find()) {
throw new IllegalArgumentException("Invalid field in string");
}
final String name = fieldMatcher.group(1);
String body = unfolded.substring(fieldMatcher.end());
if (body.length() > 0 && body.charAt(0) == ' ") {
body = body.substring(1);
}
return parser.parse(name, body, raw);
|
public java.lang.String | toString()
return raw;
|