1 57 58 package com.sun.org.apache.xerces.internal.impl.xs.models; 59 60 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMNode; 61 import com.sun.org.apache.xerces.internal.impl.dtd.models.CMStateSet; 62 import com.sun.org.apache.xerces.internal.impl.xs.XSModelGroupImpl; 63 64 71 public class XSCMBinOp extends CMNode { 72 public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode) 76 { 77 super(type); 78 79 if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE) 81 && (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) { 82 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 83 } 84 85 fLeftChild = leftNode; 87 fRightChild = rightNode; 88 } 89 90 91 final CMNode getLeft() { 95 return fLeftChild; 96 } 97 98 final CMNode getRight() { 99 return fRightChild; 100 } 101 102 103 public boolean isNullable() { 107 if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) 113 return (fLeftChild.isNullable() || fRightChild.isNullable()); 114 else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) 115 return (fLeftChild.isNullable() && fRightChild.isNullable()); 116 else 117 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 118 } 119 120 121 protected void calcFirstPos(CMStateSet toSet) { 125 if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) { 126 toSet.setTo(fLeftChild.firstPos()); 128 toSet.union(fRightChild.firstPos()); 129 } 130 else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) { 131 toSet.setTo(fLeftChild.firstPos()); 137 if (fLeftChild.isNullable()) 138 toSet.union(fRightChild.firstPos()); 139 } 140 else { 141 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 142 } 143 } 144 145 protected void calcLastPos(CMStateSet toSet) { 146 if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) { 147 toSet.setTo(fLeftChild.lastPos()); 149 toSet.union(fRightChild.lastPos()); 150 } 151 else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) { 152 toSet.setTo(fRightChild.lastPos()); 158 if (fRightChild.isNullable()) 159 toSet.union(fLeftChild.lastPos()); 160 } 161 else { 162 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 163 } 164 } 165 166 167 private CMNode fLeftChild; 176 private CMNode fRightChild; 177 } 179 | Popular Tags |