home *** CD-ROM | disk | FTP | other *** search
/ Online Today 2000 January / Onto0100.iso / pc / JAVA / MSJAVX86.EXE / xmldso.cab / com / ms / xml / om / ElementEnumeration.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-05  |  1.2 KB  |  69 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 Object nextElement() {
  14.       if (this.next != null) {
  15.          Element var1 = this.next;
  16.          this.next = null;
  17.          return var1;
  18.       } else {
  19.          return this.getNext();
  20.       }
  21.    }
  22.  
  23.    public void reset() {
  24.       this.children = this.root != null ? this.root.getElements() : null;
  25.       this.next = null;
  26.    }
  27.  
  28.    public ElementEnumeration(Element var1) {
  29.       this.root = var1;
  30.       this.tag = null;
  31.       this.next = null;
  32.       this.children = var1 != null ? var1.getElements() : null;
  33.       this.type = -1;
  34.    }
  35.  
  36.    public ElementEnumeration(Element var1, Name var2, int var3) {
  37.       this.root = var1;
  38.       this.tag = var2;
  39.       this.next = null;
  40.       this.children = var1 != null ? var1.getElements() : null;
  41.       this.type = var3;
  42.    }
  43.  
  44.    Element getNext() {
  45.       if (this.children != null) {
  46.          while(this.children.hasMoreElements()) {
  47.             Element var1 = (Element)this.children.nextElement();
  48.             if (this.tag == null && this.type == -1) {
  49.                return var1;
  50.             }
  51.  
  52.             if ((this.type == -1 || var1.getType() == this.type) && (this.tag == null || var1.getTagName() == this.tag)) {
  53.                return var1;
  54.             }
  55.          }
  56.       }
  57.  
  58.       return null;
  59.    }
  60.  
  61.    public boolean hasMoreElements() {
  62.       if (this.next == null) {
  63.          this.next = this.getNext();
  64.       }
  65.  
  66.       return this.next != null;
  67.    }
  68. }
  69.