1 57 58 package com.sun.org.apache.xerces.internal.impl.dtd.models; 59 60 import com.sun.org.apache.xerces.internal.impl.dtd.XMLContentSpec; 61 62 68 public class CMBinOp extends CMNode 69 { 70 public CMBinOp(int type, CMNode leftNode, CMNode rightNode) 74 { 75 super(type); 76 77 if ((type() != XMLContentSpec.CONTENTSPECNODE_CHOICE) 79 && (type() != XMLContentSpec.CONTENTSPECNODE_SEQ)) 80 { 81 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 82 } 83 84 fLeftChild = leftNode; 86 fRightChild = rightNode; 87 } 88 89 90 final CMNode getLeft() 94 { 95 return fLeftChild; 96 } 97 98 final CMNode getRight() 99 { 100 return fRightChild; 101 } 102 103 104 public boolean isNullable() 108 { 109 if (type() == XMLContentSpec.CONTENTSPECNODE_CHOICE) 115 return (fLeftChild.isNullable() || fRightChild.isNullable()); 116 else if (type() == XMLContentSpec.CONTENTSPECNODE_SEQ) 117 return (fLeftChild.isNullable() && fRightChild.isNullable()); 118 else 119 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 120 } 121 122 123 protected void calcFirstPos(CMStateSet toSet) 127 { 128 if (type() == XMLContentSpec.CONTENTSPECNODE_CHOICE) 129 { 130 toSet.setTo(fLeftChild.firstPos()); 132 toSet.union(fRightChild.firstPos()); 133 } 134 else if (type() == XMLContentSpec.CONTENTSPECNODE_SEQ) 135 { 136 toSet.setTo(fLeftChild.firstPos()); 142 if (fLeftChild.isNullable()) 143 toSet.union(fRightChild.firstPos()); 144 } 145 else 146 { 147 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 148 } 149 } 150 151 protected void calcLastPos(CMStateSet toSet) 152 { 153 if (type() == XMLContentSpec.CONTENTSPECNODE_CHOICE) 154 { 155 toSet.setTo(fLeftChild.lastPos()); 157 toSet.union(fRightChild.lastPos()); 158 } 159 else if (type() == XMLContentSpec.CONTENTSPECNODE_SEQ) 160 { 161 toSet.setTo(fRightChild.lastPos()); 167 if (fRightChild.isNullable()) 168 toSet.union(fLeftChild.lastPos()); 169 } 170 else 171 { 172 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 173 } 174 } 175 176 177 private CMNode fLeftChild; 186 private CMNode fRightChild; 187 }; 188 189 | Popular Tags |