View Javadoc

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