1 57 58 package org.enhydra.apache.xerces.validators.common; 59 60 import org.enhydra.apache.xerces.framework.XMLContentSpec; 61 import org.enhydra.apache.xerces.utils.QName; 62 import org.enhydra.apache.xerces.utils.StringPool; 63 64 69 public class CMLeaf 70 extends CMNode { 71 72 76 77 private QName fElement = new QName(); 78 79 84 private int fPosition = -1; 85 86 90 91 public CMLeaf(QName element, int position) throws CMException { 92 super(XMLContentSpec.CONTENTSPECNODE_LEAF); 93 94 fElement.setValues(element); 96 fPosition = position; 97 } 98 99 100 public CMLeaf(QName element) throws CMException { 101 super(XMLContentSpec.CONTENTSPECNODE_LEAF); 102 103 fElement.setValues(element); 105 } 106 107 111 final QName getElement() 112 { 113 return fElement; 114 } 115 116 final int getPosition() 117 { 118 return fPosition; 119 } 120 121 final void setPosition(int newPosition) 122 { 123 fPosition = newPosition; 124 } 125 126 130 132 boolean isNullable() throws CMException 133 { 134 return (fPosition == -1); 136 } 137 138 String toString(StringPool stringPool) 139 { 140 StringBuffer strRet = new StringBuffer (fElement.toString()); 141 strRet.append(" ("); 142 strRet.append(stringPool.toString(fElement.uri)); 143 strRet.append(','); 144 strRet.append(stringPool.toString(fElement.localpart)); 145 strRet.append(')'); 146 if (fPosition >= 0) 147 { 148 strRet.append 149 ( 150 " (Pos:" 151 + new Integer (fPosition).toString() 152 + ")" 153 ); 154 } 155 return strRet.toString(); 156 } 157 158 160 protected void calcFirstPos(CMStateSet toSet) throws CMException 161 { 162 if (fPosition == -1) 164 toSet.zeroBits(); 165 166 else 168 toSet.setBit(fPosition); 169 } 170 171 protected void calcLastPos(CMStateSet toSet) throws CMException 172 { 173 if (fPosition == -1) 175 toSet.zeroBits(); 176 177 else 179 toSet.setBit(fPosition); 180 } 181 182 } | Popular Tags |