home *** CD-ROM | disk | FTP | other *** search
- package com.ms.xml.parser;
-
- import com.ms.xml.om.Element;
- import com.ms.xml.om.ElementImpl;
- import com.ms.xml.util.Atom;
- import com.ms.xml.util.Name;
- import com.ms.xml.util.XMLOutputStream;
- import java.io.IOException;
- import java.util.BitSet;
-
- class Sequence extends Node {
- Node left;
- Node right;
-
- Sequence(Node var1, Node var2) {
- this.left = var1;
- this.right = var2;
- }
-
- BitSet firstpos(int var1) {
- if (super.first == null) {
- if (this.left.nullable()) {
- super.first = (BitSet)this.left.firstpos(var1).clone();
- super.first.or(this.right.firstpos(var1));
- } else {
- super.first = this.left.firstpos(var1);
- }
- }
-
- return super.first;
- }
-
- BitSet lastpos(int var1) {
- if (super.last == null) {
- if (this.right.nullable()) {
- super.last = (BitSet)this.left.lastpos(var1).clone();
- super.last.or(this.right.lastpos(var1));
- } else {
- super.last = this.right.lastpos(var1);
- }
- }
-
- return super.last;
- }
-
- Element toSchema(int var1, int var2, Element var3) {
- ++var2;
- if (var1 == 44) {
- var3 = this.left.toSchema(44, var2, var3);
- this.right.toSchema(44, var2, var3);
- } else {
- Element var4 = new ElementImpl(Name.create("GROUP", "XML"), 0);
- var4.setAttribute(Name.create("GROUPTYPE", "XML"), "SEQ");
- if (var1 == 63) {
- var4.setAttribute(Name.create("OCCURS", "XML"), "OPTIONAL");
- } else if (var1 == 42) {
- var4.setAttribute(Name.create("OCCURS", "XML"), "STAR");
- } else if (var1 == 43) {
- var4.setAttribute(Name.create("OCCURS", "XML"), "PLUS");
- }
-
- var4 = this.left.toSchema(44, var2, var4);
- this.right.toSchema(44, var2, var4);
- var3.addChild(var4, (Element)null);
- }
-
- --var2;
- return var3;
- }
-
- void save(XMLOutputStream var1, int var2, int var3, Atom var4) throws IOException {
- ++var3;
- if (var2 == 44) {
- this.left.save(var1, 44, var3, var4);
- var1.write(44);
- this.right.save(var1, 44, var3, var4);
- } else {
- var1.write(40);
- this.left.save(var1, 44, var3, var4);
- var1.write(44);
- this.right.save(var1, 44, var3, var4);
- var1.write(41);
- }
-
- --var3;
- }
-
- Node clone(ContentModel var1) {
- return new Sequence(this.left.clone(var1), this.right.clone(var1));
- }
-
- void calcfollowpos(BitSet[] var1) {
- this.left.calcfollowpos(var1);
- this.right.calcfollowpos(var1);
- int var2 = var1.length;
- BitSet var3 = this.left.lastpos(var2);
- BitSet var4 = this.right.firstpos(var2);
-
- for(int var5 = var1.length - 1; var5 >= 0; --var5) {
- if (var3.get(var5)) {
- var1[var5].or(var4);
- }
- }
-
- }
-
- boolean nullable() {
- return this.left.nullable() && this.right.nullable();
- }
- }
-