Package com.sun.xml.bind.v2.schemagen.episode

Examples of com.sun.xml.bind.v2.schemagen.episode.Bindings


        if(!(bi instanceof ClassBeanInfoImpl))
            throw new JAXBException(wrapperBean+" is not a bean");

        for( ClassBeanInfoImpl cb = (ClassBeanInfoImpl) bi; cb!=null; cb=cb.superClazz) {
            for (Property p : cb.properties) {
                final Accessor acc = p.getElementPropertyAccessor(nsUri,localName);
                if(acc!=null)
                    return new RawAccessor() {
                        // Accessor.set/get are designed for unmarshaller/marshaller, and hence
                        // they go through an adapter behind the scene.
                        // this isn't desirable for JAX-WS, which essentially uses this method
                        // just as a reflection library. So use the "unadapted" version to
                        // achieve the desired semantics
                        public Object get(Object bean) throws AccessorException {
                            return acc.getUnadapted(bean);
                        }

                        public void set(Object bean, Object value) throws AccessorException {
                            acc.setUnadapted(bean,value);
                        }
                    };
            }
        }
        throw new JAXBException(new QName(nsUri,localName)+" is not a valid property on "+wrapperBean);
View Full Code Here


     *
     * @return null
     *      if for some reason it fails to create an optimized version.
     */
    public static final TransducedAccessor get(RuntimePropertyInfo prop) {
        Accessor acc = prop.getAccessor();

        // consider using an optimized TransducedAccessor implementations.
        Class opt=null;

        TypeInfo<Type,Class> parent = prop.parent();
        if(!(parent instanceof RuntimeClassInfo))
            return null;
       
        Class dc = ((RuntimeClassInfo)parent).getClazz();
        String newClassName = toVMClassName(dc)+"_JaxbXducedAccessor_"+prop.getName();


        if(acc instanceof Accessor.FieldReflection) {
            // TODO: we also need to make sure that the default xducer is used.
            Accessor.FieldReflection racc = (Accessor.FieldReflection) acc;
            Field field = racc.f;

            int mods = field.getModifiers();
            if(Modifier.isPrivate(mods) || Modifier.isFinal(mods))
                // we can't access private fields.
                // TODO: think about how to improve this case
                return null;

            Class<?> t = field.getType();
            if(t.isPrimitive())
                opt = AccessorInjector.prepare( dc,
                    fieldTemplateName+suffixMap.get(t),
                    newClassName,
                    toVMClassName(Bean.class),
                    toVMClassName(dc),
                    "f_"+t.getName(),
                    field.getName() );
        }

        if(acc.getClass()==Accessor.GetterSetterReflection.class) {
            Accessor.GetterSetterReflection gacc = (Accessor.GetterSetterReflection) acc;

            if(gacc.getter==null || gacc.setter==null)
                return null;    // incomplete

View Full Code Here

                        reader.next();
                        StringBuffer sb = null;
                        byte [] value = null;
                        CharSequence charSeq = ((XMLStreamReaderEx)reader).getPCDATA();
                        if(charSeq instanceof Base64Data){
                            Base64Data bd = (Base64Data) ((XMLStreamReaderEx)reader).getPCDATA();
                            value = bd.getExact();
                            if(canonWriter != null){
                                String ev = Base64.encode(value);
                                canonWriter.writeCharacters(ev);
                            }
                        }else {
View Full Code Here

        byte [] value = null;
        if(reader.getEventType() == reader.CHARACTERS){
            if(reader instanceof XMLStreamReaderEx){
                CharSequence charSeq = ((XMLStreamReaderEx)reader).getPCDATA();
                if(charSeq instanceof Base64Data){
                    Base64Data bd = (Base64Data) ((XMLStreamReaderEx)reader).getPCDATA();
                    value = bd.getExact();
                    if(canonWriter != null){
                        String ev = Base64.encode(value);
                        canonWriter.writeCharacters(ev);
                    }
                }else{
View Full Code Here

    }

    public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) {
        keyLoader = keyBeanInfo.getLoader(chain.context,true);
        valueLoader = valueBeanInfo.getLoader(chain.context,true);
        handlers.put(tagName,new ChildLoader(itemsLoader,null));
    }
View Full Code Here

    public Loader getLoader(JAXBContextImpl context, boolean typeSubstitutionCapable) {
        if(loader==null) {
            // these variables have to be set before they are initialized,
            // because the initialization may build other loaders and they may refer to this.
            StructureLoader sl = new StructureLoader(this);
            loader = sl;
            if(ci.hasSubClasses())
                loaderWithTypeSubst = new XsiTypeLoader(this);
            else
                // optimization. we know there can be no @xsi:type
                loaderWithTypeSubst = loader;


            sl.init(context,this,ci.getAttributeWildcard());
        }
        if(typeSubstitutionCapable)
            return loaderWithTypeSubst;
        else
            return loader;
View Full Code Here

    public MarshallerImpl createMarshaller() {
        return new MarshallerImpl(this,null);
    }

    public UnmarshallerImpl createUnmarshaller() {
        return new UnmarshallerImpl(this,null);
    }   
View Full Code Here

            // these variables have to be set before they are initialized,
            // because the initialization may build other loaders and they may refer to this.
            StructureLoader sl = new StructureLoader(this);
            loader = sl;
            if(ci.hasSubClasses())
                loaderWithTypeSubst = new XsiTypeLoader(this);
            else
                // optimization. we know there can be no @xsi:type
                loaderWithTypeSubst = loader;

View Full Code Here

    /**
     * Writes out the episode file.
     */
    public void writeEpisodeFile(XmlSerializer out) {
        Bindings root = TXW.create(Bindings.class, out);

        if(namespaces.containsKey("")) // otherwise jaxb binding NS should be the default namespace
            root._namespace(WellKnownNamespace.JAXB,"jaxb");
        root.version("2.1");
        // TODO: don't we want to bake in versions?

        // generate listing per schema
        for (Map.Entry<String,Namespace> e : namespaces.entrySet()) {
            Bindings group = root.bindings();

            String prefix;
            String tns = e.getKey();
            if(!tns.equals("")) {
                group._namespace(tns,"tns");
                prefix = "tns:";
            } else {
                prefix = "";
            }

            group.scd("x-schema::"+(tns.equals("")?"":"tns"));
            group.schemaBindings().map(false);

            for (ClassInfo<T,C> ci : e.getValue().classes) {
                if(ci.getTypeName()==nullcontinue;   // local type

                if(ci.getTypeName().getNamespaceURI().equals(tns)) {
                    Bindings child = group.bindings();
                    child.scd('~'+prefix+ci.getTypeName().getLocalPart());
                    child.klass().ref(ci.getName());
                }

                if(ci.isElement() && ci.getElementName().getNamespaceURI().equals(tns)) {
                    Bindings child = group.bindings();
                    child.scd(prefix+ci.getElementName().getLocalPart());
                    child.klass().ref(ci.getName());
                }
            }

            for (EnumLeafInfo<T,C> en : e.getValue().enums) {
                if(en.getTypeName()==nullcontinue;   // local type

                Bindings child = group.bindings();
                child.scd('~'+prefix+en.getTypeName().getLocalPart());
                child.klass().ref(navigator.getClassName(en.getClazz()));
            }

            group.commit(true);
        }

View Full Code Here

    /**
     * Writes out the episode file.
     */
    public void writeEpisodeFile(XmlSerializer out) {
        Bindings root = TXW.create(Bindings.class, out);

        if(namespaces.containsKey("")) // otherwise jaxb binding NS should be the default namespace
            root._namespace(WellKnownNamespace.JAXB,"jaxb");
        root.version("2.1");
        // TODO: don't we want to bake in versions?

        // generate listing per schema
        for (Map.Entry<String,Namespace> e : namespaces.entrySet()) {
            Bindings group = root.bindings();

            String prefix;
            String tns = e.getKey();
            if(!tns.equals("")) {
                group._namespace(tns,"tns");
                prefix = "tns:";
            } else {
                prefix = "";
            }

            group.scd("x-schema::"+(tns.equals("")?"":"tns"));
            group.schemaBindings().map(false);

            for (ClassInfo<T,C> ci : e.getValue().classes) {
                if(ci.getTypeName()==nullcontinue;   // local type

                if(ci.getTypeName().getNamespaceURI().equals(tns)) {
                    Bindings child = group.bindings();
                    child.scd('~'+prefix+ci.getTypeName().getLocalPart());
                    child.klass().ref(ci.getName());
                }

                if(ci.isElement() && ci.getElementName().getNamespaceURI().equals(tns)) {
                    Bindings child = group.bindings();
                    child.scd(prefix+ci.getElementName().getLocalPart());
                    child.klass().ref(ci.getName());
                }
            }

            for (EnumLeafInfo<T,C> en : e.getValue().enums) {
                if(en.getTypeName()==nullcontinue;   // local type

                Bindings child = group.bindings();
                child.scd('~'+prefix+en.getTypeName().getLocalPart());
                child.klass().ref(navigator.getClassName(en.getClazz()));
            }

            group.commit(true);
        }

View Full Code Here

TOP

Related Classes of com.sun.xml.bind.v2.schemagen.episode.Bindings

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.