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: ElementPath.java,v 1.4 2004/06/25 08:03:33 maartenc Exp $ 8 */ 9 10 package org.dom4j; 11 12 /*** This interface is used by {@link ElementHandler} instances to 13 * retrieve information about the current path hierarchy they 14 * are to process. It's primary use is to retrieve the current 15 * {@link Element} being processed. 16 * 17 * @author <a href="mailto:dwhite@equipecom.com">Dave White</a> 18 * @version $Revision: 1.4 $ 19 */ 20 public interface ElementPath 21 { 22 /*** @return the number of elements in the path */ 23 public int size(); 24 25 /*** @return the element at the specified depth index, 0 = root element*/ 26 public Element getElement(int depth); 27 28 /*** @return the path as a string */ 29 public String getPath(); 30 31 /*** @return the current element */ 32 public Element getCurrent(); 33 34 /*** Adds the <code>ElementHandler</code> to be called when the 35 * specified path is encounted. The path can be either an absolute 36 * path (i.e. prefixed with "/") or a relative path (i.e. assummed 37 * to be a child of the current path as retrieved by <b>getPath</b>. 38 * 39 * @param path is the path to be handled 40 * @param handler is the <code>ElementHandler</code> to be called 41 * by the event based processor. 42 */ 43 public void addHandler(String path, ElementHandler handler); 44 45 /*** Removes the <code>ElementHandler</code> from the event based 46 * processor, for the specified path. The path can be either an 47 * absolute path (i.e. prefixed with "/") or a relative path 48 * (i.e. assummed to be a child of the current path as retrieved 49 * by <b>getPath</b>. 50 * 51 * @param path is the path to remove the <code>ElementHandler</code> for. 52 */ 53 public void removeHandler(String path); 54 } 55 56 57 58 59 /* 60 * Redistribution and use of this software and associated documentation 61 * ("Software"), with or without modification, are permitted provided 62 * that the following conditions are met: 63 * 64 * 1. Redistributions of source code must retain copyright 65 * statements and notices. Redistributions must also contain a 66 * copy of this document. 67 * 68 * 2. Redistributions in binary form must reproduce the 69 * above copyright notice, this list of conditions and the 70 * following disclaimer in the documentation and/or other 71 * materials provided with the distribution. 72 * 73 * 3. The name "DOM4J" must not be used to endorse or promote 74 * products derived from this Software without prior written 75 * permission of MetaStuff, Ltd. For written permission, 76 * please contact dom4j-info@metastuff.com. 77 * 78 * 4. Products derived from this Software may not be called "DOM4J" 79 * nor may "DOM4J" appear in their names without prior written 80 * permission of MetaStuff, Ltd. DOM4J is a registered 81 * trademark of MetaStuff, Ltd. 82 * 83 * 5. Due credit should be given to the DOM4J Project - 84 * http://www.dom4j.org 85 * 86 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 87 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 88 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 89 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 90 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 91 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 92 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 93 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 94 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 95 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 96 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 97 * OF THE POSSIBILITY OF SUCH DAMAGE. 98 * 99 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved. 100 * 101 * $Id: ElementPath.java,v 1.4 2004/06/25 08:03:33 maartenc Exp $ 102 */