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

The following examples show how to use com.sun.tools.internal.xjc.model.CElementInfo. 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: ObjectFactoryGeneratorImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * return a JFieldVar that represents the QName field for the given information.
 *
 * if it doesn't exist, create a static field in the class and store a new JFieldVar.
 */
private JExpression getQNameInvocation(CElementInfo ei) {
    QName name = ei.getElementName();
    if(qnameMap.containsKey(name)) {
        return qnameMap.get(name);
    }

    if(qnameMap.size()>1024)
        // stop gap measure to avoid 'code too large' error in javac.
        return createQName(name);

    // [RESULT]
    // private static final QName _XYZ_NAME = new QName("uri", "local");
    JFieldVar qnameField = objectFactory.field(
        JMod.PRIVATE | JMod.STATIC | JMod.FINAL,
        QName.class,
        '_' + ei.getSqueezedName() + "_QNAME", createQName(name));

    qnameMap.put(name, qnameField);

    return qnameField;
}
 
Example #2
Source File: RawTypeSetBuilder.java    From openjdk-8 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: ObjectFactoryGeneratorImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * return a JFieldVar that represents the QName field for the given information.
 *
 * if it doesn't exist, create a static field in the class and store a new JFieldVar.
 */
private JExpression getQNameInvocation(CElementInfo ei) {
    QName name = ei.getElementName();
    if(qnameMap.containsKey(name)) {
        return qnameMap.get(name);
    }

    if(qnameMap.size()>1024)
        // stop gap measure to avoid 'code too large' error in javac.
        return createQName(name);

    // [RESULT]
    // private static final QName _XYZ_NAME = new QName("uri", "local");
    JFieldVar qnameField = objectFactory.field(
        JMod.PRIVATE | JMod.STATIC | JMod.FINAL,
        QName.class,
        '_' + ei.getSqueezedName() + "_QNAME", createQName(name));

    qnameMap.put(name, qnameField);

    return qnameField;
}
 
Example #4
Source File: RawTypeSetBuilder.java    From openjdk-jdk8u-backup 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: RawTypeSetBuilder.java    From TencentKona-8 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 #6
Source File: ObjectFactoryGeneratorImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * return a JFieldVar that represents the QName field for the given information.
 *
 * if it doesn't exist, create a static field in the class and store a new JFieldVar.
 */
private JExpression getQNameInvocation(CElementInfo ei) {
    QName name = ei.getElementName();
    if(qnameMap.containsKey(name)) {
        return qnameMap.get(name);
    }

    if(qnameMap.size()>1024)
        // stop gap measure to avoid 'code too large' error in javac.
        return createQName(name);

    // [RESULT]
    // private static final QName _XYZ_NAME = new QName("uri", "local");
    JFieldVar qnameField = objectFactory.field(
        JMod.PRIVATE | JMod.STATIC | JMod.FINAL,
        QName.class,
        '_' + ei.getSqueezedName() + "_QNAME", createQName(name));

    qnameMap.put(name, qnameField);

    return qnameField;
}
 
Example #7
Source File: ObjectFactoryGeneratorImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * return a JFieldVar that represents the QName field for the given information.
 *
 * if it doesn't exist, create a static field in the class and store a new JFieldVar.
 */
private JExpression getQNameInvocation(CElementInfo ei) {
    QName name = ei.getElementName();
    if(qnameMap.containsKey(name)) {
        return qnameMap.get(name);
    }

    if(qnameMap.size()>1024)
        // stop gap measure to avoid 'code too large' error in javac.
        return createQName(name);

    // [RESULT]
    // private static final QName _XYZ_NAME = new QName("uri", "local");
    JFieldVar qnameField = objectFactory.field(
        JMod.PRIVATE | JMod.STATIC | JMod.FINAL,
        QName.class,
        '_' + ei.getSqueezedName() + "_QNAME", createQName(name));

    qnameMap.put(name, qnameField);

    return qnameField;
}
 
Example #8
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 #9
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 #10
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 #11
Source File: ObjectFactoryGeneratorImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * return a JFieldVar that represents the QName field for the given information.
 *
 * if it doesn't exist, create a static field in the class and store a new JFieldVar.
 */
private JExpression getQNameInvocation(CElementInfo ei) {
    QName name = ei.getElementName();
    if(qnameMap.containsKey(name)) {
        return qnameMap.get(name);
    }

    if(qnameMap.size()>1024)
        // stop gap measure to avoid 'code too large' error in javac.
        return createQName(name);

    // [RESULT]
    // private static final QName _XYZ_NAME = new QName("uri", "local");
    JFieldVar qnameField = objectFactory.field(
        JMod.PRIVATE | JMod.STATIC | JMod.FINAL,
        QName.class,
        '_' + ei.getSqueezedName() + "_QNAME", createQName(name));

    qnameMap.put(name, qnameField);

    return qnameField;
}
 
