Fri, 14 Feb 2014 11:13:45 +0100
8026188: Enhance envelope factory
Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Alexander Fomin
Reviewed-by: ahgross, mgrebac, skoivu
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. Oracle designates this |
aoqi@0 | 8 | * particular file as subject to the "Classpath" exception as provided |
aoqi@0 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aoqi@0 | 10 | * |
aoqi@0 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 15 | * accompanied this code). |
aoqi@0 | 16 | * |
aoqi@0 | 17 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 20 | * |
aoqi@0 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 22 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 23 | * questions. |
aoqi@0 | 24 | */ |
aoqi@0 | 25 | |
aoqi@0 | 26 | package com.sun.xml.internal.xsom.impl; |
aoqi@0 | 27 | |
aoqi@0 | 28 | import com.sun.xml.internal.xsom.SCD; |
aoqi@0 | 29 | import com.sun.xml.internal.xsom.XSAttGroupDecl; |
aoqi@0 | 30 | import com.sun.xml.internal.xsom.XSAttributeDecl; |
aoqi@0 | 31 | import com.sun.xml.internal.xsom.XSAttributeUse; |
aoqi@0 | 32 | import com.sun.xml.internal.xsom.XSComplexType; |
aoqi@0 | 33 | import com.sun.xml.internal.xsom.XSComponent; |
aoqi@0 | 34 | import com.sun.xml.internal.xsom.XSContentType; |
aoqi@0 | 35 | import com.sun.xml.internal.xsom.XSElementDecl; |
aoqi@0 | 36 | import com.sun.xml.internal.xsom.XSFacet; |
aoqi@0 | 37 | import com.sun.xml.internal.xsom.XSIdentityConstraint; |
aoqi@0 | 38 | import com.sun.xml.internal.xsom.XSListSimpleType; |
aoqi@0 | 39 | import com.sun.xml.internal.xsom.XSModelGroup; |
aoqi@0 | 40 | import com.sun.xml.internal.xsom.XSModelGroupDecl; |
aoqi@0 | 41 | import com.sun.xml.internal.xsom.XSNotation; |
aoqi@0 | 42 | import com.sun.xml.internal.xsom.XSParticle; |
aoqi@0 | 43 | import com.sun.xml.internal.xsom.XSRestrictionSimpleType; |
aoqi@0 | 44 | import com.sun.xml.internal.xsom.XSSchema; |
aoqi@0 | 45 | import com.sun.xml.internal.xsom.XSSchemaSet; |
aoqi@0 | 46 | import com.sun.xml.internal.xsom.XSSimpleType; |
aoqi@0 | 47 | import com.sun.xml.internal.xsom.XSType; |
aoqi@0 | 48 | import com.sun.xml.internal.xsom.XSUnionSimpleType; |
aoqi@0 | 49 | import com.sun.xml.internal.xsom.XSVariety; |
aoqi@0 | 50 | import com.sun.xml.internal.xsom.XSWildcard; |
aoqi@0 | 51 | import com.sun.xml.internal.xsom.impl.scd.Iterators; |
aoqi@0 | 52 | import com.sun.xml.internal.xsom.visitor.XSContentTypeFunction; |
aoqi@0 | 53 | import com.sun.xml.internal.xsom.visitor.XSContentTypeVisitor; |
aoqi@0 | 54 | import com.sun.xml.internal.xsom.visitor.XSFunction; |
aoqi@0 | 55 | import com.sun.xml.internal.xsom.visitor.XSSimpleTypeFunction; |
aoqi@0 | 56 | import com.sun.xml.internal.xsom.visitor.XSSimpleTypeVisitor; |
aoqi@0 | 57 | import com.sun.xml.internal.xsom.visitor.XSVisitor; |
aoqi@0 | 58 | import org.xml.sax.Locator; |
aoqi@0 | 59 | |
aoqi@0 | 60 | import javax.xml.namespace.NamespaceContext; |
aoqi@0 | 61 | import java.text.ParseException; |
aoqi@0 | 62 | import java.util.ArrayList; |
aoqi@0 | 63 | import java.util.Collection; |
aoqi@0 | 64 | import java.util.Collections; |
aoqi@0 | 65 | import java.util.HashMap; |
aoqi@0 | 66 | import java.util.Iterator; |
aoqi@0 | 67 | import java.util.List; |
aoqi@0 | 68 | import java.util.Map; |
aoqi@0 | 69 | import java.util.Vector; |
aoqi@0 | 70 | |
aoqi@0 | 71 | public class SchemaSetImpl implements XSSchemaSet |
aoqi@0 | 72 | { |
aoqi@0 | 73 | private final Map<String,XSSchema> schemas = new HashMap<String,XSSchema>(); |
aoqi@0 | 74 | private final Vector<XSSchema> schemas2 = new Vector<XSSchema>(); |
aoqi@0 | 75 | private final List<XSSchema> readonlySchemaList = Collections.unmodifiableList(schemas2); |
aoqi@0 | 76 | |
aoqi@0 | 77 | /** |
aoqi@0 | 78 | * Gets a reference to the existing schema or creates a new one |
aoqi@0 | 79 | * if none exists yet. |
aoqi@0 | 80 | */ |
aoqi@0 | 81 | public SchemaImpl createSchema(String targetNamespace, Locator location) { |
aoqi@0 | 82 | SchemaImpl obj = (SchemaImpl)schemas.get(targetNamespace); |
aoqi@0 | 83 | if (obj == null) { |
aoqi@0 | 84 | obj = new SchemaImpl(this, location, targetNamespace); |
aoqi@0 | 85 | schemas.put(targetNamespace, obj); |
aoqi@0 | 86 | schemas2.add(obj); |
aoqi@0 | 87 | } |
aoqi@0 | 88 | return obj; |
aoqi@0 | 89 | } |
aoqi@0 | 90 | |
aoqi@0 | 91 | public int getSchemaSize() { |
aoqi@0 | 92 | return schemas.size(); |
aoqi@0 | 93 | } |
aoqi@0 | 94 | public XSSchema getSchema(String targetNamespace) { |
aoqi@0 | 95 | return schemas.get(targetNamespace); |
aoqi@0 | 96 | } |
aoqi@0 | 97 | public XSSchema getSchema(int idx) { |
aoqi@0 | 98 | return schemas2.get(idx); |
aoqi@0 | 99 | } |
aoqi@0 | 100 | public Iterator<XSSchema> iterateSchema() { |
aoqi@0 | 101 | return schemas2.iterator(); |
aoqi@0 | 102 | } |
aoqi@0 | 103 | |
aoqi@0 | 104 | public final Collection<XSSchema> getSchemas() { |
aoqi@0 | 105 | return readonlySchemaList; |
aoqi@0 | 106 | } |
aoqi@0 | 107 | |
aoqi@0 | 108 | public XSType getType(String ns, String localName) { |
aoqi@0 | 109 | XSSchema schema = getSchema(ns); |
aoqi@0 | 110 | if(schema==null) return null; |
aoqi@0 | 111 | |
aoqi@0 | 112 | return schema.getType(localName); |
aoqi@0 | 113 | } |
aoqi@0 | 114 | |
aoqi@0 | 115 | public XSSimpleType getSimpleType( String ns, String localName ) { |
aoqi@0 | 116 | XSSchema schema = getSchema(ns); |
aoqi@0 | 117 | if(schema==null) return null; |
aoqi@0 | 118 | |
aoqi@0 | 119 | return schema.getSimpleType(localName); |
aoqi@0 | 120 | } |
aoqi@0 | 121 | |
aoqi@0 | 122 | public XSElementDecl getElementDecl( String ns, String localName ) { |
aoqi@0 | 123 | XSSchema schema = getSchema(ns); |
aoqi@0 | 124 | if(schema==null) return null; |
aoqi@0 | 125 | |
aoqi@0 | 126 | return schema.getElementDecl(localName); |
aoqi@0 | 127 | } |
aoqi@0 | 128 | |
aoqi@0 | 129 | public XSAttributeDecl getAttributeDecl( String ns, String localName ) { |
aoqi@0 | 130 | XSSchema schema = getSchema(ns); |
aoqi@0 | 131 | if(schema==null) return null; |
aoqi@0 | 132 | |
aoqi@0 | 133 | return schema.getAttributeDecl(localName); |
aoqi@0 | 134 | } |
aoqi@0 | 135 | |
aoqi@0 | 136 | public XSModelGroupDecl getModelGroupDecl( String ns, String localName ) { |
aoqi@0 | 137 | XSSchema schema = getSchema(ns); |
aoqi@0 | 138 | if(schema==null) return null; |
aoqi@0 | 139 | |
aoqi@0 | 140 | return schema.getModelGroupDecl(localName); |
aoqi@0 | 141 | } |
aoqi@0 | 142 | |
aoqi@0 | 143 | public XSAttGroupDecl getAttGroupDecl( String ns, String localName ) { |
aoqi@0 | 144 | XSSchema schema = getSchema(ns); |
aoqi@0 | 145 | if(schema==null) return null; |
aoqi@0 | 146 | |
aoqi@0 | 147 | return schema.getAttGroupDecl(localName); |
aoqi@0 | 148 | } |
aoqi@0 | 149 | |
aoqi@0 | 150 | public XSComplexType getComplexType( String ns, String localName ) { |
aoqi@0 | 151 | XSSchema schema = getSchema(ns); |
aoqi@0 | 152 | if(schema==null) return null; |
aoqi@0 | 153 | |
aoqi@0 | 154 | return schema.getComplexType(localName); |
aoqi@0 | 155 | } |
aoqi@0 | 156 | |
aoqi@0 | 157 | public XSIdentityConstraint getIdentityConstraint(String ns, String localName) { |
aoqi@0 | 158 | XSSchema schema = getSchema(ns); |
aoqi@0 | 159 | if(schema==null) return null; |
aoqi@0 | 160 | |
aoqi@0 | 161 | return schema.getIdentityConstraint(localName); |
aoqi@0 | 162 | } |
aoqi@0 | 163 | |
aoqi@0 | 164 | public Iterator<XSElementDecl> iterateElementDecls() { |
aoqi@0 | 165 | return new Iterators.Map<XSElementDecl,XSSchema>(iterateSchema()) { |
aoqi@0 | 166 | protected Iterator<XSElementDecl> apply(XSSchema u) { |
aoqi@0 | 167 | return u.iterateElementDecls(); |
aoqi@0 | 168 | } |
aoqi@0 | 169 | }; |
aoqi@0 | 170 | } |
aoqi@0 | 171 | |
aoqi@0 | 172 | public Iterator<XSType> iterateTypes() { |
aoqi@0 | 173 | return new Iterators.Map<XSType,XSSchema>(iterateSchema()) { |
aoqi@0 | 174 | protected Iterator<XSType> apply(XSSchema u) { |
aoqi@0 | 175 | return u.iterateTypes(); |
aoqi@0 | 176 | } |
aoqi@0 | 177 | }; |
aoqi@0 | 178 | } |
aoqi@0 | 179 | |
aoqi@0 | 180 | public Iterator<XSAttributeDecl> iterateAttributeDecls() { |
aoqi@0 | 181 | return new Iterators.Map<XSAttributeDecl,XSSchema>(iterateSchema()) { |
aoqi@0 | 182 | protected Iterator<XSAttributeDecl> apply(XSSchema u) { |
aoqi@0 | 183 | return u.iterateAttributeDecls(); |
aoqi@0 | 184 | } |
aoqi@0 | 185 | }; |
aoqi@0 | 186 | } |
aoqi@0 | 187 | public Iterator<XSAttGroupDecl> iterateAttGroupDecls() { |
aoqi@0 | 188 | return new Iterators.Map<XSAttGroupDecl,XSSchema>(iterateSchema()) { |
aoqi@0 | 189 | protected Iterator<XSAttGroupDecl> apply(XSSchema u) { |
aoqi@0 | 190 | return u.iterateAttGroupDecls(); |
aoqi@0 | 191 | } |
aoqi@0 | 192 | }; |
aoqi@0 | 193 | } |
aoqi@0 | 194 | public Iterator<XSModelGroupDecl> iterateModelGroupDecls() { |
aoqi@0 | 195 | return new Iterators.Map<XSModelGroupDecl,XSSchema>(iterateSchema()) { |
aoqi@0 | 196 | protected Iterator<XSModelGroupDecl> apply(XSSchema u) { |
aoqi@0 | 197 | return u.iterateModelGroupDecls(); |
aoqi@0 | 198 | } |
aoqi@0 | 199 | }; |
aoqi@0 | 200 | } |
aoqi@0 | 201 | public Iterator<XSSimpleType> iterateSimpleTypes() { |
aoqi@0 | 202 | return new Iterators.Map<XSSimpleType,XSSchema>(iterateSchema()) { |
aoqi@0 | 203 | protected Iterator<XSSimpleType> apply(XSSchema u) { |
aoqi@0 | 204 | return u.iterateSimpleTypes(); |
aoqi@0 | 205 | } |
aoqi@0 | 206 | }; |
aoqi@0 | 207 | } |
aoqi@0 | 208 | public Iterator<XSComplexType> iterateComplexTypes() { |
aoqi@0 | 209 | return new Iterators.Map<XSComplexType,XSSchema>(iterateSchema()) { |
aoqi@0 | 210 | protected Iterator<XSComplexType> apply(XSSchema u) { |
aoqi@0 | 211 | return u.iterateComplexTypes(); |
aoqi@0 | 212 | } |
aoqi@0 | 213 | }; |
aoqi@0 | 214 | } |
aoqi@0 | 215 | public Iterator<XSNotation> iterateNotations() { |
aoqi@0 | 216 | return new Iterators.Map<XSNotation,XSSchema>(iterateSchema()) { |
aoqi@0 | 217 | protected Iterator<XSNotation> apply(XSSchema u) { |
aoqi@0 | 218 | return u.iterateNotations(); |
aoqi@0 | 219 | } |
aoqi@0 | 220 | }; |
aoqi@0 | 221 | } |
aoqi@0 | 222 | |
aoqi@0 | 223 | public Iterator<XSIdentityConstraint> iterateIdentityConstraints() { |
aoqi@0 | 224 | return new Iterators.Map<XSIdentityConstraint,XSSchema>(iterateSchema()) { |
aoqi@0 | 225 | protected Iterator<XSIdentityConstraint> apply(XSSchema u) { |
aoqi@0 | 226 | return u.getIdentityConstraints().values().iterator(); |
aoqi@0 | 227 | } |
aoqi@0 | 228 | }; |
aoqi@0 | 229 | } |
aoqi@0 | 230 | |
aoqi@0 | 231 | public Collection<XSComponent> select(String scd, NamespaceContext nsContext) { |
aoqi@0 | 232 | try { |
aoqi@0 | 233 | return SCD.create(scd,nsContext).select(this); |
aoqi@0 | 234 | } catch (ParseException e) { |
aoqi@0 | 235 | throw new IllegalArgumentException(e); |
aoqi@0 | 236 | } |
aoqi@0 | 237 | } |
aoqi@0 | 238 | |
aoqi@0 | 239 | public XSComponent selectSingle(String scd, NamespaceContext nsContext) { |
aoqi@0 | 240 | try { |
aoqi@0 | 241 | return SCD.create(scd,nsContext).selectSingle(this); |
aoqi@0 | 242 | } catch (ParseException e) { |
aoqi@0 | 243 | throw new IllegalArgumentException(e); |
aoqi@0 | 244 | } |
aoqi@0 | 245 | } |
aoqi@0 | 246 | |
aoqi@0 | 247 | |
aoqi@0 | 248 | public final EmptyImpl empty = new EmptyImpl(); |
aoqi@0 | 249 | public XSContentType getEmpty() { return empty; } |
aoqi@0 | 250 | |
aoqi@0 | 251 | public XSSimpleType getAnySimpleType() { return anySimpleType; } |
aoqi@0 | 252 | public final AnySimpleType anySimpleType = new AnySimpleType(); |
aoqi@0 | 253 | private class AnySimpleType extends DeclarationImpl |
aoqi@0 | 254 | implements XSRestrictionSimpleType, Ref.SimpleType { |
aoqi@0 | 255 | |
aoqi@0 | 256 | AnySimpleType() { |
aoqi@0 | 257 | super(null,null,null,null,"http://www.w3.org/2001/XMLSchema","anySimpleType",false); |
aoqi@0 | 258 | } |
aoqi@0 | 259 | public SchemaImpl getOwnerSchema() { |
aoqi@0 | 260 | return createSchema("http://www.w3.org/2001/XMLSchema",null); |
aoqi@0 | 261 | } |
aoqi@0 | 262 | public XSSimpleType asSimpleType() { return this; } |
aoqi@0 | 263 | public XSComplexType asComplexType() { return null; } |
aoqi@0 | 264 | |
aoqi@0 | 265 | public boolean isDerivedFrom(XSType t) { |
aoqi@0 | 266 | return t==this || t==anyType; |
aoqi@0 | 267 | } |
aoqi@0 | 268 | |
aoqi@0 | 269 | public boolean isSimpleType() { return true; } |
aoqi@0 | 270 | public boolean isComplexType() { return false; } |
aoqi@0 | 271 | public XSContentType asEmpty() { return null; } |
aoqi@0 | 272 | public XSParticle asParticle() { return null; } |
aoqi@0 | 273 | public XSType getBaseType() { return anyType; } |
aoqi@0 | 274 | public XSSimpleType getSimpleBaseType() { return null; } |
aoqi@0 | 275 | public int getDerivationMethod() { return RESTRICTION; } |
aoqi@0 | 276 | public Iterator<XSFacet> iterateDeclaredFacets() { return Iterators.empty(); } |
aoqi@0 | 277 | public Collection<? extends XSFacet> getDeclaredFacets() { return Collections.EMPTY_LIST; } |
aoqi@0 | 278 | public void visit( XSSimpleTypeVisitor visitor ) {visitor.restrictionSimpleType(this); } |
aoqi@0 | 279 | public void visit( XSContentTypeVisitor visitor ) {visitor.simpleType(this); } |
aoqi@0 | 280 | public void visit( XSVisitor visitor ) {visitor.simpleType(this); } |
aoqi@0 | 281 | public <T> T apply( XSSimpleTypeFunction<T> f ) {return f.restrictionSimpleType(this); } |
aoqi@0 | 282 | public <T> T apply( XSContentTypeFunction<T> f ) { return f.simpleType(this); } |
aoqi@0 | 283 | public <T> T apply( XSFunction<T> f ) { return f.simpleType(this); } |
aoqi@0 | 284 | public XSVariety getVariety() { return XSVariety.ATOMIC; } |
aoqi@0 | 285 | public XSSimpleType getPrimitiveType() {return this;} |
aoqi@0 | 286 | public boolean isPrimitive() {return true;} |
aoqi@0 | 287 | public XSListSimpleType getBaseListType() {return null;} |
aoqi@0 | 288 | public XSUnionSimpleType getBaseUnionType() {return null;} |
aoqi@0 | 289 | public XSFacet getFacet(String name) { return null; } |
aoqi@0 | 290 | public List<XSFacet> getFacets( String name ) { return Collections.EMPTY_LIST; } |
aoqi@0 | 291 | public XSFacet getDeclaredFacet(String name) { return null; } |
aoqi@0 | 292 | public List<XSFacet> getDeclaredFacets(String name) { return Collections.EMPTY_LIST; } |
aoqi@0 | 293 | |
aoqi@0 | 294 | public boolean isRestriction() { return true; } |
aoqi@0 | 295 | public boolean isList() { return false; } |
aoqi@0 | 296 | public boolean isUnion() { return false; } |
aoqi@0 | 297 | public boolean isFinal(XSVariety v) { return false; } |
aoqi@0 | 298 | public XSRestrictionSimpleType asRestriction() { return this; } |
aoqi@0 | 299 | public XSListSimpleType asList() { return null; } |
aoqi@0 | 300 | public XSUnionSimpleType asUnion() { return null; } |
aoqi@0 | 301 | public XSSimpleType getType() { return this; } // Ref.SimpleType implementation |
aoqi@0 | 302 | public XSSimpleType getRedefinedBy() { return null; } |
aoqi@0 | 303 | public int getRedefinedCount() { return 0; } |
aoqi@0 | 304 | |
aoqi@0 | 305 | public XSType[] listSubstitutables() { |
aoqi@0 | 306 | return Util.listSubstitutables(this); |
aoqi@0 | 307 | } |
aoqi@0 | 308 | } |
aoqi@0 | 309 | |
aoqi@0 | 310 | public XSComplexType getAnyType() { return anyType; } |
aoqi@0 | 311 | public final AnyType anyType = new AnyType(); |
aoqi@0 | 312 | private class AnyType extends DeclarationImpl implements XSComplexType, Ref.Type { |
aoqi@0 | 313 | AnyType() { |
aoqi@0 | 314 | super(null,null,null,null,"http://www.w3.org/2001/XMLSchema","anyType",false); |
aoqi@0 | 315 | } |
aoqi@0 | 316 | public SchemaImpl getOwnerSchema() { |
aoqi@0 | 317 | return createSchema("http://www.w3.org/2001/XMLSchema",null); |
aoqi@0 | 318 | } |
aoqi@0 | 319 | public boolean isAbstract() { return false; } |
aoqi@0 | 320 | public XSWildcard getAttributeWildcard() { return anyWildcard; } |
aoqi@0 | 321 | public XSAttributeUse getAttributeUse( String nsURI, String localName ) { return null; } |
aoqi@0 | 322 | public Iterator<XSAttributeUse> iterateAttributeUses() { return Iterators.empty(); } |
aoqi@0 | 323 | public XSAttributeUse getDeclaredAttributeUse( String nsURI, String localName ) { return null; } |
aoqi@0 | 324 | public Iterator<XSAttributeUse> iterateDeclaredAttributeUses() { return Iterators.empty(); } |
aoqi@0 | 325 | public Iterator<XSAttGroupDecl> iterateAttGroups() { return Iterators.empty(); } |
aoqi@0 | 326 | public Collection<XSAttributeUse> getAttributeUses() { return Collections.EMPTY_LIST; } |
aoqi@0 | 327 | public Collection<? extends XSAttributeUse> getDeclaredAttributeUses() { return Collections.EMPTY_LIST; } |
aoqi@0 | 328 | public Collection<? extends XSAttGroupDecl> getAttGroups() { return Collections.EMPTY_LIST; } |
aoqi@0 | 329 | public boolean isFinal( int i ) { return false; } |
aoqi@0 | 330 | public boolean isSubstitutionProhibited( int i ) { return false; } |
aoqi@0 | 331 | public boolean isMixed() { return true; } |
aoqi@0 | 332 | public XSContentType getContentType() { return contentType; } |
aoqi@0 | 333 | public XSContentType getExplicitContent() { return null; } |
aoqi@0 | 334 | public XSType getBaseType() { return this; } |
aoqi@0 | 335 | public XSSimpleType asSimpleType() { return null; } |
aoqi@0 | 336 | public XSComplexType asComplexType() { return this; } |
aoqi@0 | 337 | |
aoqi@0 | 338 | public boolean isDerivedFrom(XSType t) { |
aoqi@0 | 339 | return t==this; |
aoqi@0 | 340 | } |
aoqi@0 | 341 | |
aoqi@0 | 342 | public boolean isSimpleType() { return false; } |
aoqi@0 | 343 | public boolean isComplexType() { return true; } |
aoqi@0 | 344 | public XSContentType asEmpty() { return null; } |
aoqi@0 | 345 | public int getDerivationMethod() { return XSType.RESTRICTION; } |
aoqi@0 | 346 | |
aoqi@0 | 347 | public XSElementDecl getScope() { return null; } |
aoqi@0 | 348 | public void visit( XSVisitor visitor ) { visitor.complexType(this); } |
aoqi@0 | 349 | public <T> T apply( XSFunction<T> f ) { return f.complexType(this); } |
aoqi@0 | 350 | |
aoqi@0 | 351 | public XSType getType() { return this; } // Ref.Type implementation |
aoqi@0 | 352 | |
aoqi@0 | 353 | public XSComplexType getRedefinedBy() { return null; } |
aoqi@0 | 354 | public int getRedefinedCount() { return 0; } |
aoqi@0 | 355 | |
aoqi@0 | 356 | public XSType[] listSubstitutables() { |
aoqi@0 | 357 | return Util.listSubstitutables(this); |
aoqi@0 | 358 | } |
aoqi@0 | 359 | |
aoqi@0 | 360 | private final WildcardImpl anyWildcard = new WildcardImpl.Any(null,null,null,null,XSWildcard.SKIP); |
aoqi@0 | 361 | private final XSContentType contentType = new ParticleImpl( null, null, |
aoqi@0 | 362 | new ModelGroupImpl(null, null, null, null,XSModelGroup.SEQUENCE, new ParticleImpl[]{ |
aoqi@0 | 363 | new ParticleImpl( null, null, |
aoqi@0 | 364 | anyWildcard, null, |
aoqi@0 | 365 | XSParticle.UNBOUNDED, 0 ) |
aoqi@0 | 366 | }) |
aoqi@0 | 367 | ,null,1,1); |
aoqi@0 | 368 | public List<XSComplexType> getSubtypes() { |
aoqi@0 | 369 | ArrayList subtypeList = new ArrayList(); |
aoqi@0 | 370 | Iterator<XSComplexType> cTypes = getRoot().iterateComplexTypes(); |
aoqi@0 | 371 | while (cTypes.hasNext()) { |
aoqi@0 | 372 | XSComplexType cType= cTypes.next(); |
aoqi@0 | 373 | XSType base = cType.getBaseType(); |
aoqi@0 | 374 | if ((base != null) && (base.equals(this))) { |
aoqi@0 | 375 | subtypeList.add(cType); |
aoqi@0 | 376 | } |
aoqi@0 | 377 | } |
aoqi@0 | 378 | return subtypeList; |
aoqi@0 | 379 | } |
aoqi@0 | 380 | |
aoqi@0 | 381 | public List<XSElementDecl> getElementDecls() { |
aoqi@0 | 382 | ArrayList declList = new ArrayList(); |
aoqi@0 | 383 | XSSchemaSet schemaSet = getRoot(); |
aoqi@0 | 384 | for (XSSchema sch : schemaSet.getSchemas()) { |
aoqi@0 | 385 | for (XSElementDecl decl : sch.getElementDecls().values()) { |
aoqi@0 | 386 | if (decl.getType().equals(this)) { |
aoqi@0 | 387 | declList.add(decl); |
aoqi@0 | 388 | } |
aoqi@0 | 389 | } |
aoqi@0 | 390 | } |
aoqi@0 | 391 | return declList; |
aoqi@0 | 392 | } |
aoqi@0 | 393 | } |
aoqi@0 | 394 | } |