Let's talk about the DOM.
The current solution is the "message", "field", "field.address" and "field.datetime" are the packages part of the DOM.
Most stuff in message is abstract, most class in field are interfaces, address and datetime are abstract.
Problems to be fixed:
1) ParsedField interface has "isValid" and "getParseException": from the DOM perspective a field should always be valid, shouldn't it? Shouldn't we throw exception during parsing instead of building the dom node with "isValid"/"getParseException" methods? Can you provide an use case where an exception/monitor during parsing is not enough and we need to carry the "invalidity" to the DOM?
2) Dependency on "MimeException": once we fixed #1 then we shouldn't have anymore the need to depend on MimeException but maybe we'll need a new exception for DOM related operations, DOM should not have any other dependency in mime4j, so we should probably introduce a DOMException (or something similar)
- Introduce a basic interface for the "Node" and make the whole DOM a traversable tree: this will give a lot of future options, like using XPath expressions to select mime nodes (needs more thinking but could be very interesting: "//image[@type=png]" would select all parts with a content type (image/png) at any depth level...
- Add manipulation methods: once we get an instance of the "root" Message we should be able to add header, content, subparts and anything else only accessing the root object and the DOM interfaces (the same as for an xml Document.. once you have it you don't need a DocumentBuilder anymore).