Example #12
Source File: RawTypeSetBuilder.java    From openjdk-jdk9 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 #13
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 #14
Source File: BeanGenerator.java    From hottub 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 #15
Source File: RawTypeSetBuilder.java    From hottub 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 #16
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 #17
Source File: ElementOutlineImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
ElementOutlineImpl(BeanGenerator parent, CElementInfo ei) {
    super(ei,
          parent.getClassFactory().createClass(
                  parent.getContainer( ei.parent, Aspect.EXPOSED ), ei.shortName(), ei.getLocator() ));
    this.parent = parent;
    parent.elements.put(ei,this);

    JCodeModel cm = parent.getCodeModel();

    implClass._extends(
        cm.ref(JAXBElement.class).narrow(
            target.getContentInMemoryType().toType(parent,Aspect.EXPOSED).boxify()));

    if(ei.hasClass()) {
        JType implType = ei.getContentInMemoryType().toType(parent,Aspect.IMPLEMENTATION);
        JExpression declaredType = JExpr.cast(cm.ref(Class.class),implType.boxify().dotclass()); // why do we have to cast?
        JClass scope=null;
        if(ei.getScope()!=null)
            scope = parent.getClazz(ei.getScope()).implRef;
        JExpression scopeClass = scope==null?JExpr._null():scope.dotclass();
        JFieldVar valField = implClass.field(JMod.PROTECTED|JMod.FINAL|JMod.STATIC,QName.class,"NAME",createQName(cm,ei.getElementName()));

        // take this opportunity to generate a constructor in the element class
        JMethod cons = implClass.constructor(JMod.PUBLIC);
        cons.body().invoke("super")
            .arg(valField)
            .arg(declaredType)
            .arg(scopeClass)
            .arg(cons.param(implType,"value"));

        // generate no-arg constructor in the element class (bug #391; section 5.6.2 in JAXB spec 2.1)
        JMethod noArgCons = implClass.constructor(JMod.PUBLIC);
        noArgCons.body().invoke("super")
            .arg(valField)
            .arg(declaredType)
            .arg(scopeClass)
            .arg(JExpr._null());

    }
}
 
Example #18
Source File: PropertyImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** Returns raw schema name for simpleType property. May return null for other types. */
public final QName rawName() {
    if (fr instanceof ElementAdapter) {
        CElementInfo eInfo = ((ElementAdapter)fr).ei;
        if ((eInfo != null) && (eInfo.getProperty() != null)) {
            return eInfo.getProperty().getTypes().get(0).getTypeName();
        }
    }
    return null;
}
 
Example #19
Source File: ElementOutlineImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
ElementOutlineImpl(BeanGenerator parent, CElementInfo ei) {
    super(ei,
          parent.getClassFactory().createClass(
                  parent.getContainer( ei.parent, Aspect.EXPOSED ), ei.shortName(), ei.getLocator() ));
    this.parent = parent;
    parent.elements.put(ei,this);

    JCodeModel cm = parent.getCodeModel();

    implClass._extends(
        cm.ref(JAXBElement.class).narrow(
            target.getContentInMemoryType().toType(parent,Aspect.EXPOSED).boxify()));

    if(ei.hasClass()) {
        JType implType = ei.getContentInMemoryType().toType(parent,Aspect.IMPLEMENTATION);
        JExpression declaredType = JExpr.cast(cm.ref(Class.class),implType.boxify().dotclass()); // why do we have to cast?
        JClass scope=null;
        if(ei.getScope()!=null)
            scope = parent.getClazz(ei.getScope()).implRef;
        JExpression scopeClass = scope==null?JExpr._null():scope.dotclass();
        JFieldVar valField = implClass.field(JMod.PROTECTED|JMod.FINAL|JMod.STATIC,QName.class,"NAME",createQName(cm,ei.getElementName()));

        // take this opportunity to generate a constructor in the element class
        JMethod cons = implClass.constructor(JMod.PUBLIC);
        cons.body().invoke("super")
            .arg(valField)
            .arg(declaredType)
            .arg(scopeClass)
            .arg(cons.param(implType,"value"));

        // generate no-arg constructor in the element class (bug #391; section 5.6.2 in JAXB spec 2.1)
        JMethod noArgCons = implClass.constructor(JMod.PUBLIC);
        noArgCons.body().invoke("super")
            .arg(valField)
            .arg(declaredType)
            .arg(scopeClass)
            .arg(JExpr._null());

    }
}
 
Example #20
Source File: PropertyImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** Returns raw schema name for simpleType property. May return null for other types. */
public final QName rawName() {
    if (fr instanceof ElementAdapter) {
        CElementInfo eInfo = ((ElementAdapter)fr).ei;
        if ((eInfo != null) && (eInfo.getProperty() != null)) {
            return eInfo.getProperty().getTypes().get(0).getTypeName();
        }
    }
    return null;
}
 
