Package org.apache.commons.betwixt.io.read

Examples of org.apache.commons.betwixt.io.read.ElementMapping


            * @param attributes the <code>Attributes</code> used to match <code>ID/IDREF</code>
            * @return the created bean
            */
            protected Object createBean( String namespace, String name, Attributes attributes ) {
                // todo: recycle element mappings
                ElementMapping mapping = new ElementMapping();
                mapping.setType( beanClass );
                mapping.setNamespace( namespace );
                mapping.setName( name );
                mapping.setAttributes( attributes );
                mapping.setDescriptor( descriptor );
               
                Object newInstance = context.getBeanCreationChain().create( mapping, context );
               
                return newInstance;
            }   
View Full Code Here


        XMLIntrospector introspector = new XMLIntrospector();
        introspector.register(new InputSource(new StringReader(MAPPING)));
       
       
        ElementDescriptor descriptor = introspector.introspect(Element.class).getElementDescriptor();
        ElementMapping elementMapping = new ElementMapping();
        elementMapping.setAttributes(new AttributesImpl());
        elementMapping.setName("Bogus");
        elementMapping.setDescriptor(descriptor);
        elementMapping.setType(Iterator.class);
        ReadContext readContext = new ReadContext(new BindingConfiguration(), new ReadConfiguration());
       
        assertNull(introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext));
       
        elementMapping.setName("elementA");
        Class resolution = introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext);
        assertEquals("Should resolve to the element about", ElementA.class, resolution);
    }
View Full Code Here

        XMLIntrospector introspector = new XMLIntrospector();
        introspector.register(new InputSource(new StringReader(MAPPING)));
       
       
        ElementDescriptor descriptor = introspector.introspect(Element.class).getElementDescriptor();
        ElementMapping elementMapping = new ElementMapping();
        elementMapping.setAttributes(new AttributesImpl());
        elementMapping.setName("Bogus");
        elementMapping.setDescriptor(descriptor);
        elementMapping.setType(Iterator.class);
        ReadContext readContext = new ReadContext(new BindingConfiguration(), new ReadConfiguration());
       
        assertNull(introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext));
       
        elementMapping.setName("elementA");
        Class resolution = introspector.getPolymorphicReferenceResolver().resolveType(elementMapping, readContext);
        assertEquals("Should resolve to the element about", ElementA.class, resolution);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.betwixt.io.read.ElementMapping

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.