KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > xml > dom4j > o3impl > ElementNameIterator


1 /*
2  * Copyright 2001 (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.2 2003/06/10 16:18:36 per_nyfelt Exp $
8  */

9
10 package org.ozoneDB.xml.dom4j.o3impl;
11
12 import org.dom4j.Element;
13
14 import java.util.Iterator JavaDoc;
15
16 /** <p><code>ElementNameIterator</code> is a filtering {@link Iterator} which
17  * filters out objects which do not implement the {@link Element}
18  * interface and are not of the correct element name.</p>
19  *
20  * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan</a>
21  * @version $Revision: 1.2 $
22  */

23 public class ElementNameIterator extends FilterIterator {
24
25     private String JavaDoc name;
26
27     public ElementNameIterator(Iterator JavaDoc proxy, String JavaDoc name) {
28         super(proxy);
29         this.name = name;
30     }
31
32     /** @return true if the given element implements the {@link Element}
33      * interface
34      */

35     protected boolean matches(Object JavaDoc object) {
36         if (object instanceof Element) {
37             Element element = (Element) object;
38             return name.equals(element.getName());
39         }
40         return false;
41     }
42 }
43
44
45 /*
46  * Redistribution and use of this software and associated documentation
47  * ("Software"), with or without modification, are permitted provided
48  * that the following conditions are met:
49  *
50  * 1. Redistributions of source code must retain copyright
51  * statements and notices. Redistributions must also contain a
52  * copy of this document.
53  *
54  * 2. Redistributions in binary form must reproduce the
55  * above copyright notice, this list of conditions and the
56  * following disclaimer in the documentation and/or other
57  * materials provided with the distribution.
58  *
59  * 3. The name "DOM4J" must not be used to endorse or promote
60  * products derived from this Software without prior written
61  * permission of MetaStuff, Ltd. For written permission,
62  * please contact dom4j-info@metastuff.com.
63  *
64  * 4. Products derived from this Software may not be called "DOM4J"
65  * nor may "DOM4J" appear in their names without prior written
66  * permission of MetaStuff, Ltd. DOM4J is a registered
67  * trademark of MetaStuff, Ltd.
68  *
69  * 5. Due credit should be given to the DOM4J Project
70  * (http://dom4j.org/).
71  *
72  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS
73  * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
74  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
75  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
76  * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
77  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
79  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
80  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
81  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
82  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
83  * OF THE POSSIBILITY OF SUCH DAMAGE.
84  *
85  * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved.
86  *
87  * $Id: ElementNameIterator.java,v 1.2 2003/06/10 16:18:36 per_nyfelt Exp $
88  */

89
Popular Tags