Package com.sun.xml.internal.bind.v2.schemagen.xmlschema

Examples of com.sun.xml.internal.bind.v2.schemagen.xmlschema.Occurs


            typeInfo = param.getTypeInfo();
        } else {
            if (typeInfo.getWrapperType() != null) typeInfo = param.getTypeInfo();
            else repeatedElement = true;
        }
        Occurs child = addChild(sq, param.getName(), typeInfo);
        if (repeatedElement && child != null) {
            child.maxOccurs("unbounded");
        }
    }
View Full Code Here


         * @param ep the element property
         * @param compositor the schema compositor (sequence or all)
         */
        private void handleElementProp(ElementPropertyInfo<T,C> ep, ExplicitGroup compositor) {
            QName ename = ep.getXmlName();
            Occurs occurs = null;

            if (ep.isValueList()) {
                TypeRef<T,C> t = ep.getTypes().get(0);
                LocalElement e = compositor.element();

                QName tn = t.getTagName();
                e.name(tn.getLocalPart());
                List lst = e.simpleType().list();
                writeTypeRef(lst,t, "itemType");
                elementFormDefault.writeForm(e,tn);
                return;
            }

            if (ep.isCollection()) {
                if (ename != null) { // wrapped collection
                    LocalElement e = compositor.element();
                    if(ename.getNamespaceURI().length()>0) {
                        if (!ename.getNamespaceURI().equals(this.uri)) {
                            // TODO: we need to generate the corresponding element declaration for this
                            // table 8-25: Property/field element wrapper with ref attribute
                            e.ref(new QName(ename.getNamespaceURI(), ename.getLocalPart()));
                            return;
                        }
                    }
                    elementFormDefault.writeForm(e,ename);

                    ComplexType p = e.name(ename.getLocalPart()).complexType();
                    if(ep.isCollectionNillable()) {
                        e.nillable(true);
                    } else {
                        e.minOccurs(0);
                    }
                    if (ep.getTypes().size() == 1) {
                        compositor = p.sequence();
                    } else {
                        compositor = p.choice();
                        occurs = compositor;
                    }
                } else { // unwrapped collection
                    if (ep.getTypes().size() > 1) {
                        compositor = compositor.choice();
                        occurs = compositor;
                    }
                }
            } else {
                if (ep.getTypes().size() > 1) {
                    compositor = compositor.choice();
                    occurs = compositor;
                }
            }


            // fill in the content model
            for (TypeRef<T,C> t : ep.getTypes()) {
                LocalElement e = compositor.element();
                if (occurs == null) occurs = e;
                QName tn = t.getTagName();

                if(canBeDirectElementRef(t,tn) || (!tn.getNamespaceURI().equals(uri) && tn.getNamespaceURI().length()>0)) {
                    e.ref(tn);
                } else {
                    e.name(tn.getLocalPart());
                    writeTypeRef(e,t, "type");
                    elementFormDefault.writeForm(e,tn);
                }

                if (t.isNillable()) {
                    e.nillable(true);
                }
                if(t.getDefaultValue()!=null)
                    e._default(t.getDefaultValue());
            }

            if (ep.isCollection())
                occurs.maxOccurs("unbounded");

            if (!ep.isRequired())
                // see Spec table 8-13
                occurs.minOccurs(0);
            // else minOccurs defaults to 1
        }
View Full Code Here

         * @param rp
         * @param compositor
         */
        private void handleReferenceProp(ReferencePropertyInfo<T,C> rp, ExplicitGroup compositor) {
            QName ename = rp.getXmlName();
            Occurs occurs = null;

            if (rp.isCollection()) {
                if (ename != null) { // wrapped collection
                    LocalElement e = compositor.element();
                    ComplexType p = e.name(ename.getLocalPart()).complexType();
                    elementFormDefault.writeForm(e,ename);
                    if(rp.isCollectionNillable())
                        e.nillable(true);
                    if (rp.getElements().size() == 1) {
                        compositor = p.sequence();
                    } else {
                        compositor = p.choice();
                        occurs = compositor;
                    }
                } else { // unwrapped collection
                    if (rp.getElements().size() > 1) {
                        compositor = compositor.choice();
                        occurs = compositor;
                    }
                }
            }

            // fill in content model
            TODO.checkSpec("should we loop in the case of a non-collection ep?");
            for (Element<T,C> e : rp.getElements()) {
                LocalElement eref = compositor.element();
                if (occurs == null) occurs = eref;

                QName en = e.getElementName();
                if(e.getScope()!=null) {
                    // scoped. needs to be inlined
                    boolean qualified = en.getNamespaceURI().equals(uri);
                    boolean unqualified = en.getNamespaceURI().equals("");
                    if(qualified || unqualified) {
                        // can be inlined indeed

                        // write form="..." if necessary
                        if(unqualified) {
                            if(elementFormDefault.isEffectivelyQualified)
                                eref.form("unqualified");
                        } else {
                            if(!elementFormDefault.isEffectivelyQualified)
                                eref.form("qualified");
                        }

                        eref.name(en.getLocalPart());

                        // write out type reference
                        if(e instanceof ClassInfo) {
                            writeTypeRef(eref,(ClassInfo<T,C>)e,"type");
                        } else {
                            writeTypeRef(eref,((ElementInfo<T,C>)e).getContentType(),"type");
                        }
                        continue;
                    }
                }
                eref.ref(en);
            }

            WildcardMode wc = rp.getWildcard();
            if( wc != null ) {
                Any any = compositor.any();
                final String pcmode = getProcessContentsModeName(wc);
                if( pcmode != null ) any.processContents(pcmode);
                TODO.schemaGenerator("generate @namespace ???");
                if( occurs == null ) occurs = any;
            }

            if(rp.isCollection())
                occurs.maxOccurs("unbounded");

        }
