1 16 17 package org.apache.xerces.impl.xs; 18 19 import org.apache.xerces.util.XMLResourceIdentifierImpl; 20 import org.apache.xerces.xni.QName; 21 import org.apache.xerces.xni.XMLAttributes; 22 import org.apache.xerces.xni.grammars.XMLGrammarDescription; 23 import org.apache.xerces.xni.grammars.XMLSchemaDescription; 24 25 35 public class XSDDescription extends XMLResourceIdentifierImpl 36 implements XMLSchemaDescription { 37 41 public final static short CONTEXT_INITIALIZE = -1; 42 46 public final static short CONTEXT_INCLUDE = 0; 47 51 public final static short CONTEXT_REDEFINE = 1; 52 56 public final static short CONTEXT_IMPORT = 2; 57 60 public final static short CONTEXT_PREPARSE = 3; 61 67 public final static short CONTEXT_INSTANCE = 4; 68 75 public final static short CONTEXT_ELEMENT = 5; 76 83 public final static short CONTEXT_ATTRIBUTE = 6; 84 91 public final static short CONTEXT_XSITYPE = 7; 92 93 protected short fContextType; 95 protected String [] fLocationHints ; 96 protected QName fTriggeringComponent; 97 protected QName fEnclosedElementName; 98 protected XMLAttributes fAttributes; 99 100 105 public String getGrammarType() { 106 return XMLGrammarDescription.XML_SCHEMA; 107 } 108 109 115 public short getContextType() { 116 return fContextType ; 117 } 118 119 126 public String getTargetNamespace() { 127 return fNamespace; 128 } 129 130 138 public String [] getLocationHints() { 139 return fLocationHints ; 140 } 141 142 149 public QName getTriggeringComponent() { 150 return fTriggeringComponent ; 151 } 152 153 159 public QName getEnclosingElementName() { 160 return fEnclosedElementName ; 161 } 162 163 169 public XMLAttributes getAttributes() { 170 return fAttributes; 171 } 172 173 public boolean fromInstance() { 174 return fContextType == CONTEXT_ATTRIBUTE || 175 fContextType == CONTEXT_ELEMENT || 176 fContextType == CONTEXT_INSTANCE || 177 fContextType == CONTEXT_XSITYPE; 178 } 179 180 187 public boolean equals(Object descObj) { 188 if(!(descObj instanceof XMLSchemaDescription)) return false; 189 XMLSchemaDescription desc = (XMLSchemaDescription)descObj; 190 if (fNamespace != null) 191 return fNamespace.equals(desc.getTargetNamespace()); 192 else return desc.getTargetNamespace() == null; 194 } 195 196 201 public int hashCode() { 202 return (fNamespace == null) ? 0 : fNamespace.hashCode(); 203 } 204 205 public void setContextType(short contextType){ 206 fContextType = contextType ; 207 } 208 209 public void setTargetNamespace(String targetNamespace){ 210 fNamespace = targetNamespace ; 211 } 212 213 public void setLocationHints(String [] locationHints){ 214 int length = locationHints.length ; 215 fLocationHints = new String [length]; 216 System.arraycopy(locationHints, 0, fLocationHints, 0, length); 217 } 219 220 public void setTriggeringComponent(QName triggeringComponent){ 221 fTriggeringComponent = triggeringComponent ; 222 } 223 224 public void setEnclosingElementName(QName enclosedElementName){ 225 fEnclosedElementName = enclosedElementName ; 226 } 227 228 public void setAttributes(XMLAttributes attributes){ 229 fAttributes = attributes ; 230 } 231 232 235 public void reset(){ 236 super.clear(); 237 fContextType = CONTEXT_INITIALIZE; 238 fLocationHints = null ; 239 fTriggeringComponent = null ; 240 fEnclosedElementName = null ; 241 fAttributes = null ; 242 } 243 244 public XSDDescription makeClone() { 245 XSDDescription desc = new XSDDescription(); 246 desc.fAttributes = this.fAttributes; 247 desc.fBaseSystemId = this.fBaseSystemId; 248 desc.fContextType = this.fContextType; 249 desc.fEnclosedElementName = this.fEnclosedElementName; 250 desc.fExpandedSystemId = this.fExpandedSystemId; 251 desc.fLiteralSystemId = this.fLiteralSystemId; 252 desc.fLocationHints = this.fLocationHints; 253 desc.fPublicId = this.fPublicId; 254 desc.fNamespace = this.fNamespace; 255 desc.fTriggeringComponent = this.fTriggeringComponent; 256 return desc; 257 } 258 259 } | Popular Tags |