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.StringPool; 62 63 68 public class CMAny 69 extends CMNode { 70 71 75 81 private int fType; 82 83 89 private int fURI; 90 91 96 private int fPosition = -1; 97 98 102 103 public CMAny(int type, int uri, int position) throws CMException { 104 super(type); 105 106 fType = type; 108 fURI = uri; 109 fPosition = position; 110 } 111 112 116 final int getType() { 117 return fType; 118 } 119 120 final int getURI() { 121 return fURI; 122 } 123 124 final int getPosition() 125 { 126 return fPosition; 127 } 128 129 final void setPosition(int newPosition) 130 { 131 fPosition = newPosition; 132 } 133 134 138 140 boolean isNullable() throws CMException 141 { 142 return (fPosition == -1); 144 } 145 146 String toString(StringPool stringPool) 147 { 148 StringBuffer strRet = new StringBuffer (); 149 strRet.append("("); 150 switch (fType & 0x0f) { 151 case XMLContentSpec.CONTENTSPECNODE_ANY: 152 strRet.append("##any"); 153 break; 154 case XMLContentSpec.CONTENTSPECNODE_ANY_NS: 155 strRet.append("##any:uri=" + stringPool.toString(fURI)); 156 break; 157 case XMLContentSpec.CONTENTSPECNODE_ANY_OTHER: 158 strRet.append("##other:uri=" + stringPool.toString(fURI)); 159 break; 160 } 161 strRet.append(stringPool.toString(fURI)); 162 strRet.append(')'); 163 if (fPosition >= 0) 164 { 165 strRet.append 166 ( 167 " (Pos:" 168 + new Integer (fPosition).toString() 169 + ")" 170 ); 171 } 172 return strRet.toString(); 173 } 174 175 177 protected void calcFirstPos(CMStateSet toSet) throws CMException 178 { 179 if (fPosition == -1) 181 toSet.zeroBits(); 182 183 else 185 toSet.setBit(fPosition); 186 } 187 188 protected void calcLastPos(CMStateSet toSet) throws CMException 189 { 190 if (fPosition == -1) 192 toSet.zeroBits(); 193 194 else 196 toSet.setBit(fPosition); 197 } 198 199 } | Popular Tags |