1 /*
2 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
3 *
4 * This software is open source.
5 * See the bottom of this file for the licence.
6 *
7 * $Id: PruningDispatchHandler.java,v 1.1 2004/08/02 18:44:07 maartenc Exp $
8 */
9
10 package org.dom4j.io;
11
12 import org.dom4j.ElementPath;
13
14 /***
15 * This extension on the {@link DispatchHandler} prunes the current {@link org.dom4j.Element}
16 * when there are no {@link ElementHandler) objects active the element.
17 *
18 * @author Wonne keysers (Realsoftware)
19 */
20
21 class PruningDispatchHandler extends DispatchHandler {
22
23 public void onEnd(ElementPath elementPath) {
24 super.onEnd(elementPath);
25
26 if (getActiveHandlerCount() == 0) {
27 elementPath.getCurrent().detach();
28 }
29 }
30
31 }
32
33
34
35
36 /*
37 * Redistribution and use of this software and associated documentation
38 * ("Software"), with or without modification, are permitted provided
39 * that the following conditions are met:
40 *
41 * 1. Redistributions of source code must retain copyright
42 * statements and notices. Redistributions must also contain a
43 * copy of this document.
44 *
45 * 2. Redistributions in binary form must reproduce the
46 * above copyright notice, this list of conditions and the
47 * following disclaimer in the documentation and/or other
48 * materials provided with the distribution.
49 *
50 * 3. The name "DOM4J" must not be used to endorse or promote
51 * products derived from this Software without prior written
52 * permission of MetaStuff, Ltd. For written permission,
53 * please contact dom4j-info@metastuff.com.
54 *
55 * 4. Products derived from this Software may not be called "DOM4J"
56 * nor may "DOM4J" appear in their names without prior written
57 * permission of MetaStuff, Ltd. DOM4J is a registered
58 * trademark of MetaStuff, Ltd.
59 *
60 * 5. Due credit should be given to the DOM4J Project -
61 * http://www.dom4j.org
62 *
63 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
64 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
65 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
66 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
67 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
68 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
69 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
70 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
71 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
72 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
73 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
74 * OF THE POSSIBILITY OF SUCH DAMAGE.
75 *
76 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
77 *
78 * $Id: PruningDispatchHandler.java,v 1.1 2004/08/02 18:44:07 maartenc Exp $
79 */