Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 44931 invoked from network); 29 Apr 2005 16:55:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Apr 2005 16:55:48 -0000 Received: (qmail 65059 invoked by uid 500); 29 Apr 2005 16:56:30 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 64333 invoked by uid 500); 29 Apr 2005 16:56:27 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 64026 invoked by uid 99); 29 Apr 2005 16:56:25 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Fri, 29 Apr 2005 09:56:25 -0700 Received: (qmail 44110 invoked by uid 65534); 29 Apr 2005 16:55:04 -0000 Message-ID: <20050429165504.44109.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r165317 - /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/SourceUtil.java Date: Fri, 29 Apr 2005 16:55:03 -0000 To: cvs@cocoon.apache.org From: vgritsenko@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: vgritsenko Date: Fri Apr 29 09:55:02 2005 New Revision: 165317 URL: http://svn.apache.org/viewcvs?rev=3D165317&view=3Drev Log: unwrap evil SAXExceptions Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sour= ce/SourceUtil.java Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/component= s/source/SourceUtil.java URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/or= g/apache/cocoon/components/source/SourceUtil.java?rev=3D165317&r1=3D165316&= r2=3D165317&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sour= ce/SourceUtil.java (original) +++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/sour= ce/SourceUtil.java Fri Apr 29 09:55:02 2005 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,7 @@ * * @author Carsten Ziegeler * @author Stephan Michels - * @version CVS $Id$ + * @version $Id$ */ public final class SourceUtil { =20 @@ -85,6 +85,37 @@ } =20 /** + * Generates SAX events from the XMLizable and handle SAXException. + * + * @param source the data + */ + static public void toSAX(XMLizable source, + ContentHandler handler) + throws SAXException, IOException, ProcessingException { + try { + source.toSAX(handler); + } catch (SAXException e) { + // Unwrap ProcessingException, IOException, and extreme cases = of SAXExceptions. + // See also handleSAXException + final Exception cause =3D e.getException(); + if (cause !=3D null) { + if (cause instanceof ProcessingException) { + throw (ProcessingException) cause; + } + if (cause instanceof IOException) { + throw (IOException) cause; + } + if (cause instanceof SAXException) { + throw (SAXException) cause; + } + } + + // Throw original SAX exception + throw e; + } + } + + /** * Generates SAX events from the given source. * *

NOTE: If the implementation can produce lexical events, @@ -138,25 +169,7 @@ ContentHandler handler) throws SAXException, IOException, ProcessingException { if (source instanceof XMLizable) { - try { - ((XMLizable) source).toSAX(handler); - } catch (SAXException e) { - // Unwrap ProcessingException, IOException, and extreme ca= ses of SAXExceptions. - // See also handleSAXException - final Exception cause =3D e.getException(); - if (cause !=3D null) { - if (cause instanceof ProcessingException) { - throw (ProcessingException) cause; - } - if (cause instanceof IOException) { - throw (IOException) cause; - } - if (cause instanceof SAXException) { - throw (SAXException) cause; - } - } - throw e; - } + toSAX((XMLizable) source, handler); } else { String mimeType =3D source.getMimeType(); if (null =3D=3D mimeType) { @@ -196,7 +209,7 @@ ContentHandler handler) throws SAXException, IOException, ProcessingException { if (source instanceof XMLizable) { - ((XMLizable) source).toSAX(handler); + toSAX((XMLizable) source, handler); } else { String mimeType =3D source.getMimeType(); if (null =3D=3D mimeType) { @@ -236,7 +249,7 @@ ContentHandler handler) throws SAXException, IOException, ProcessingException { if (source instanceof XMLizable) { - ((XMLizable) source).toSAX(handler); + toSAX((XMLizable) source, handler); } else { SAXParser parser =3D null; try { @@ -267,7 +280,7 @@ ContentHandler handler) throws SAXException, IOException, ProcessingException { if (source instanceof XMLizable) { - ((XMLizable) source).toSAX(handler); + toSAX((XMLizable) source, handler); } else { SAXParser parser =3D null; try {