com.sun.tools.internal.xjc.reader.Ring Java Examples

The following examples show how to use com.sun.tools.internal.xjc.reader.Ring. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RawTypeSetBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void elementDecl(XSElementDecl decl) {

        QName n = BGMBuilder.getName(decl);
        if(elementNames.add(n)) {
            CElement elementBean = Ring.get(ClassSelector.class).bindToType(decl,null);
            if(elementBean==null)
                refs.add(new XmlTypeRef(decl));
            else {
                // yikes!
                if(elementBean instanceof CClass)
                    refs.add(new CClassRef(decl,(CClass)elementBean));
                else
                    refs.add(new CElementInfoRef(decl,(CElementInfo)elementBean));
            }
        }
    }
 
Example #2
Source File: RawTypeSetBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public void elementDecl(XSElementDecl decl) {

        QName n = BGMBuilder.getName(decl);
        if(elementNames.add(n)) {
            CElement elementBean = Ring.get(ClassSelector.class).bindToType(decl,null);
            if(elementBean==null)
                refs.add(new XmlTypeRef(decl));
            else {
                // yikes!
                if(elementBean instanceof CClass)
                    refs.add(new CClassRef(decl,(CClass)elementBean));
                else
                    refs.add(new CElementInfoRef(decl,(CElementInfo)elementBean));
            }
        }
    }
 
Example #3
Source File: RawTypeSetBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The whole type set can be later bound to a reference property,
 * in which case we need to generate additional code to wrap this
 * type reference into an element class.
 *
 * This method generates such an element class and returns it.
 */
protected void toElementRef(CReferencePropertyInfo prop) {
    CClassInfo scope = Ring.get(ClassSelector.class).getCurrentBean();
    Model model = Ring.get(Model.class);

    CCustomizations custs = Ring.get(BGMBuilder.class).getBindInfo(decl).toCustomizationList();

    if(target instanceof CClassInfo && Ring.get(BIGlobalBinding.class).isSimpleMode()) {
        CClassInfo bean = new CClassInfo(model,scope,
                        model.getNameConverter().toClassName(decl.getName()),
                        decl.getLocator(), null, BGMBuilder.getName(decl), decl,
                        custs);
        bean.setBaseClass((CClassInfo)target);
        prop.getElements().add(bean);
    } else {
        CElementInfo e = new CElementInfo(model,BGMBuilder.getName(decl),scope,target,
                decl.getDefaultValue(), decl, custs, decl.getLocator());
        prop.getElements().add(e);
    }
}
 
Example #4
Source File: RawTypeSetBuilder.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void elementDecl(XSElementDecl decl) {

        QName n = BGMBuilder.getName(decl);
        if(elementNames.add(n)) {
            CElement elementBean = Ring.get(ClassSelector.class).bindToType(decl,null);
            if(elementBean==null)
                refs.add(new XmlTypeRef(decl));
            else {
                // yikes!
                if(elementBean instanceof CClass)
                    refs.add(new CClassRef(decl,(CClass)elementBean));
                else
                    refs.add(new CElementInfoRef(decl,(CElementInfo)elementBean));
            }
        }
    }
 
Example #5
Source File: CPropertyInfo.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected CPropertyInfo(String name, boolean collection, XSComponent source,
                        CCustomizations customizations, Locator locator) {
    this.publicName = name;
    String n = null;

    Model m = Ring.get(Model.class);
    if (m != null) {
        n = m.getNameConverter().toVariableName(name);
    } else {
        n = NameConverter.standard.toVariableName(name);
    }

    if(!JJavaName.isJavaIdentifier(n))
        n = '_'+n;  // avoid colliding with the reserved names like 'abstract'.
    this.privateName = n;

    this.isCollection = collection;
    this.locator = locator;
    if(customizations==null)
        this.customizations = CCustomizations.EMPTY;
    else
        this.customizations = customizations;
    this.source = source;
}
 
Example #6
Source File: RawTypeSetBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The whole type set can be later bound to a reference property,
 * in which case we need to generate additional code to wrap this
 * type reference into an element class.
 *
 * This method generates such an element class and returns it.
 */
protected void toElementRef(CReferencePropertyInfo prop) {
    CClassInfo scope = Ring.get(ClassSelector.class).getCurrentBean();
    Model model = Ring.get(Model.class);

    CCustomizations custs = Ring.get(BGMBuilder.class).getBindInfo(decl).toCustomizationList();

    if(target instanceof CClassInfo && Ring.get(BIGlobalBinding.class).isSimpleMode()) {
        CClassInfo bean = new CClassInfo(model,scope,
                        model.getNameConverter().toClassName(decl.getName()),
                        decl.getLocator(), null, BGMBuilder.getName(decl), decl,
                        custs);
        bean.setBaseClass((CClassInfo)target);
        prop.getElements().add(bean);
    } else {
        CElementInfo e = new CElementInfo(model,BGMBuilder.getName(decl),scope,target,
                decl.getDefaultValue(), decl, custs, decl.getLocator());
        prop.getElements().add(e);
    }
}
 