Example #21
Source File: JAXBModelImpl.java    From openjdk-jdk8u 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 #22
Source File: ClassSelector.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks if the given component is bound to a class.
 */
public final CElement isBound( XSElementDecl x, XSComponent referer ) {
    CElementInfo r = boundElements.get(x);
    if(r!=null)
        return r;
    return bindToType(x,referer);
}
 
Example #23
Source File: PropertyImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** Returns raw schema name for simpleType property. May return null for other types. */
public final QName rawName() {
    if (fr instanceof ElementAdapter) {
        CElementInfo eInfo = ((ElementAdapter)fr).ei;
        if ((eInfo != null) && (eInfo.getProperty() != null)) {
            return eInfo.getProperty().getTypes().get(0).getTypeName();
        }
    }
    return null;
}
 
Example #24
Source File: PropertyImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** Returns raw schema name for simpleType property. May return null for other types. */
public final QName rawName() {
    if (fr instanceof ElementAdapter) {
        CElementInfo eInfo = ((ElementAdapter)fr).ei;
        if ((eInfo != null) && (eInfo.getProperty() != null)) {
            return eInfo.getProperty().getTypes().get(0).getTypeName();
        }
    }
    return null;
}
 
Example #25
Source File: BeanGenerator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ElementOutlineImpl getElement(CElementInfo ei) {
    ElementOutlineImpl def = elements.get(ei);
    if (def == null && ei.hasClass()) {
        // create one. in the constructor it adds itself to the elements.
        def = new ElementOutlineImpl(this, ei);
    }
    return def;
}
 
Example #26
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 #27
Source File: PropertyImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** Returns raw schema name for simpleType property. May return null for other types. */
public final QName rawName() {
    if (fr instanceof ElementAdapter) {
        CElementInfo eInfo = ((ElementAdapter)fr).ei;
        if ((eInfo != null) && (eInfo.getProperty() != null)) {
            return eInfo.getProperty().getTypes().get(0).getTypeName();
        }
    }
    return null;
}
 
Example #28
Source File: PropertyImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** Returns raw schema name for simpleType property. May return null for other types. */
public final QName rawName() {
    if (fr instanceof ElementAdapter) {
        CElementInfo eInfo = ((ElementAdapter)fr).ei;
        if ((eInfo != null) && (eInfo.getProperty() != null)) {
            return eInfo.getProperty().getTypes().get(0).getTypeName();
        }
    }
    return null;
}
 
Example #29
Source File: ElementOutlineImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
ElementOutlineImpl(BeanGenerator parent, CElementInfo ei) {
    super(ei,
          parent.getClassFactory().createClass(
                  parent.getContainer( ei.parent, Aspect.EXPOSED ), ei.shortName(), ei.getLocator() ));
    this.parent = parent;
    parent.elements.put(ei,this);

    JCodeModel cm = parent.getCodeModel();

    implClass._extends(
        cm.ref(JAXBElement.class).narrow(
            target.getContentInMemoryType().toType(parent,Aspect.EXPOSED).boxify()));

    if(ei.hasClass()) {
        JType implType = ei.getContentInMemoryType().toType(parent,Aspect.IMPLEMENTATION);
        JExpression declaredType = JExpr.cast(cm.ref(Class.class),implType.boxify().dotclass()); // why do we have to cast?
        JClass scope=null;
        if(ei.getScope()!=null)
            scope = parent.getClazz(ei.getScope()).implRef;
        JExpression scopeClass = scope==null?JExpr._null():scope.dotclass();
        JFieldVar valField = implClass.field(JMod.PROTECTED|JMod.FINAL|JMod.STATIC,QName.class,"NAME",createQName(cm,ei.getElementName()));

        // take this opportunity to generate a constructor in the element class
        JMethod cons = implClass.constructor(JMod.PUBLIC);
        cons.body().invoke("super")
            .arg(valField)
            .arg(declaredType)
            .arg(scopeClass)
            .arg(cons.param(implType,"value"));

        // generate no-arg constructor in the element class (bug #391; section 5.6.2 in JAXB spec 2.1)
        JMethod noArgCons = implClass.constructor(JMod.PUBLIC);
        noArgCons.body().invoke("super")
            .arg(valField)
            .arg(declaredType)
            .arg(scopeClass)
            .arg(JExpr._null());

    }
}
 
Example #30
Source File: BeanGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ElementOutlineImpl getElement(CElementInfo ei) {
    ElementOutlineImpl def = elements.get(ei);
    if (def == null && ei.hasClass()) {
        // create one. in the constructor it adds itself to the elements.
        def = new ElementOutlineImpl(this, ei);
    }
    return def;
}