com.sun.tools.internal.xjc.model.CClassInfo Java Examples

The following examples show how to use com.sun.tools.internal.xjc.model.CClassInfo. 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: Element.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private CClassInfo calcClass() {
    BIElement e = owner.bindInfo.element(name);
    if(e==null) {
        if(contentModelType!=DTDEventListener.CONTENT_MODEL_MIXED
        || !attributes.isEmpty()
        || mustBeClass)
            return createDefaultClass();
        if(contentModel!=Term.EMPTY) {
            throw new UnsupportedOperationException("mixed content model not supported");
        } else {
            // just #PCDATA
            if(isReferenced)
                return null;
            else
                // if no one else is referencing, assumed to be the root.
                return createDefaultClass();
        }
    } else {
        return e.clazz;
    }
}
 
Example #2
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 #3
Source File: Element.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private CClassInfo calcClass() {
    BIElement e = owner.bindInfo.element(name);
    if(e==null) {
        if(contentModelType!=DTDEventListener.CONTENT_MODEL_MIXED
        || !attributes.isEmpty()
        || mustBeClass)
            return createDefaultClass();
        if(contentModel!=Term.EMPTY) {
            throw new UnsupportedOperationException("mixed content model not supported");
        } else {
            // just #PCDATA
            if(isReferenced)
                return null;
            else
                // if no one else is referencing, assumed to be the root.
                return createDefaultClass();
        }
    } else {
        return e.clazz;
    }
}
 
Example #4
Source File: RELAXNGCompiler.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void mapToClass(DElementPattern p) {
    NameClass nc = p.getName();
    if(nc.isOpen())
        return;   // infinite name. can't map to a class.

    Set<QName> names = nc.listNames();

    CClassInfo[] types = new CClassInfo[names.size()];
    int i=0;
    for( QName n : names ) {
        // TODO: read class names from customization
        String name = model.getNameConverter().toClassName(n.getLocalPart());

        bindQueue.put(
            types[i++] = new CClassInfo(model,pkg,name,p.getLocation(),null,n,null,null/*TODO*/),
            p.getChild() );
    }

    classes.put(p,types);
}
 
Example #5
Source File: AbstractMappingImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private boolean containingChoice(CClassInfo typeBean) {
    XSComponent component = typeBean.getSchemaComponent();
    if (component instanceof XSComplexType) {
        XSContentType contentType = ((XSComplexType) component).getContentType();
        XSParticle particle = contentType.asParticle();
        if (particle != null) {
            XSTerm term = particle.getTerm();
            XSModelGroup modelGroup = term.asModelGroup();
            if (modelGroup != null) {
                return (modelGroup.getCompositor() == XSModelGroup.Compositor.CHOICE);
            }
        }
    }

    return false;
}
 
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: AbstractMappingImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private boolean containingChoice(CClassInfo typeBean) {
    XSComponent component = typeBean.getSchemaComponent();
    if (component instanceof XSComplexType) {
        XSContentType contentType = ((XSComplexType) component).getContentType();
        XSParticle particle = contentType.asParticle();
        if (particle != null) {
            XSTerm term = particle.getTerm();
            XSModelGroup modelGroup = term.asModelGroup();
            if (modelGroup != null) {
                return (modelGroup.getCompositor() == XSModelGroup.Compositor.CHOICE);
            }
        }
    }

    return false;
}
 
Example #8
Source File: BeanGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
 
Example #9
Source File: BeanGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Generates the minimum {@link JDefinedClass} skeleton
 * without filling in its body.
 */
private ClassOutlineImpl generateClassDef(CClassInfo bean) {
    ImplStructureStrategy.Result r = model.strategy.createClasses(this, bean);
    JClass implRef;

    if (bean.getUserSpecifiedImplClass() != null) {
        // create a place holder for a user-specified class.
        JDefinedClass usr;
        try {
            usr = codeModel._class(bean.getUserSpecifiedImplClass());
            // but hide that file so that it won't be generated.
            usr.hide();
        } catch (JClassAlreadyExistsException e) {
            // it's OK for this to collide.
            usr = e.getExistingClass();
        }
        usr._extends(r.implementation);
        implRef = usr;
    } else {
        implRef = r.implementation;
    }

    return new ClassOutlineImpl(this, bean, r.exposed, r.implementation, implRef);
}
 
