1 16 17 package org.apache.xerces.impl.xs.models; 18 19 import org.apache.xerces.impl.dtd.models.CMNode; 20 import org.apache.xerces.impl.dtd.models.CMStateSet; 21 import org.apache.xerces.impl.xs.XSModelGroupImpl; 22 23 32 public class XSCMBinOp extends CMNode { 33 public XSCMBinOp(int type, CMNode leftNode, CMNode rightNode) 37 { 38 super(type); 39 40 if ((type() != XSModelGroupImpl.MODELGROUP_CHOICE) 42 && (type() != XSModelGroupImpl.MODELGROUP_SEQUENCE)) { 43 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 44 } 45 46 fLeftChild = leftNode; 48 fRightChild = rightNode; 49 } 50 51 52 final CMNode getLeft() { 56 return fLeftChild; 57 } 58 59 final CMNode getRight() { 60 return fRightChild; 61 } 62 63 64 public boolean isNullable() { 68 if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) 74 return (fLeftChild.isNullable() || fRightChild.isNullable()); 75 else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) 76 return (fLeftChild.isNullable() && fRightChild.isNullable()); 77 else 78 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 79 } 80 81 82 protected void calcFirstPos(CMStateSet toSet) { 86 if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) { 87 toSet.setTo(fLeftChild.firstPos()); 89 toSet.union(fRightChild.firstPos()); 90 } 91 else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) { 92 toSet.setTo(fLeftChild.firstPos()); 98 if (fLeftChild.isNullable()) 99 toSet.union(fRightChild.firstPos()); 100 } 101 else { 102 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 103 } 104 } 105 106 protected void calcLastPos(CMStateSet toSet) { 107 if (type() == XSModelGroupImpl.MODELGROUP_CHOICE) { 108 toSet.setTo(fLeftChild.lastPos()); 110 toSet.union(fRightChild.lastPos()); 111 } 112 else if (type() == XSModelGroupImpl.MODELGROUP_SEQUENCE) { 113 toSet.setTo(fRightChild.lastPos()); 119 if (fRightChild.isNullable()) 120 toSet.union(fLeftChild.lastPos()); 121 } 122 else { 123 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 124 } 125 } 126 127 128 private CMNode fLeftChild; 137 private CMNode fRightChild; 138 } 140 | Popular Tags |