Example #7
Source File: RawTypeSetBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void elementDecl(XSElementDecl decl) {

        QName n = BGMBuilder.getName(decl);
        if(elementNames.add(n)) {
            CElement elementBean = Ring.get(ClassSelector.class).bindToType(decl,null);
            if(elementBean==null)
                refs.add(new XmlTypeRef(decl));
            else {
                // yikes!
                if(elementBean instanceof CClass)
                    refs.add(new CClassRef(decl,(CClass)elementBean));
                else
                    refs.add(new CElementInfoRef(decl,(CElementInfo)elementBean));
            }
        }
    }
 
Example #8
Source File: RawTypeSetBuilder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The whole type set can be later bound to a reference property,
 * in which case we need to generate additional code to wrap this
 * type reference into an element class.
 *
 * This method generates such an element class and returns it.
 */
protected void toElementRef(CReferencePropertyInfo prop) {
    CClassInfo scope = Ring.get(ClassSelector.class).getCurrentBean();
    Model model = Ring.get(Model.class);

    CCustomizations custs = Ring.get(BGMBuilder.class).getBindInfo(decl).toCustomizationList();

    if(target instanceof CClassInfo && Ring.get(BIGlobalBinding.class).isSimpleMode()) {
        CClassInfo bean = new CClassInfo(model,scope,
                        model.getNameConverter().toClassName(decl.getName()),
                        decl.getLocator(), null, BGMBuilder.getName(decl), decl,
                        custs);
        bean.setBaseClass((CClassInfo)target);
        prop.getElements().add(bean);
    } else {
        CElementInfo e = new CElementInfo(model,BGMBuilder.getName(decl),scope,target,
                decl.getDefaultValue(), decl, custs, decl.getLocator());
        prop.getElements().add(e);
    }
}
 
Example #9
Source File: RawTypeSetBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public void elementDecl(XSElementDecl decl) {

        QName n = BGMBuilder.getName(decl);
        if(elementNames.add(n)) {
            CElement elementBean = Ring.get(ClassSelector.class).bindToType(decl,null);
            if(elementBean==null)
                refs.add(new XmlTypeRef(decl));
            else {
                // yikes!
                if(elementBean instanceof CClass)
                    refs.add(new CClassRef(decl,(CClass)elementBean));
                else
                    refs.add(new CElementInfoRef(decl,(CElementInfo)elementBean));
            }
        }
    }
 
Example #10
Source File: BIGlobalBinding.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #11
Source File: BIProperty.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void constantPropertyErrorCheck() {
    if( isConstantProperty!=null && getOwner()!=null ) {
        // run additional check on the isCOnstantProperty value.
        // this value is not allowed if the schema component doesn't have
        // a fixed value constraint.
        //
        // the setParent method associates a customization with the rest of
        // XSOM object graph, so this is the earliest possible moment where
        // we can test this.

        if( !hasFixedValue.find(getOwner()) ) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_ILLEGAL_FIXEDATTR.format()
            );
            // set this value to null to avoid the same error to be reported more than once.
            isConstantProperty = null;
        }
    }
}
 
Example #12
Source File: CClassInfo.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public CClassInfo(Model model,CClassInfoParent p, String shortName, Locator location, QName typeName, QName elementName, XSComponent source, CCustomizations customizations) {
    super(model,source,location,customizations);
    this.model = model;
    this.parent = p;
    this.shortName = model.allocator.assignClassName(parent,shortName);
    this.typeName = typeName;
    this.elementName = elementName;

    Language schemaLanguage = model.options.getSchemaLanguage();
    if ((schemaLanguage != null) &&
        (schemaLanguage.equals(Language.XMLSCHEMA) || schemaLanguage.equals(Language.WSDL))) {
        BIFactoryMethod factoryMethod = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIFactoryMethod.class);
        if(factoryMethod!=null) {
            factoryMethod.markAsAcknowledged();
            this.squeezedName = factoryMethod.name;
        }
    }

    model.add(this);
}
 