Example #10
Source File: BeanGenerator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns all <i>used</i> JPackages.
 *
 * A JPackage is considered as "used" if a ClassItem or
 * a InterfaceItem resides in that package.
 *
 * This value is dynamically calculated every time because
 * one can freely remove ClassItem/InterfaceItem.
 *
 * @return
 *         Given the same input, the order of packages in the array
 *         is always the same regardless of the environment.
 */
public final JPackage[] getUsedPackages(Aspect aspect) {
    Set<JPackage> s = new TreeSet<JPackage>();

    for (CClassInfo bean : model.beans().values()) {
        JClassContainer cont = getContainer(bean.parent(), aspect);
        if (cont.isPackage()) {
            s.add((JPackage) cont);
        }
    }

    for (CElementInfo e : model.getElementMappings(null).values()) {
        // at the first glance you might think we should be iterating all elements,
        // not just global ones, but if you think about it, local ones live inside
        // another class, so those packages are already enumerated when we were
        // walking over CClassInfos.
        s.add(e._package());
    }

    return s.toArray(new JPackage[s.size()]);
}
 
Example #11
Source File: RELAXNGCompiler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
private void mapToClass(DElementPattern p) {
    NameClass nc = p.getName();
    if(nc.isOpen())
        return;   // infinite name. can't map to a class.

    Set<QName> names = nc.listNames();

    CClassInfo[] types = new CClassInfo[names.size()];
    int i=0;
    for( QName n : names ) {
        // TODO: read class names from customization
        String name = model.getNameConverter().toClassName(n.getLocalPart());

        bindQueue.put(
            types[i++] = new CClassInfo(model,pkg,name,p.getLocation(),null,n,null,null/*TODO*/),
            p.getChild() );
    }

    classes.put(p,types);
}
 
Example #12
Source File: Element.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private CClassInfo calcClass() {
    BIElement e = owner.bindInfo.element(name);
    if(e==null) {
        if(contentModelType!=DTDEventListener.CONTENT_MODEL_MIXED
        || !attributes.isEmpty()
        || mustBeClass)
            return createDefaultClass();
        if(contentModel!=Term.EMPTY) {
            throw new UnsupportedOperationException("mixed content model not supported");
        } else {
            // just #PCDATA
            if(isReferenced)
                return null;
            else
                // if no one else is referencing, assumed to be the root.
                return createDefaultClass();
        }
    } else {
        return e.clazz;
    }
}
 
