A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / jdom / SiblingEnumeration.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core.jdom;
12
13 import java.util.Enumeration;
14
15 import net.sourceforge.phpdt.core.jdom.IDOMNode;
16
17 /**
18  * SiblingEnumeration provides an enumeration on a linked list of sibling DOM
19  * nodes.
20  * 
21  * @see java.util.Enumeration
22  */
23
24 /* package */class SiblingEnumeration implements Enumeration {
25
26         /**
27          * The current location in the linked list of DOM nodes.
28          */
29         protected IDOMNode fCurrentElement;
30
31         /**
32          * Creates an enumeration of silbings starting at the given node. If the
33          * given node is <code>null</code> the enumeration is empty.
34          */
35         SiblingEnumeration(IDOMNode child) {
36                 fCurrentElement = child;
37         }
38
39         /**
40          * @see java.util.Enumeration#hasMoreElements()
41          */
42         public boolean hasMoreElements() {
43                 return fCurrentElement != null;
44         }
45
46         /**
47          * @see java.util.Enumeration#nextElement()
48          */
49         public Object nextElement() {
50                 IDOMNode curr = fCurrentElement;
51                 if (curr != null) {
52                         fCurrentElement = fCurrentElement.getNextNode();
53                 }
54                 return curr;
55         }
56 }