Return-Path: Delivered-To: apmail-jackrabbit-users-archive@locus.apache.org Received: (qmail 67850 invoked from network); 29 Aug 2007 18:43:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Aug 2007 18:43:59 -0000 Received: (qmail 30491 invoked by uid 500); 29 Aug 2007 18:43:54 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 30470 invoked by uid 500); 29 Aug 2007 18:43:54 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 30460 invoked by uid 99); 29 Aug 2007 18:43:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2007 11:43:54 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jukka.zitting@gmail.com designates 64.233.162.228 as permitted sender) Received: from [64.233.162.228] (HELO nz-out-0506.google.com) (64.233.162.228) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Aug 2007 18:43:50 +0000 Received: by nz-out-0506.google.com with SMTP id s18so233201nze for ; Wed, 29 Aug 2007 11:43:29 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=FJdlsAIJrnlLbFx9G4opXWhhocedMzWOSSIH0Ajn2eulWzzJm8Ilp6C+4B+G+GUMdpPPGC0+w4cveKKrLnNe2HsKk4JVc6bzkpi1EHTHAnAI4ecz5o98z5+ta7vrhVg9FBgUX2nUDdiNDx/+B+u6enHOKCyrquH26eOVCJrfQlQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Kq/5NrVMUg9T7evzXkCTkp5vgS4XziCp87lIbUH2O8wSgEF17x2qzjyAViGwIO1FOHtys3rHSO3tOmjTF9CktvusGgj15TUMnvOpFRUU4Erq7Vz/yirOaiyglUpD7xf2Yj6JThlZeWpdHHJTE2WIYQiMF8L/Ei31/77cmX1kCnk= Received: by 10.141.107.13 with SMTP id j13mr493183rvm.1188413008860; Wed, 29 Aug 2007 11:43:28 -0700 (PDT) Received: by 10.141.33.14 with HTTP; Wed, 29 Aug 2007 11:43:28 -0700 (PDT) Message-ID: <510143ac0708291143h5d5dc813g1e09f4b544be3dee@mail.gmail.com> Date: Wed, 29 Aug 2007 21:43:28 +0300 From: "Jukka Zitting" To: users@jackrabbit.apache.org Subject: Re: Session.importXml - how to monitor progress In-Reply-To: <2123A704743EB34295B4AA1DB09475680227C98B@jaxmsx02.nemours.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <510143ac0708291105q33656138scf768ee5ac8166d5@mail.gmail.com> <2123A704743EB34295B4AA1DB09475680227C98B@jaxmsx02.nemours.org> X-Virus-Checked: Checked by ClamAV on apache.org Hi, On 8/29/07, Amir Mistric wrote: > Is there an example of this "decoration" anywhere? > I assume SAX does not come with ability to just add decorator handlers does it? Using the helper base class given below, you could do something like this: ContentHandler handler = new ContentHandlerDecorator( session.getImportContentHandler(...)) { private int elements = 0; void endElement(String uri, String local, String name) throws SAXException { super.endElement(uri, local, name); if (++elements % 100 == 0) { System.out.println(elements + " XML elements processed."); } } } BR, Jukka Zitting ---- import org.xml.sax.Attributes; import org.xml.sax.ContentHandler; import org.xml.sax.Locator; import org.xml.sax.SAXException; public class ContentHandlerDecorator implements ContentHandler { private final ContentHandler handler; public ContentHandlerDecorator(ContentHandler handler) { this.handler = handler; } public void characters(char[] ch, int start, int length) throws SAXException { handler.characters(ch, start, length); } public void endDocument() throws SAXException { handler.endDocument(); } public void endElement(String uri, String localName, String name) throws SAXException { handler.endElement(uri, localName, name); } public void endPrefixMapping(String prefix) throws SAXException { handler.endPrefixMapping(prefix); } public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { handler.ignorableWhitespace(ch, start, length); } public void processingInstruction(String target, String data) throws SAXException { handler.processingInstruction(target, data); } public void setDocumentLocator(Locator locator) { handler.setDocumentLocator(locator); } public void skippedEntity(String name) throws SAXException { handler.skippedEntity(name); } public void startDocument() throws SAXException { handler.startDocument(); } public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException { handler.startElement(uri, localName, name, atts); } public void startPrefixMapping(String prefix, String uri) throws SAXException { handler.startPrefixMapping(prefix, uri); } }