Example #13
Source File: CPropertyInfo.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected CPropertyInfo(String name, boolean collection, XSComponent source,
                        CCustomizations customizations, Locator locator) {
    this.publicName = name;
    String n = null;

    Model m = Ring.get(Model.class);
    if (m != null) {
        n = m.getNameConverter().toVariableName(name);
    } else {
        n = NameConverter.standard.toVariableName(name);
    }

    if(!JJavaName.isJavaIdentifier(n))
        n = '_'+n;  // avoid colliding with the reserved names like 'abstract'.
    this.privateName = n;

    this.isCollection = collection;
    this.locator = locator;
    if(customizations==null)
        this.customizations = CCustomizations.EMPTY;
    else
        this.customizations = customizations;
    this.source = source;
}
 
Example #14
Source File: RawTypeSetBuilder.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void elementDecl(XSElementDecl decl) {

        QName n = BGMBuilder.getName(decl);
        if(elementNames.add(n)) {
            CElement elementBean = Ring.get(ClassSelector.class).bindToType(decl,null);
            if(elementBean==null)
                refs.add(new XmlTypeRef(decl));
            else {
                // yikes!
                if(elementBean instanceof CClass)
                    refs.add(new CClassRef(decl,(CClass)elementBean));
                else
                    refs.add(new CElementInfoRef(decl,(CElementInfo)elementBean));
            }
        }
    }
 
Example #15
Source File: BGMBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all types that refer to the given complex type.
 */
public Set<XSComponent> getReferer(XSType c) {
    if(refFinder==null) {
        refFinder = new RefererFinder();
        refFinder.schemaSet(Ring.get(XSSchemaSet.class));
    }
    return refFinder.getReferer(c);
}
 
Example #16
Source File: BIGlobalBinding.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
JDefinedClass getClazz(ClassType t) {
    if (clazz != null) return clazz;
    try {
        JCodeModel codeModel = Ring.get(JCodeModel.class);
        clazz = codeModel._class(name, t);
        clazz.hide();
        return clazz;
    } catch (JClassAlreadyExistsException e) {
        return e.getExistingClass();
    }
}
 
Example #17
Source File: BIGlobalBinding.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
JDefinedClass getClazz(ClassType t) {
    if (clazz != null) return clazz;
    try {
        JCodeModel codeModel = Ring.get(JCodeModel.class);
        clazz = codeModel._class(name, t);
        clazz.hide();
        return clazz;
    } catch (JClassAlreadyExistsException e) {
        return e.getExistingClass();
    }
}
 
Example #18
Source File: ColorBinder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected final void createSimpleTypeProperty(XSSimpleType type,String propName) {
    BIProperty prop = BIProperty.getCustomization(type);

    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);
    // since we are building the simple type here, use buildDef
    CPropertyInfo p = prop.createValueProperty(propName,false,type,stb.buildDef(type),BGMBuilder.getName(type));
    getCurrentBean().addProperty(p);
}
 
Example #19
Source File: ClassSelector.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ClassSelector() {
    classBinder = new Abstractifier(new DefaultClassBinder());
    Ring.add(ClassBinder.class,classBinder);

    classScopes.push(null);  // so that the getClassFactory method returns null

    XSComplexType anyType = Ring.get(XSSchemaSet.class).getComplexType(WellKnownNamespace.XML_SCHEMA,"anyType");
    bindMap.put(anyType,new Binding(anyType,CBuiltinLeafInfo.ANYTYPE));
}
 
Example #20
Source File: BIInlineBinaryData.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the given component has {@link BIInlineBinaryData} customization,
 * reflect that to the specified property.
 */
public static void handle(XSComponent source, CPropertyInfo prop) {
    BIInlineBinaryData inline = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIInlineBinaryData.class);
    if(inline!=null) {
        prop.inlineBinaryData = true;
        inline.markAsAcknowledged();
    }
}
 
Example #21
Source File: BGMBuilder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** Fill-in the contents of each classes. */
private void buildContents() {
    ClassSelector cs = getClassSelector();
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);

    for( XSSchema s : Ring.get(XSSchemaSet.class).getSchemas() ) {
        BISchemaBinding sb = getBindInfo(s).get(BISchemaBinding.class);

        if(sb!=null && !sb.map) {
            sb.markAsAcknowledged();
            continue;       // no mapping for this package
        }

        getClassSelector().pushClassScope( new CClassInfoParent.Package(
            getClassSelector().getPackage(s.getTargetNamespace())) );

        checkMultipleSchemaBindings(s);
        processPackageJavadoc(s);
        populate(s.getAttGroupDecls(),s);
        populate(s.getAttributeDecls(),s);
        populate(s.getElementDecls(),s);
        populate(s.getModelGroupDecls(),s);

        // fill in typeUses
        for (XSType t : s.getTypes().values()) {
            stb.refererStack.push(t);
            model.typeUses().put( getName(t), cs.bindToType(t,s) );
            stb.refererStack.pop();
        }

        getClassSelector().popClassScope();
    }
}
 
