Package com.sun.xml.bind.v2.model.runtime

Examples of com.sun.xml.bind.v2.model.runtime.RuntimeTypeInfoSet


        }
        this.fastBoot = fastB;

        System.arraycopy(classes,0,this.classes,0,classes.length);

        RuntimeTypeInfoSet typeSet = getTypeInfoSet();

        // at least prepare the empty table so that we don't have to check for null later
        elements.put(null,new LinkedHashMap<QName, ElementBeanInfoImpl>());

        // recognize leaf bean infos
        for( RuntimeBuiltinLeafInfo leaf : RuntimeBuiltinLeafInfoImpl.builtinBeanInfos ) {
            LeafBeanInfoImpl<?> bi = new LeafBeanInfoImpl(this,leaf);
            beanInfoMap.put(leaf.getClazz(),bi);
            for( QName t : bi.getTypeNames() )
                typeMap.put(t,bi);
        }

        for (RuntimeEnumLeafInfo e : typeSet.enums().values()) {
            JaxBeanInfo<?> bi = getOrCreate(e);
            for (QName qn : bi.getTypeNames())
                typeMap.put( qn, bi );
            if(e.isElement())
                rootMap.put( e.getElementName(), bi );
        }

        for (RuntimeArrayInfo a : typeSet.arrays().values()) {
            JaxBeanInfo<?> ai = getOrCreate(a);
            for (QName qn : ai.getTypeNames())
                typeMap.put( qn, ai );
        }

        for( Entry<Class, ? extends RuntimeClassInfo> e : typeSet.beans().entrySet() ) {
            ClassBeanInfoImpl<?> bi = getOrCreate(e.getValue());

            XmlSchema xs = this.annotaitonReader.getPackageAnnotation(XmlSchema.class, e.getKey(), null);
            if(xs != null) {
                if(xs.xmlns() != null && xs.xmlns().length > 0) {
                    if(xmlNsSet == null)
                        xmlNsSet = new HashSet<XmlNs>();

                    for(int i = 0; i < xs.xmlns().length; i++)
                        xmlNsSet.add(xs.xmlns()[i]);
                }
            }

            if(bi.isElement())
                rootMap.put( e.getValue().getElementName(), bi );

            for (QName qn : bi.getTypeNames())
                typeMap.put( qn, bi );
        }

        // fill in element mappings
        for( RuntimeElementInfo n : typeSet.getAllElements() ) {
            ElementBeanInfoImpl bi = getOrCreate(n);
            if(n.getScope()==null)
                rootMap.put(n.getElementName(),bi);

            RuntimeClassInfo scope = n.getScope();
            Class scopeClazz = scope==null?null:scope.getClazz();
            Map<QName,ElementBeanInfoImpl> m = elements.get(scopeClazz);
            if(m==null) {
                m = new LinkedHashMap<QName, ElementBeanInfoImpl>();
                elements.put(scopeClazz,m);
            }
            m.put(n.getElementName(),bi);
        }

        // this one is so that we can handle plain JAXBElements.
        beanInfoMap.put(JAXBElement.class,new ElementBeanInfoImpl(this));
        // another special BeanInfoImpl just for marshalling
        beanInfoMap.put(CompositeStructure.class,new CompositeStructureBeanInfo(this));

        getOrCreate(typeSet.getAnyTypeInfo());

        // then link them all!
        for (JaxBeanInfo bi : beanInfos.values())
            bi.link(this);

        // register primitives for boxed types just to make GrammarInfo fool-proof
        for( Map.Entry<Class,Class> e : RuntimeUtil.primitiveToBox.entrySet() )
            beanInfoMap.put( e.getKey(), beanInfoMap.get(e.getValue()) );

        // build bridges
        ReflectionNavigator nav = typeSet.getNavigator();

        for (TypeReference tr : typeRefs) {
            XmlJavaTypeAdapter xjta = tr.get(XmlJavaTypeAdapter.class);
            Adapter<Type,Class> a=null;
            XmlList xl = tr.get(XmlList.class);
View Full Code Here


     */
    public RuntimeTypeInfoSet getTypeInfoSet() throws IllegalAnnotationsException {

        // check cache
        if(typeInfoSetCache!=null) {
            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

            throw x;
        }
    }

    private XmlSchemaGenerator<Type,Class,Field,Method> createSchemaGenerator() {
        RuntimeTypeInfoSet tis;
        try {
            tis = getTypeInfoSet();
        } catch (IllegalAnnotationsException e) {
            // this shouldn't happen because we've already
            throw new AssertionError(e);
        }

        XmlSchemaGenerator<Type,Class,Field,Method> xsdgen =
                new XmlSchemaGenerator<Type,Class,Field,Method>(tis.getNavigator(),tis);

        // JAX-RPC uses Bridge objects that collide with
        // @XmlRootElement.
        // we will avoid collision here
        Set<QName> rootTagNames = new HashSet<QName>();
        for (RuntimeElementInfo ei : tis.getAllElements()) {
            rootTagNames.add(ei.getElementName());
        }
        for (RuntimeClassInfo ci : tis.beans().values()) {
            if(ci.isElement())
                rootTagNames.add(ci.asElement().getElementName());
        }

        for (TypeReference tr : bridges.keySet()) {
View Full Code Here

        }
        this.fastBoot = fastB;

        System.arraycopy(classes,0,this.classes,0,classes.length);

        RuntimeTypeInfoSet typeSet = getTypeInfoSet();

        // at least prepare the empty table so that we don't have to check for null later
        elements.put(null,new LinkedHashMap<QName, ElementBeanInfoImpl>());

        // recognize leaf bean infos
        for( RuntimeBuiltinLeafInfo leaf : RuntimeBuiltinLeafInfoImpl.builtinBeanInfos ) {
            LeafBeanInfoImpl<?> bi = new LeafBeanInfoImpl(this,leaf);
            beanInfoMap.put(leaf.getClazz(),bi);
            for( QName t : bi.getTypeNames() )
                typeMap.put(t,bi);
        }

        for (RuntimeEnumLeafInfo e : typeSet.enums().values()) {
            JaxBeanInfo<?> bi = getOrCreate(e);
            for (QName qn : bi.getTypeNames())
                typeMap.put( qn, bi );
            if(e.isElement())
                rootMap.put( e.getElementName(), bi );
        }

        for (RuntimeArrayInfo a : typeSet.arrays().values()) {
            JaxBeanInfo<?> ai = getOrCreate(a);
            for (QName qn : ai.getTypeNames())
                typeMap.put( qn, ai );
        }

        for( Entry<Class, ? extends RuntimeClassInfo> e : typeSet.beans().entrySet() ) {
            ClassBeanInfoImpl<?> bi = getOrCreate(e.getValue());

            XmlSchema xs = this.annotaitonReader.getPackageAnnotation(XmlSchema.class, e.getKey(), null);
            if(xs != null) {
                if(xs.xmlns() != null && xs.xmlns().length > 0) {
                    if(xmlNsSet == null)
                        xmlNsSet = new HashSet<XmlNs>();

                    for(int i = 0; i < xs.xmlns().length; i++)
                        xmlNsSet.add(xs.xmlns()[i]);
                }
            }

            if(bi.isElement())
                rootMap.put( e.getValue().getElementName(), bi );

            for (QName qn : bi.getTypeNames())
                typeMap.put( qn, bi );
        }

        // fill in element mappings
        for( RuntimeElementInfo n : typeSet.getAllElements() ) {
            ElementBeanInfoImpl bi = getOrCreate(n);
            if(n.getScope()==null)
                rootMap.put(n.getElementName(),bi);

            RuntimeClassInfo scope = n.getScope();
            Class scopeClazz = scope==null?null:scope.getClazz();
            Map<QName,ElementBeanInfoImpl> m = elements.get(scopeClazz);
            if(m==null) {
                m = new LinkedHashMap<QName, ElementBeanInfoImpl>();
                elements.put(scopeClazz,m);
            }
            m.put(n.getElementName(),bi);
        }

        // this one is so that we can handle plain JAXBElements.
        beanInfoMap.put(JAXBElement.class,new ElementBeanInfoImpl(this));
        // another special BeanInfoImpl just for marshalling
        beanInfoMap.put(CompositeStructure.class,new CompositeStructureBeanInfo(this));

        getOrCreate(typeSet.getAnyTypeInfo());

        // then link them all!
        for (JaxBeanInfo bi : beanInfos.values())
            bi.link(this);

        // register primitives for boxed types just to make GrammarInfo fool-proof
        for( Map.Entry<Class,Class> e : RuntimeUtil.primitiveToBox.entrySet() )
            beanInfoMap.put( e.getKey(), beanInfoMap.get(e.getValue()) );

        // build bridges
        ReflectionNavigator nav = typeSet.getNavigator();

        for (TypeReference tr : typeRefs) {
            XmlJavaTypeAdapter xjta = tr.get(XmlJavaTypeAdapter.class);
            Adapter<Type,Class> a=null;
            XmlList xl = tr.get(XmlList.class);
View Full Code Here

     */
    public RuntimeTypeInfoSet getTypeInfoSet() throws IllegalAnnotationsException {

        // check cache
        if(typeInfoSetCache!=null) {
            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

            throw x;
        }
    }

    private XmlSchemaGenerator<Type,Class,Field,Method> createSchemaGenerator() {
        RuntimeTypeInfoSet tis;
        try {
            tis = getTypeInfoSet();
        } catch (IllegalAnnotationsException e) {
            // this shouldn't happen because we've already
            throw new AssertionError(e);
        }

        XmlSchemaGenerator<Type,Class,Field,Method> xsdgen =
                new XmlSchemaGenerator<Type,Class,Field,Method>(tis.getNavigator(),tis);

        // JAX-RPC uses Bridge objects that collide with
        // @XmlRootElement.
        // we will avoid collision here
        Set<QName> rootTagNames = new HashSet<QName>();
        for (RuntimeElementInfo ei : tis.getAllElements()) {
            rootTagNames.add(ei.getElementName());
        }
        for (RuntimeClassInfo ci : tis.beans().values()) {
            if(ci.isElement())
                rootTagNames.add(ci.asElement().getElementName());
        }

        for (TypeReference tr : bridges.keySet()) {
View Full Code Here

     * @throws IllegalAnnotationsException if there was any incorrect use of
     *             annotations in the specified set of classes.
     */
    public static RuntimeTypeInfoSet create(JAXBContextImpl context, Class... classes) throws IllegalAnnotationsException {
        IllegalAnnotationsException.Builder errorListener = new IllegalAnnotationsException.Builder();
        RuntimeTypeInfoSet r = create(context, errorListener, classes);
        errorListener.check();
        return r;
    }
View Full Code Here

            }

        }
        context = (JAXBContextImpl) ContextFactory.createContext(classes, riProperties);

        RuntimeTypeInfoSet runtimeTypeInfoSet = JAXBModelFactory.create(context, classes);

        model = new Model();

        for (RuntimeEnumLeafInfo runtimeEnumLeafInfo : runtimeTypeInfoSet.enums().values()) {
            addEnum(model, runtimeEnumLeafInfo);
        }

        for (RuntimeClassInfo runtimeClassInfo : runtimeTypeInfoSet.beans().values()) {
            addBean(model, runtimeClassInfo);
        }

        for (Class clazz : classes) {
            if (clazz.isAnnotationPresent(XmlRegistry.class)) {
View Full Code Here

     * @throws IllegalAnnotationsException if there was any incorrect use of
     *             annotations in the specified set of classes.
     */
    public static RuntimeTypeInfoSet create(JAXBContextImpl context, Class... classes) throws IllegalAnnotationsException {
        IllegalAnnotationsException.Builder errorListener = new IllegalAnnotationsException.Builder();
        RuntimeTypeInfoSet r = create(context, errorListener, classes);
        errorListener.check();
        return r;
    }
View Full Code Here

/* 281 */     this.xmlAccessorFactorySupport = xmlAccessorFactorySupport;
/* 282 */     this.allNillable = allNillable;
/* 283 */     this.classes = new Class[classes.length];
/* 284 */     System.arraycopy(classes, 0, this.classes, 0, classes.length);
/*     */
/* 286 */     RuntimeTypeInfoSet typeSet = getTypeInfoSet();
/*     */
/* 290 */     this.elements.put(null, new LinkedHashMap());
/*     */
/* 293 */     for (RuntimeBuiltinLeafInfo leaf : RuntimeBuiltinLeafInfoImpl.builtinBeanInfos) {
/* 294 */       bi = new LeafBeanInfoImpl(this, leaf);
/* 295 */       this.beanInfoMap.put(leaf.getClazz(), bi);
/* 296 */       for (QName t : bi.getTypeNames())
/* 297 */         this.typeMap.put(t, bi);
/*     */     }
/*     */     LeafBeanInfoImpl bi;
/* 300 */     for (RuntimeEnumLeafInfo e : typeSet.enums().values()) {
/* 301 */       JaxBeanInfo bi = getOrCreate(e);
/* 302 */       for (QName qn : bi.getTypeNames())
/* 303 */         this.typeMap.put(qn, bi);
/* 304 */       if (e.isElement()) {
/* 305 */         this.rootMap.put(e.getElementName(), bi);
/*     */       }
/*     */     }
/* 308 */     for (RuntimeArrayInfo a : typeSet.arrays().values()) {
/* 309 */       ai = getOrCreate(a);
/* 310 */       for (QName qn : ai.getTypeNames())
/* 311 */         this.typeMap.put(qn, ai);
/*     */     }
/*     */     JaxBeanInfo ai;
/* 314 */     for (RuntimeClassInfo ci : typeSet.beans().values()) {
/* 315 */       bi = getOrCreate(ci);
/*     */
/* 317 */       if (bi.isElement()) {
/* 318 */         this.rootMap.put(ci.getElementName(), bi);
/*     */       }
/* 320 */       for (QName qn : bi.getTypeNames())
/* 321 */         this.typeMap.put(qn, bi);
/*     */     }
/*     */     ClassBeanInfoImpl bi;
/* 325 */     for (RuntimeElementInfo n : typeSet.getAllElements()) {
/* 326 */       ElementBeanInfoImpl bi = getOrCreate(n);
/* 327 */       if (n.getScope() == null) {
/* 328 */         this.rootMap.put(n.getElementName(), bi);
/*     */       }
/* 330 */       RuntimeClassInfo scope = n.getScope();
/* 331 */       Class scopeClazz = scope == null ? null : (Class)scope.getClazz();
/* 332 */       Map m = (Map)this.elements.get(scopeClazz);
/* 333 */       if (m == null) {
/* 334 */         m = new LinkedHashMap();
/* 335 */         this.elements.put(scopeClazz, m);
/*     */       }
/* 337 */       m.put(n.getElementName(), bi);
/*     */     }
/*     */
/* 341 */     this.beanInfoMap.put(JAXBElement.class, new ElementBeanInfoImpl(this));
/*     */
/* 343 */     this.beanInfoMap.put(CompositeStructure.class, new CompositeStructureBeanInfo(this));
/*     */
/* 345 */     getOrCreate(typeSet.getAnyTypeInfo());
/*     */
/* 348 */     for (JaxBeanInfo bi : this.beanInfos.values()) {
/* 349 */       bi.link(this);
/*     */     }
/*     */
/* 352 */     for (Map.Entry e : RuntimeUtil.primitiveToBox.entrySet()) {
/* 353 */       this.beanInfoMap.put(e.getKey(), this.beanInfoMap.get(e.getValue()));
/*     */     }
/*     */
/* 356 */     ReflectionNavigator nav = typeSet.getNavigator();
/*     */
/* 358 */     for (TypeReference tr : typeRefs) {
/* 359 */       XmlJavaTypeAdapter xjta = (XmlJavaTypeAdapter)tr.get(XmlJavaTypeAdapter.class);
/* 360 */       Adapter a = null;
/* 361 */       XmlList xl = (XmlList)tr.get(XmlList.class);
View Full Code Here

TOP

Related Classes of com.sun.xml.bind.v2.model.runtime.RuntimeTypeInfoSet

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.