Example #13
Source File: DefaultClassBinder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
     * Makes sure that the component doesn't carry a {@link BIClass}
     * customization.
     *
     * @return
     *      return value is unused. Since most of the caller needs to
     *      return null, to make the code a little bit shorter, this
     *      method always return null (so that the caller can always
     *      say <code>return never(sc);</code>.
     */
    private CClassInfo never() {
        // all we need to do here is just not to acknowledge
        // any class customization. Then this class customization
        // will be reported as an error later when we check all
        // unacknowledged customizations.


//        BIDeclaration cust=owner.getBindInfo(component).get(BIClass.NAME);
//        if(cust!=null) {
//            // error
//            owner.errorReporter.error(
//                cust.getLocation(),
//                "test {0}", NameGetter.get(component) );
//        }
        return null;
    }
 
Example #14
Source File: RawTypeSetBuilder.java    From openjdk-8-source 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 #15
Source File: DefaultClassBinder.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
     * Makes sure that the component doesn't carry a {@link BIClass}
     * customization.
     *
     * @return
     *      return value is unused. Since most of the caller needs to
     *      return null, to make the code a little bit shorter, this
     *      method always return null (so that the caller can always
     *      say <code>return never(sc);</code>.
     */
    private CClassInfo never() {
        // all we need to do here is just not to acknowledge
        // any class customization. Then this class customization
        // will be reported as an error later when we check all
        // unacknowledged customizations.


//        BIDeclaration cust=owner.getBindInfo(component).get(BIClass.NAME);
//        if(cust!=null) {
//            // error
//            owner.errorReporter.error(
//                cust.getLocation(),
//                "test {0}", NameGetter.get(component) );
//        }
        return null;
    }
 
Example #16
Source File: RELAXNGCompiler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private void compile() {
    // decide which patterns to map to classes
    promoteElementDefsToClasses();
    promoteTypeSafeEnums();
    // TODO: promote patterns with <jaxb:class> to classes
    // TODO: promote 'type' patterns to classes
    promoteTypePatternsToClasses();

    for (Map.Entry<CClassInfo,DPattern> e : bindQueue.entrySet())
        bindContentModel(e.getKey(),e.getValue());
}
 
Example #17
Source File: BeanGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public ClassOutlineImpl getClazz(CClassInfo bean) {
    ClassOutlineImpl r = classes.get(bean);
    if (r == null) {
        classes.put(bean, r = generateClassDef(bean));
    }
    return r;
}
 
Example #18
Source File: JAXBModelImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
JAXBModelImpl(Outline outline) {
    this.model = outline.getModel();
    this.outline = outline;

    for (CClassInfo ci : model.beans().values()) {
        if(!ci.isElement())
            continue;
        byXmlName.put(ci.getElementName(),new BeanMappingImpl(this,ci));
    }
    for (CElementInfo ei : model.getElementMappings(null).values()) {
        byXmlName.put(ei.getElementName(),new ElementMappingImpl(this,ei));
    }
}
 
Example #19
Source File: RELAXNGCompiler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void compile() {
    // decide which patterns to map to classes
    promoteElementDefsToClasses();
    promoteTypeSafeEnums();
    // TODO: promote patterns with <jaxb:class> to classes
    // TODO: promote 'type' patterns to classes
    promoteTypePatternsToClasses();

    for (Map.Entry<CClassInfo,DPattern> e : bindQueue.entrySet())
        bindContentModel(e.getKey(),e.getValue());
}
 
Example #20
Source File: ElementMappingImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public final List<Property> calcDrilldown() {
    CElementPropertyInfo p = clazz.getProperty();

    if(p.getAdapter()!=null)
        return null;    // if adapted, avoid drill down

    if(p.isCollection())
    // things like <xs:element name="foo" type="xs:NMTOKENS" /> is not eligible.
        return null;

    CTypeInfo typeClass = p.ref().get(0);

    if(!(typeClass instanceof CClassInfo))
        // things like <xs:element name="foo" type="xs:string" /> is not eligible.
        return null;

    CClassInfo ci = (CClassInfo)typeClass;

    // if the type is abstract we can't use it.
    if(ci.isAbstract())
        return null;

    // the 'all' compositor doesn't qualify
    if(!ci.isOrdered())
        return null;

    return buildDrilldown(ci);
}
 
Example #21
Source File: ElementMappingImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public final List<Property> calcDrilldown() {
    CElementPropertyInfo p = clazz.getProperty();

    if(p.getAdapter()!=null)
        return null;    // if adapted, avoid drill down

    if(p.isCollection())
    // things like <xs:element name="foo" type="xs:NMTOKENS" /> is not eligible.
        return null;

    CTypeInfo typeClass = p.ref().get(0);

    if(!(typeClass instanceof CClassInfo))
        // things like <xs:element name="foo" type="xs:string" /> is not eligible.
        return null;

    CClassInfo ci = (CClassInfo)typeClass;

    // if the type is abstract we can't use it.
    if(ci.isAbstract())
        return null;

    // the 'all' compositor doesn't qualify
    if(!ci.isOrdered())
        return null;

    return buildDrilldown(ci);
}
 
Example #22
Source File: DefaultParticleBinder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private Checker checkCollision( XSParticle p, Collection<XSParticle> forcedProps ) {
    // scan the tree by a checker.
    Checker checker = new Checker(forcedProps);

    CClassInfo superClass = getCurrentBean().getBaseClass();

    if(superClass!=null)
        checker.readSuperClass(superClass);
    checker.particle(p);

    return checker;
}
 
Example #23
Source File: Element.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return null if this class is not bound to a class.
 */
CClassInfo getClassInfo() {
    if(!classInfoComputed) {
        classInfoComputed = true;
        classInfo = calcClass();
    }
    return classInfo;
}
 
Example #24
Source File: Element.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return null if this class is not bound to a class.
 */
CClassInfo getClassInfo() {
    if(!classInfoComputed) {
        classInfoComputed = true;
        classInfo = calcClass();
    }
    return classInfo;
}
 
Example #25
Source File: ElementMappingImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public final List<Property> calcDrilldown() {
    CElementPropertyInfo p = clazz.getProperty();

    if(p.getAdapter()!=null)
        return null;    // if adapted, avoid drill down

    if(p.isCollection())
    // things like <xs:element name="foo" type="xs:NMTOKENS" /> is not eligible.
        return null;

    CTypeInfo typeClass = p.ref().get(0);

    if(!(typeClass instanceof CClassInfo))
        // things like <xs:element name="foo" type="xs:string" /> is not eligible.
        return null;

    CClassInfo ci = (CClassInfo)typeClass;

    // if the type is abstract we can't use it.
    if(ci.isAbstract())
        return null;

    // the 'all' compositor doesn't qualify
    if(!ci.isOrdered())
        return null;

    return buildDrilldown(ci);
}
 
Example #26
Source File: RELAXNGCompiler.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void compile() {
    // decide which patterns to map to classes
    promoteElementDefsToClasses();
    promoteTypeSafeEnums();
    // TODO: promote patterns with <jaxb:class> to classes
    // TODO: promote 'type' patterns to classes
    promoteTypePatternsToClasses();

    for (Map.Entry<CClassInfo,DPattern> e : bindQueue.entrySet())
        bindContentModel(e.getKey(),e.getValue());
}
 
Example #27
Source File: ElementMappingImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public final List<Property> calcDrilldown() {
    CElementPropertyInfo p = clazz.getProperty();

    if(p.getAdapter()!=null)
        return null;    // if adapted, avoid drill down

    if(p.isCollection())
    // things like <xs:element name="foo" type="xs:NMTOKENS" /> is not eligible.
        return null;

    CTypeInfo typeClass = p.ref().get(0);

    if(!(typeClass instanceof CClassInfo))
        // things like <xs:element name="foo" type="xs:string" /> is not eligible.
        return null;

    CClassInfo ci = (CClassInfo)typeClass;

    // if the type is abstract we can't use it.
    if(ci.isAbstract())
        return null;

    // the 'all' compositor doesn't qualify
    if(!ci.isOrdered())
        return null;

    return buildDrilldown(ci);
}
 
Example #28
Source File: JAXBModelImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
JAXBModelImpl(Outline outline) {
    this.model = outline.getModel();
    this.outline = outline;

    for (CClassInfo ci : model.beans().values()) {
        if(!ci.isElement())
            continue;
        byXmlName.put(ci.getElementName(),new BeanMappingImpl(this,ci));
    }
    for (CElementInfo ei : model.getElementMappings(null).values()) {
        byXmlName.put(ei.getElementName(),new ElementMappingImpl(this,ei));
    }
}
 
Example #29
Source File: Element.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return null if this class is not bound to a class.
 */
CClassInfo getClassInfo() {
    if(!classInfoComputed) {
        classInfoComputed = true;
        classInfo = calcClass();
    }
    return classInfo;
}
 
Example #30
Source File: ClassSelector.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private void append(CClassInfo bean, String doc) {
    if(bean.javadoc==null)
        bean.javadoc = doc+'\n';
    else
        bean.javadoc += '\n'+doc+'\n';
}