001/* 002 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 003 * 004 * This software is open source. 005 * See the bottom of this file for the licence. 006 * 007 * $Id: ElementIterator.java,v 1.2 2001/01/09 20:43:11 jstrachan Exp $ 008 */ 009 010package org.dom4j.tree; 011 012import java.util.Iterator; 013 014import org.dom4j.Element; 015 016/** <p><code>ElementIterator</code> is a filtering {@link Iterator} which 017 * filters out objects which do not implement the {@link Element} 018 * interface.</p> 019 * 020 * @author <a href="mailto:james.strachan@metastuff.com">James Strachan</a> 021 * @version $Revision: 1.2 $ 022 */ 023public class ElementIterator extends FilterIterator { 024 025 public ElementIterator(Iterator proxy) { 026 super(proxy); 027 } 028 029 030 /** @return true if the given element implements the {@link Element} 031 * interface 032 */ 033 protected boolean matches(Object element) { 034 return element instanceof Element; 035 } 036} 037 038 039 040 041/* 042 * Redistribution and use of this software and associated documentation 043 * ("Software"), with or without modification, are permitted provided 044 * that the following conditions are met: 045 * 046 * 1. Redistributions of source code must retain copyright 047 * statements and notices. Redistributions must also contain a 048 * copy of this document. 049 * 050 * 2. Redistributions in binary form must reproduce the 051 * above copyright notice, this list of conditions and the 052 * following disclaimer in the documentation and/or other 053 * materials provided with the distribution. 054 * 055 * 3. The name "DOM4J" must not be used to endorse or promote 056 * products derived from this Software without prior written 057 * permission of MetaStuff, Ltd. For written permission, 058 * please contact dom4j-info@metastuff.com. 059 * 060 * 4. Products derived from this Software may not be called "DOM4J" 061 * nor may "DOM4J" appear in their names without prior written 062 * permission of MetaStuff, Ltd. DOM4J is a registered 063 * trademark of MetaStuff, Ltd. 064 * 065 * 5. Due credit should be given to the DOM4J Project 066 * (http://dom4j.org/). 067 * 068 * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS 069 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 070 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 071 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 072 * METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 073 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 074 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 075 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 076 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 077 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 078 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 079 * OF THE POSSIBILITY OF SUCH DAMAGE. 080 * 081 * Copyright 2001 (C) MetaStuff, Ltd. All Rights Reserved. 082 * 083 * $Id: ElementIterator.java,v 1.2 2001/01/09 20:43:11 jstrachan Exp $ 084 */