Example #22
Source File: BIProperty.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public JType getBaseType() {
    if(baseType!=null && baseType.name!=null) {
        return TypeUtil.getType(getCodeModel(),
                baseType.name,
                Ring.get(ErrorReceiver.class),getLocation());
    }
    BIProperty next = getDefault();
    if(next!=null)  return next.getBaseType();
    else            return null;
}
 
Example #23
Source File: BIInlineBinaryData.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the given component has {@link BIInlineBinaryData} customization,
 * reflect that to the specified property.
 */
public static void handle(XSComponent source, CPropertyInfo prop) {
    BIInlineBinaryData inline = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIInlineBinaryData.class);
    if(inline!=null) {
        prop.inlineBinaryData = true;
        inline.markAsAcknowledged();
    }
}
 
Example #24
Source File: RawTypeSetBuilder.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public XmlTypeRef(XSElementDecl decl) {
    this.decl = decl;
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);
    stb.refererStack.push(decl);
    TypeUse r = Ring.get(ClassSelector.class).bindToType(decl.getType(),decl);
    stb.refererStack.pop();
    target = r;
}
 
Example #25
Source File: BIGlobalBinding.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void onSetOwner() {
    super.onSetOwner();
    // if one is given by options, use that
    NameConverter nc = Ring.get(Model.class).options.getNameConverter();
    if(nc!=null)
        nameConverter = nc;
}
 
Example #26
Source File: BIGlobalBinding.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
JDefinedClass getClazz(ClassType t) {
    if (clazz != null) return clazz;
    try {
        JCodeModel codeModel = Ring.get(JCodeModel.class);
        clazz = codeModel._class(name, t);
        clazz.hide();
        return clazz;
    } catch (JClassAlreadyExistsException e) {
        return e.getExistingClass();
    }
}
 
Example #27
Source File: ClassSelector.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ClassSelector() {
    classBinder = new Abstractifier(new DefaultClassBinder());
    Ring.add(ClassBinder.class,classBinder);

    classScopes.push(null);  // so that the getClassFactory method returns null

    XSComplexType anyType = Ring.get(XSSchemaSet.class).getComplexType(WellKnownNamespace.XML_SCHEMA,"anyType");
    bindMap.put(anyType,new Binding(anyType,CBuiltinLeafInfo.ANYTYPE));
}
 
Example #28
Source File: BIFactoryMethod.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * If the given component has {@link BIInlineBinaryData} customization,
 * reflect that to the specified property.
 */
public static void handle(XSComponent source, CPropertyInfo prop) {
    BIInlineBinaryData inline = Ring.get(BGMBuilder.class).getBindInfo(source).get(BIInlineBinaryData.class);
    if(inline!=null) {
        prop.inlineBinaryData = true;
        inline.markAsAcknowledged();
    }
}
 
Example #29
Source File: BGMBuilder.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Find all types that refer to the given complex type.
 */
public Set<XSComponent> getReferer(XSType c) {
    if(refFinder==null) {
        refFinder = new RefererFinder();
        refFinder.schemaSet(Ring.get(XSSchemaSet.class));
    }
    return refFinder.getReferer(c);
}
 
Example #30
Source File: BGMBuilder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Fill-in the contents of each classes. */
private void buildContents() {
    ClassSelector cs = getClassSelector();
    SimpleTypeBuilder stb = Ring.get(SimpleTypeBuilder.class);

    for( XSSchema s : Ring.get(XSSchemaSet.class).getSchemas() ) {
        BISchemaBinding sb = getBindInfo(s).get(BISchemaBinding.class);

        if(sb!=null && !sb.map) {
            sb.markAsAcknowledged();
            continue;       // no mapping for this package
        }

        getClassSelector().pushClassScope( new CClassInfoParent.Package(
            getClassSelector().getPackage(s.getTargetNamespace())) );

        checkMultipleSchemaBindings(s);
        processPackageJavadoc(s);
        populate(s.getAttGroupDecls(),s);
        populate(s.getAttributeDecls(),s);
        populate(s.getElementDecls(),s);
        populate(s.getModelGroupDecls(),s);

        // fill in typeUses
        for (XSType t : s.getTypes().values()) {
            stb.refererStack.push(t);
            model.typeUses().put( getName(t), cs.bindToType(t,s) );
            stb.refererStack.pop();
        }

        getClassSelector().popClassScope();
    }
}