home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / xml4j.jar / com / ibm / xml / internal / CMBinOp.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-08-30  |  1.3 KB  |  63 lines

  1. package com.ibm.xml.internal;
  2.  
  3. class CMBinOp extends CMNode {
  4.    private CMNode fLeftChild;
  5.    private CMNode fRightChild;
  6.  
  7.    CMBinOp(int var1, CMNode var2, CMNode var3) throws CMException {
  8.       super(var1);
  9.       if (((CMNode)this).type() != 4 && ((CMNode)this).type() != 5) {
  10.          throw new CMException(154);
  11.       } else {
  12.          this.fLeftChild = var2;
  13.          this.fRightChild = var3;
  14.       }
  15.    }
  16.  
  17.    final CMNode getLeft() {
  18.       return this.fLeftChild;
  19.    }
  20.  
  21.    final CMNode getRight() {
  22.       return this.fRightChild;
  23.    }
  24.  
  25.    boolean isNullable() throws CMException {
  26.       if (((CMNode)this).type() == 4) {
  27.          return this.fLeftChild.isNullable() || this.fRightChild.isNullable();
  28.       } else if (((CMNode)this).type() == 5) {
  29.          return this.fLeftChild.isNullable() && this.fRightChild.isNullable();
  30.       } else {
  31.          throw new CMException(154);
  32.       }
  33.    }
  34.  
  35.    protected void calcFirstPos(CMStateSet var1) throws CMException {
  36.       if (((CMNode)this).type() == 4) {
  37.          var1.setTo(this.fLeftChild.firstPos());
  38.          var1.union(this.fRightChild.firstPos());
  39.       } else if (((CMNode)this).type() == 5) {
  40.          var1.setTo(this.fLeftChild.firstPos());
  41.          if (this.fLeftChild.isNullable()) {
  42.             var1.union(this.fRightChild.firstPos());
  43.          }
  44.       } else {
  45.          throw new CMException(154);
  46.       }
  47.    }
  48.  
  49.    protected void calcLastPos(CMStateSet var1) throws CMException {
  50.       if (((CMNode)this).type() == 4) {
  51.          var1.setTo(this.fLeftChild.lastPos());
  52.          var1.union(this.fRightChild.lastPos());
  53.       } else if (((CMNode)this).type() == 5) {
  54.          var1.setTo(this.fRightChild.lastPos());
  55.          if (this.fRightChild.isNullable()) {
  56.             var1.union(this.fLeftChild.lastPos());
  57.          }
  58.       } else {
  59.          throw new CMException(154);
  60.       }
  61.    }
  62. }
  63.