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: ElementNameIterator.java,v 1.9 2004/06/25 08:03:41 maartenc Exp $
8 */
9
10 package org.dom4j.tree;
11
12 import java.util.Iterator;
13
14 import org.dom4j.Element;
15
16
17 /*** <p><code>ElementNameIterator</code> is a filtering {@link Iterator} which
18 * filters out objects which do not implement the {@link Element}
19 * interface and are not of the correct element name.</p>
20 *
21 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a>
22 * @version $Revision: 1.9 $
23 * @deprecated THIS CLASS WILL BE REMOVED IN dom4j-1.6 !!
24 */
25 public class ElementNameIterator extends FilterIterator {
26
27 private String name;
28
29 public ElementNameIterator(Iterator proxy, String name) {
30 super(proxy);
31 this.name = name;
32 }
33
34 /*** @return true if the given element implements the {@link Element}
35 * interface
36 */
37 protected boolean matches(Object object) {
38 if (object instanceof Element) {
39 Element element = (Element) object;
40 return name.equals( element.getName() );
41 }
42 return false;
43 }
44 }
45
46
47
48
49 /*
50 * Redistribution and use of this software and associated documentation
51 * ("Software"), with or without modification, are permitted provided
52 * that the following conditions are met:
53 *
54 * 1. Redistributions of source code must retain copyright
55 * statements and notices. Redistributions must also contain a
56 * copy of this document.
57 *
58 * 2. Redistributions in binary form must reproduce the
59 * above copyright notice, this list of conditions and the
60 * following disclaimer in the documentation and/or other
61 * materials provided with the distribution.
62 *
63 * 3. The name "DOM4J" must not be used to endorse or promote
64 * products derived from this Software without prior written
65 * permission of MetaStuff, Ltd. For written permission,
66 * please contact dom4j-info@metastuff.com.
67 *
68 * 4. Products derived from this Software may not be called "DOM4J"
69 * nor may "DOM4J" appear in their names without prior written
70 * permission of MetaStuff, Ltd. DOM4J is a registered
71 * trademark of MetaStuff, Ltd.
72 *
73 * 5. Due credit should be given to the DOM4J Project -
74 * http://www.dom4j.org
75 *
76 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
77 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
78 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
79 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
80 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
81 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
82 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
83 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
84 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
85 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
86 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
87 * OF THE POSSIBILITY OF SUCH DAMAGE.
88 *
89 * Copyright 2001-2004 (C) MetaStuff, Ltd. All Rights Reserved.
90 *
91 * $Id: ElementNameIterator.java,v 1.9 2004/06/25 08:03:41 maartenc Exp $
92 */