1 16 17 package org.apache.xerces.impl.dtd.models; 18 19 import org.apache.xerces.impl.dtd.XMLContentSpec; 20 21 28 public class CMBinOp extends CMNode 29 { 30 public CMBinOp(int type, CMNode leftNode, CMNode rightNode) 34 { 35 super(type); 36 37 if ((type() != XMLContentSpec.CONTENTSPECNODE_CHOICE) 39 && (type() != XMLContentSpec.CONTENTSPECNODE_SEQ)) 40 { 41 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 42 } 43 44 fLeftChild = leftNode; 46 fRightChild = rightNode; 47 } 48 49 50 final CMNode getLeft() 54 { 55 return fLeftChild; 56 } 57 58 final CMNode getRight() 59 { 60 return fRightChild; 61 } 62 63 64 public boolean isNullable() 68 { 69 if (type() == XMLContentSpec.CONTENTSPECNODE_CHOICE) 75 return (fLeftChild.isNullable() || fRightChild.isNullable()); 76 else if (type() == XMLContentSpec.CONTENTSPECNODE_SEQ) 77 return (fLeftChild.isNullable() && fRightChild.isNullable()); 78 else 79 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 80 } 81 82 83 protected void calcFirstPos(CMStateSet toSet) 87 { 88 if (type() == XMLContentSpec.CONTENTSPECNODE_CHOICE) 89 { 90 toSet.setTo(fLeftChild.firstPos()); 92 toSet.union(fRightChild.firstPos()); 93 } 94 else if (type() == XMLContentSpec.CONTENTSPECNODE_SEQ) 95 { 96 toSet.setTo(fLeftChild.firstPos()); 102 if (fLeftChild.isNullable()) 103 toSet.union(fRightChild.firstPos()); 104 } 105 else 106 { 107 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 108 } 109 } 110 111 protected void calcLastPos(CMStateSet toSet) 112 { 113 if (type() == XMLContentSpec.CONTENTSPECNODE_CHOICE) 114 { 115 toSet.setTo(fLeftChild.lastPos()); 117 toSet.union(fRightChild.lastPos()); 118 } 119 else if (type() == XMLContentSpec.CONTENTSPECNODE_SEQ) 120 { 121 toSet.setTo(fRightChild.lastPos()); 127 if (fRightChild.isNullable()) 128 toSet.union(fLeftChild.lastPos()); 129 } 130 else 131 { 132 throw new RuntimeException ("ImplementationMessages.VAL_BST"); 133 } 134 } 135 136 137 private CMNode fLeftChild; 146 private CMNode fRightChild; 147 }; 148 149 | Popular Tags |