home *** CD-ROM | disk | FTP | other *** search
- package com.ms.xml.om;
-
- import com.ms.xml.util.Name;
-
- public class ElementCollection {
- Element root;
- ElementEnumeration items;
- int length;
- Element current;
- int currentindex;
-
- public Element getChild(int var1) {
- if (this.currentindex == var1) {
- return this.current;
- } else {
- if (this.currentindex > var1) {
- this.currentindex = 0;
- this.items.reset();
- }
-
- if (this.currentindex < var1) {
- while(this.currentindex < var1 && this.items.hasMoreElements()) {
- this.current = (Element)this.items.nextElement();
- ++this.currentindex;
- }
- }
-
- return this.currentindex != var1 ? null : this.current;
- }
- }
-
- public ElementCollection(Element var1) {
- this.root = var1;
- this.items = new ElementEnumeration(var1, (Name)null, 0);
- this.currentindex = 0;
- this.current = (Element)this.items.nextElement();
- this.length = -1;
- }
-
- public ElementCollection(Element var1, Name var2, int var3) {
- this.root = var1;
- this.items = new ElementEnumeration(var1, var2, var3);
- this.length = -1;
- this.currentindex = 0;
- this.current = (Element)this.items.nextElement();
- }
-
- public Object item(String var1) {
- try {
- int var4 = Integer.parseInt(var1);
- return this.getChild(var4);
- } catch (Exception var3) {
- ElementCollection var2 = new ElementCollection(this.root, Name.create(var1), 0);
- return var2.getLength() == 1 ? var2.getChild(0) : var2;
- }
- }
-
- public int getLength() {
- if (this.length == -1) {
- this.items.reset();
-
- for(this.length = 0; this.items.hasMoreElements(); ++this.length) {
- this.items.nextElement();
- }
-
- this.items.reset();
- this.currentindex = 0;
- this.current = (Element)this.items.nextElement();
- }
-
- return this.length;
- }
-
- public Element item(String var1, int var2) {
- ElementCollection var3 = new ElementCollection(this.root, Name.create(var1), 0);
- return var3.getChild(var2);
- }
- }
-