1 57 58 package com.sun.org.apache.xerces.internal.impl.xs; 59 60 import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl; 61 import com.sun.org.apache.xerces.internal.xni.QName; 62 import com.sun.org.apache.xerces.internal.xni.XMLAttributes; 63 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription; 64 import com.sun.org.apache.xerces.internal.xni.grammars.XMLSchemaDescription; 65 66 74 public class XSDDescription extends XMLResourceIdentifierImpl 75 implements XMLSchemaDescription { 76 80 public final static short CONTEXT_INITIALIZE = -1; 81 85 public final static short CONTEXT_INCLUDE = 0; 86 90 public final static short CONTEXT_REDEFINE = 1; 91 95 public final static short CONTEXT_IMPORT = 2; 96 99 public final static short CONTEXT_PREPARSE = 3; 100 106 public final static short CONTEXT_INSTANCE = 4; 107 114 public final static short CONTEXT_ELEMENT = 5; 115 122 public final static short CONTEXT_ATTRIBUTE = 6; 123 130 public final static short CONTEXT_XSITYPE = 7; 131 132 protected short fContextType; 134 protected String [] fLocationHints ; 135 protected QName fTriggeringComponent; 136 protected QName fEnclosedElementName; 137 protected XMLAttributes fAttributes; 138 139 144 public String getGrammarType() { 145 return XMLGrammarDescription.XML_SCHEMA; 146 } 147 148 154 public short getContextType() { 155 return fContextType ; 156 } 157 158 165 public String getTargetNamespace() { 166 return fNamespace; 167 } 168 169 177 public String [] getLocationHints() { 178 return fLocationHints ; 179 } 180 181 188 public QName getTriggeringComponent() { 189 return fTriggeringComponent ; 190 } 191 192 198 public QName getEnclosingElementName() { 199 return fEnclosedElementName ; 200 } 201 202 208 public XMLAttributes getAttributes() { 209 return fAttributes; 210 } 211 212 public boolean fromInstance() { 213 return fContextType == CONTEXT_ATTRIBUTE || 214 fContextType == CONTEXT_ELEMENT || 215 fContextType == CONTEXT_INSTANCE || 216 fContextType == CONTEXT_XSITYPE; 217 } 218 219 226 public boolean equals(Object descObj) { 227 if(!(descObj instanceof XMLSchemaDescription)) return false; 228 XMLSchemaDescription desc = (XMLSchemaDescription)descObj; 229 if (fNamespace != null) 230 return fNamespace.equals(desc.getTargetNamespace()); 231 else return desc.getTargetNamespace() == null; 233 } 234 235 240 public int hashCode() { 241 return (fNamespace == null) ? 0 : fNamespace.hashCode(); 242 } 243 244 public void setContextType(short contextType){ 245 fContextType = contextType ; 246 } 247 248 public void setTargetNamespace(String targetNamespace){ 249 fNamespace = targetNamespace ; 250 } 251 252 public void setLocationHints(String [] locationHints){ 253 int length = locationHints.length ; 254 fLocationHints = new String [length]; 255 System.arraycopy(locationHints, 0, fLocationHints, 0, length); 256 } 258 259 public void setTriggeringComponent(QName triggeringComponent){ 260 fTriggeringComponent = triggeringComponent ; 261 } 262 263 public void setEnclosingElementName(QName enclosedElementName){ 264 fEnclosedElementName = enclosedElementName ; 265 } 266 267 public void setAttributes(XMLAttributes attributes){ 268 fAttributes = attributes ; 269 } 270 271 274 public void reset(){ 275 super.clear(); 276 fContextType = CONTEXT_INITIALIZE; 277 fLocationHints = null ; 278 fTriggeringComponent = null ; 279 fEnclosedElementName = null ; 280 fAttributes = null ; 281 } 282 283 public XSDDescription makeClone() { 284 XSDDescription desc = new XSDDescription(); 285 desc.fAttributes = this.fAttributes; 286 desc.fBaseSystemId = this.fBaseSystemId; 287 desc.fContextType = this.fContextType; 288 desc.fEnclosedElementName = this.fEnclosedElementName; 289 desc.fExpandedSystemId = this.fExpandedSystemId; 290 desc.fLiteralSystemId = this.fLiteralSystemId; 291 desc.fLocationHints = this.fLocationHints; 292 desc.fPublicId = this.fPublicId; 293 desc.fNamespace = this.fNamespace; 294 desc.fTriggeringComponent = this.fTriggeringComponent; 295 return desc; 296 } 297 298 } | Popular Tags |