home *** CD-ROM | disk | FTP | other *** search
/ Online Today 2000 January / Onto0100.iso / pc / JAVA / MSJAVX86.EXE / xmldso.cab / XML4IE3.cab / com / ms / xml / om / ElementEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-10-10  |  1.2 KB  |  68 lines

  1. package com.ms.xml.om;
  2.  
  3. import com.ms.xml.util.Name;
  4. import java.util.Enumeration;
  5.  
  6. public class ElementEnumeration implements Enumeration {
  7.    Element root;
  8.    Enumeration children;
  9.    Name tag;
  10.    Element next;
  11.    int type;
  12.  
  13.    public ElementEnumeration(Element var1) {
  14.       this.root = var1;
  15.       this.tag = null;
  16.       this.next = null;
  17.       this.children = var1 != null ? var1.getElements() : null;
  18.       this.type = -1;
  19.    }
  20.  
  21.    public ElementEnumeration(Element var1, Name var2, int var3) {
  22.       this.root = var1;
  23.       this.tag = var2;
  24.       this.next = null;
  25.       this.children = var1 != null ? var1.getElements() : null;
  26.       this.type = var3;
  27.    }
  28.  
  29.    public Object nextElement() {
  30.       if (this.next != null) {
  31.          Element var1 = this.next;
  32.          this.next = null;
  33.          return var1;
  34.       } else {
  35.          return this.getNext();
  36.       }
  37.    }
  38.  
  39.    public void reset() {
  40.       this.children = this.root != null ? this.root.getElements() : null;
  41.    }
  42.  
  43.    Element getNext() {
  44.       if (this.children != null) {
  45.          while(this.children.hasMoreElements()) {
  46.             Element var1 = (Element)this.children.nextElement();
  47.             if (this.tag == null && this.type == -1) {
  48.                return var1;
  49.             }
  50.  
  51.             if ((this.type == -1 || var1.getType() == this.type) && (this.tag == null || var1.getTagName() == this.tag)) {
  52.                return var1;
  53.             }
  54.          }
  55.       }
  56.  
  57.       return null;
  58.    }
  59.  
  60.    public boolean hasMoreElements() {
  61.       if (this.next == null) {
  62.          this.next = this.getNext();
  63.       }
  64.  
  65.       return this.next != null;
  66.    }
  67. }
  68.