From mime4j-dev-return-707-apmail-james-mime4j-dev-archive=james.apache.org@james.apache.org Thu Dec 24 16:11:41 2009 Return-Path: Delivered-To: apmail-james-mime4j-dev-archive@minotaur.apache.org Received: (qmail 52722 invoked from network); 24 Dec 2009 16:11:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Dec 2009 16:11:41 -0000 Received: (qmail 78050 invoked by uid 500); 24 Dec 2009 16:11:41 -0000 Delivered-To: apmail-james-mime4j-dev-archive@james.apache.org Received: (qmail 78015 invoked by uid 500); 24 Dec 2009 16:11:41 -0000 Mailing-List: contact mime4j-dev-help@james.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mime4j-dev@james.apache.org Delivered-To: mailing list mime4j-dev@james.apache.org Received: (qmail 78005 invoked by uid 99); 24 Dec 2009 16:11:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Dec 2009 16:11:41 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of apache@bago.org designates 209.85.217.215 as permitted sender) Received: from [209.85.217.215] (HELO mail-gx0-f215.google.com) (209.85.217.215) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Dec 2009 16:11:31 +0000 Received: by gxk7 with SMTP id 7so17555105gxk.12 for ; Thu, 24 Dec 2009 08:11:10 -0800 (PST) Received: by 10.91.163.11 with SMTP id q11mr1103937ago.67.1261671069430; Thu, 24 Dec 2009 08:11:09 -0800 (PST) Received: from mail-gx0-f215.google.com (mail-gx0-f215.google.com [209.85.217.215]) by mx.google.com with ESMTPS id 9sm3155961ywe.56.2009.12.24.08.11.09 (version=SSLv3 cipher=RC4-MD5); Thu, 24 Dec 2009 08:11:09 -0800 (PST) Received: by gxk7 with SMTP id 7so17555063gxk.12 for ; Thu, 24 Dec 2009 08:11:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.150.76.6 with SMTP id y6mr17941178yba.60.1261671068775; Thu, 24 Dec 2009 08:11:08 -0800 (PST) X-Originating-IP: [78.134.13.238] Date: Thu, 24 Dec 2009 17:11:08 +0100 Message-ID: <9426afb70912240811t358e115cu7e00880dffb6872b@mail.gmail.com> Subject: Introducing a SAX-like ErrorHandler From: Stefano Bagnara To: mime4j-dev Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Hi all, for my current job I need to do some sort of MIME validation. Of course I'm going to use mime4j, but mime4j as-is doesn't do what I need. The fact is that most time mime4j logs what I need to know, but I don't want it to be logged, instead I want it to be "returned" so that I can prepare a report of problems found. In a "perfect world" I would also have the position (row/column, and maybe the "pos") where the problem has been found. In SAX world this is handled passing to the parser an "ErrorHandler" that is a simple "listener" that will receive warning/error/fatalError event with a SAXParseException parameter. The SAXParseException includes a message and a Locator object (that gives access to row/column). Introducing such an "ErrorHandler" would also let us move some of the "strict" behaviours to the error handler. A strict error handler could raise the exception at every warning/error, while the default error handler would simply do a logWarnEnabled+log.warn/logErrorEnabled+log.error . This ErrorHandler could also remove the need of the common logging dependency in many classes. Is there interest in improving mime4j so to support a similar behaviour or it is better that I simply work extending mime4j to support my behaviour and simply propose minor patches for mime4j in order to allow my extensions to be written? Stefano