Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removed "parseAllFields" parameters from the logic. Users that do not…

… want to parse all of them will provide a custom FieldParser (Proposed refactoring for MIME4J-116)

git-svn-id: https://svn.apache.org/repos/asf/james/mime4j/branches/mime4j-116-refactoring@1138767 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit 90a8cc5b5088d226ce4828ec7e27de9080c93b79 1 parent 2c8ac52
Stefano Bagnara authored
View
2  dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java
@@ -298,7 +298,7 @@ public Message parseMessage(final InputStream is) throws IOException, MimeIOExce
FieldParser<? extends ParsedField> fp = fieldParser != null ? fieldParser :
strict ? DefaultFieldParser.getParser() : LenientFieldParser.getParser();
MutableBodyDescriptorFactory bdf = bodyDescFactory != null ? bodyDescFactory :
- new MinimalBodyDescriptorFactory(fp, true);
+ new MinimalBodyDescriptorFactory(fp);
BodyFactory bf = bodyFactory != null ? bodyFactory : new BasicBodyFactory();
MimeStreamParser parser = new MimeStreamParser(cfg, mon, bdf);
// EntityBuilder expect the parser will send ParserFields for the well known fields
View
8 dom/src/main/java/org/apache/james/mime4j/message/MaximalBodyDescriptor.java
@@ -61,16 +61,16 @@ protected MaximalBodyDescriptor() {
}
protected MaximalBodyDescriptor(final BodyDescriptor parent) {
- this(parent, null, true, null);
+ this(parent, null, null);
}
- public MaximalBodyDescriptor(final BodyDescriptor parent, final FieldParser<?> fieldParser, final boolean parseAllFields, final DecodeMonitor monitor) {
- super(parent, fieldParser, parseAllFields, monitor);
+ public MaximalBodyDescriptor(final BodyDescriptor parent, final FieldParser<?> fieldParser, final DecodeMonitor monitor) {
+ super(parent, fieldParser, monitor);
}
@Override
public MutableBodyDescriptor newChild() {
- return new MaximalBodyDescriptor(this, getFieldParser(), getParseAllFields(), getDecodeMonitor());
+ return new MaximalBodyDescriptor(this, getFieldParser(), getDecodeMonitor());
}
@Override
View
8 dom/src/main/java/org/apache/james/mime4j/message/MaximalBodyDescriptorFactory.java
@@ -27,20 +27,18 @@
public class MaximalBodyDescriptorFactory implements MutableBodyDescriptorFactory {
private final FieldParser<?> fieldParser;
- private final boolean parseAllFields;
public MaximalBodyDescriptorFactory() {
- this(null, false);
+ this(null);
}
public MaximalBodyDescriptorFactory(final
- FieldParser<?> fieldParser, final boolean parseAllFields) {
+ FieldParser<?> fieldParser) {
this.fieldParser = fieldParser;
- this.parseAllFields = parseAllFields;
}
public MutableBodyDescriptor newInstance(DecodeMonitor monitor) {
- return new MaximalBodyDescriptor(null, fieldParser, parseAllFields, monitor);
+ return new MaximalBodyDescriptor(null, fieldParser, monitor);
}
}
View
17 dom/src/main/java/org/apache/james/mime4j/message/MinimalBodyDescriptor.java
@@ -74,8 +74,6 @@
private final FieldParser<?> fieldParser;
- private final boolean parseAllFields;
-
/**
* Creates a new root <code>BodyDescriptor</code> instance.
*/
@@ -87,7 +85,7 @@ public MinimalBodyDescriptor() {
* Creates a new root <code>BodyDescriptor</code> instance with the given parent
*/
public MinimalBodyDescriptor(final BodyDescriptor parent) {
- this(parent, null, false, null);
+ this(parent, null, null);
}
/**
@@ -96,7 +94,7 @@ public MinimalBodyDescriptor(final BodyDescriptor parent) {
* @param parent the descriptor of the parent or <code>null</code> if this
* is the root descriptor.
*/
- public MinimalBodyDescriptor(final BodyDescriptor parent, final FieldParser<?> fieldParser, boolean parseAllFields, final DecodeMonitor monitor) {
+ public MinimalBodyDescriptor(final BodyDescriptor parent, final FieldParser<?> fieldParser, final DecodeMonitor monitor) {
if (parent != null && MimeUtil.isSameMimeType("multipart/digest", parent.getMimeType())) {
this.mimeType = EMAIL_MESSAGE_MIME_TYPE;
this.subType = SUB_TYPE_EMAIL;
@@ -107,7 +105,6 @@ public MinimalBodyDescriptor(final BodyDescriptor parent, final FieldParser<?> f
this.mediaType = DEFAULT_MEDIA_TYPE;
}
this.fieldParser = fieldParser != null ? fieldParser : DefaultFieldParser.getParser();
- this.parseAllFields = parseAllFields;
this.monitor = monitor != null ? monitor : DecodeMonitor.SILENT;
}
@@ -119,12 +116,8 @@ protected DecodeMonitor getDecodeMonitor() {
return fieldParser;
}
- protected boolean getParseAllFields() {
- return parseAllFields;
- }
-
public MutableBodyDescriptor newChild() {
- return new MinimalBodyDescriptor(this, getFieldParser(), getParseAllFields(), getDecodeMonitor());
+ return new MinimalBodyDescriptor(this, getFieldParser(), getDecodeMonitor());
}
/**
@@ -141,9 +134,9 @@ public Field addField(RawField field) throws MimeException {
return parseContentLength(field);
} else if (name.equalsIgnoreCase(FieldName.CONTENT_TYPE) && contentTypeField == null) {
return parseContentType(field);
- } else if (getParseAllFields()) {
+ } else {
return getFieldParser().parse(field, monitor);
- } else return null;
+ }
}
private ParsedField parseContentTransferEncoding(Field field) throws MimeException {
View
6 dom/src/main/java/org/apache/james/mime4j/message/MinimalBodyDescriptorFactory.java
@@ -27,16 +27,14 @@
public class MinimalBodyDescriptorFactory implements MutableBodyDescriptorFactory {
private final FieldParser<?> fieldParser;
- private final boolean parseAllFields;
public MinimalBodyDescriptorFactory(final
- FieldParser<?> fieldParser, final boolean parseAllFields) {
+ FieldParser<?> fieldParser) {
this.fieldParser = fieldParser;
- this.parseAllFields = parseAllFields;
}
public MutableBodyDescriptor newInstance(DecodeMonitor monitor) {
- return new MinimalBodyDescriptor(null, fieldParser, parseAllFields, monitor);
+ return new MinimalBodyDescriptor(null, fieldParser, monitor);
}
}
View
2  dom/src/test/java/org/apache/james/mime4j/message/MaximalBodyDescriptorTest.java
@@ -41,7 +41,7 @@ protected void setUp() throws Exception {
MimeEntityConfig config = new MimeEntityConfig();
config.setStrictParsing(true);
parser = new MimeTokenStream(config,
- new MaximalBodyDescriptorFactory(null, false));
+ new MaximalBodyDescriptorFactory(null));
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.