om.sun.xsom.xsom.2.5.2.source-code.complexType.rng Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xsom Show documentation
Show all versions of xsom Show documentation
XML Schema Object Model (XSOM) is a Java library that allows applications to easily parse XML Schema
documents and inspect information in them. It is expected to be useful for applications that need to take XML
Schema as an input.
The newest version!
private ComplexTypeImpl result;
private Ref.Type baseType;
private Ref.ContentType contentType;
// local variables for simpleContent/restriction
private Ref.SimpleType baseContentType;
private RestrictionSimpleTypeImpl contentSimpleType;
private Locator locator,locator2;
private static class BaseContentSimpleTypeRef implements Ref.SimpleType {
private final Ref.Type baseType;
private BaseContentSimpleTypeRef(Ref.Type _baseType ) { this.baseType = _baseType; }
public XSSimpleType getType() {
return (XSSimpleType)((XSComplexType)baseType.getType()).getContentType();
}
}
locator = $runtime.copyLocator();
fa = (fa);
(null,AnnotationContext.COMPLEXTYPE_DECL);
fa = (fa);
annotation = (annotation,AnnotationContext.COMPLEXTYPE_DECL);
locator2 = $runtime.copyLocator();
baseType = new DelayedRef.Type(
$runtime, locator2, $runtime.currentSchema, baseTypeName );
fa = (fa);
annotation = (annotation,AnnotationContext.COMPLEXTYPE_DECL);
if(baseContentType==null) {
// contentType of the base type, which must be a complex type
baseContentType = new BaseContentSimpleTypeRef(baseType);
}
contentSimpleType = new RestrictionSimpleTypeImpl(
$runtime.document, null/*?*/, locator2, null,
null, true, Collections.EMPTY_SET, baseContentType );
contentType = contentSimpleType;
contentSimpleType.addFacet(facet);
makeResult(XSType.RESTRICTION);
result.setContentType(contentType);
locator2 = $runtime.copyLocator();
baseType = new DelayedRef.Type(
$runtime, locator2, $runtime.currentSchema, baseTypeName );
fa = (fa);
annotation = (annotation,AnnotationContext.COMPLEXTYPE_DECL);
contentType = new BaseContentRef($runtime,baseType);
makeResult(XSType.EXTENSION);
result.setContentType(contentType);
fa = (fa);
annotation = (annotation,AnnotationContext.COMPLEXTYPE_DECL);
locator2 = $runtime.copyLocator();
baseType = new DelayedRef.Type(
$runtime, locator2, $runtime.currentSchema, baseTypeName );
makeResult(XSType.RESTRICTION);
fa = (fa);
annotation = (annotation,AnnotationContext.COMPLEXTYPE_DECL);
result.setContentType(explicitContent);
locator2 = $runtime.copyLocator();
baseType = new DelayedRef.Type(
$runtime, locator2, $runtime.currentSchema, baseTypeName );
makeResult(XSType.EXTENSION);
fa = (fa);
annotation = (annotation,AnnotationContext.COMPLEXTYPE_DECL);
result.setExplicitContent(explicitContent);
result.setContentType(
buildComplexExtensionContentModel(explicitContent));
baseType = $runtime.parser.schemaSet.anyType;
makeResult(XSType.RESTRICTION);
result.setContentType(explicitContent);
// baseType and contentType must be computed before calling this method.
private void makeResult( int derivationMethod ) {
if(finalValue==null)
finalValue = $runtime.finalDefault;
if(blockValue==null)
blockValue = $runtime.blockDefault;
result = new ComplexTypeImpl(
$runtime.document,
annotation,
locator,
fa,
name,
name==null,
$runtime.parseBoolean(abstractValue),
derivationMethod,
baseType,
finalValue,
blockValue,
$runtime.parseBoolean(mixedValue)
);
}
// I had to make them static inner classes (as opposed to anonymous ones),
// so that they will not keep references to parser.
private static class BaseComplexTypeContentRef implements Ref.ContentType {
private final Ref.Type baseType;
private BaseComplexTypeContentRef(Ref.Type _baseType) { this.baseType = _baseType; }
public XSContentType getContentType() {
return ((XSComplexType)baseType.getType()).getContentType();
}
}
private static class InheritBaseContentTypeRef implements Ref.ContentType {
private final Ref.Type baseType;
private final XSContentType empty;
private final XSContentType expContent;
private final SchemaDocumentImpl currentDocument;
private InheritBaseContentTypeRef(
Ref.Type _baseType,XSContentType _explicitContent,NGCCRuntimeEx $runtime) {
this.baseType = _baseType;
this.currentDocument = $runtime.document;
expContent = _explicitContent;
this.empty = $runtime.parser.schemaSet.empty;
}
public XSContentType getContentType() {
XSContentType baseContentType =
((XSComplexType)baseType.getType()).getContentType();
if(baseContentType==empty)
return expContent;
else
return new ParticleImpl( currentDocument, null, new ModelGroupImpl(
currentDocument,
null, null, null, XSModelGroup.SEQUENCE,
new ParticleImpl[]{
(ParticleImpl)baseContentType,
(ParticleImpl)expContent}), null );
}
};
private Ref.ContentType buildComplexExtensionContentModel( XSContentType explicitContent ) {
if(explicitContent==$runtime.parser.schemaSet.empty)
return new BaseComplexTypeContentRef(baseType);
else
return new InheritBaseContentTypeRef(baseType,explicitContent,$runtime);
}
private ContentTypeImpl particle;
if(particle==null)
particle = $runtime.parser.schemaSet.empty;