View Full Code Here

        return addGenericElement(parent.owner.getElementInfo(parent.getClazz(),new QName(nsUri,r.name())));
    }

    private boolean addGenericElement(XmlElementRef r, ReferencePropertyInfoImpl<T,C,F,M> info) {
        String nsUri = info.getEffectiveNamespaceFor(r);
        ElementInfo ei = parent.owner.getElementInfo(info.parent.getClazz(), new QName(nsUri, r.name()));
        types.add(ei);
        return true;
    }
View Full Code Here

        boolean nillable = false; // default value

        QName name = elem.getElementName();
        Namespace n = getNamespace(name.getNamespaceURI());
        ElementInfo ei;

        if (elem.getScope() != null) { // (probably) never happens
            ei = this.types.getElementInfo(elem.getScope().getClazz(), name);
        } else {
            ei = this.types.getElementInfo(null, name);
        }

        XmlElement xmlElem = ei.getProperty().readAnnotation(XmlElement.class);

        if (xmlElem == null) {
            nillable = false;
        } else {
            nillable = xmlElem.nillable();
View Full Code Here

     * TODO: this is not the proper place for this class to be in.
     */
    public static Transducer createTransducer(RuntimeNonElementRef ref) {
        Transducer t = ref.getTarget().getTransducer();
        RuntimePropertyInfo src = ref.getSource();
        ID id = src.id();

        if(id==ID.IDREF)
            return RuntimeBuiltinLeafInfoImpl.STRING;

        if(id==ID.ID)
View Full Code Here

            t.toElementRef(prop);
    }

    public ID id() {
        for( Ref t : refs ) {
            ID id = t.id();
            if(id!=ID.NONE)    return id;
        }
        return ID.NONE;
    }
View Full Code Here

     */
    private void addTypeName(NonElement<T, C> r) {
        QName t = r.getTypeName();
        if(t==null)     return;

        TypeInfo old = typeNames.put(t,r);
        if(old!=null) {
            // collision
            reportError(new IllegalAnnotationException(
                    Messages.CONFLICTING_XML_TYPE_MAPPING.format(r.getTypeName()),
                    old, r ));
View Full Code Here

            XmlList xl = ref.annotations.getAnnotation(XmlList.class);

            builder.getTypeInfo(new Ref<TypeMirror,TypeDeclaration>(builder,t,xjta,xl));
        }

        TypeInfoSet r = builder.link();
        if(r==null)     return null;

        if(additionalElementDecls==null)
            additionalElementDecls = Collections.emptyMap();
        else {
View Full Code Here

            RuntimeTypeInfoSet r = typeInfoSetCache.get();
            if(r!=null)
                return r;
        }

        final RuntimeModelBuilder builder = new RuntimeModelBuilder(this,annotaitonReader,subclassReplacements,defaultNsUri);

        IllegalAnnotationsException.Builder errorHandler = new IllegalAnnotationsException.Builder();
        builder.setErrorHandler(errorHandler);

        for( Class c : classes ) {
            if(c==CompositeStructure.class)
                // CompositeStructure doesn't have TypeInfo, so skip it.
                // We'll add JaxBeanInfo for this later automatically
                continue;
            builder.getTypeInfo(new Ref<Type,Class>(c));
        }

        this.hasSwaRef |= builder.hasSwaRef;
        RuntimeTypeInfoSet r = builder.link();

        errorHandler.check();
        assert r!=null : "if no error was reported, the link must be a success";

        typeInfoSetCache = new WeakReference<RuntimeTypeInfoSet>(r);
View Full Code Here

TOP

Related Classes of com.sun.xml.internal.bind.v2.schemagen.xmlschema.Occurs

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.