Examples of XMLIntrospector


Examples of org.apache.commons.betwixt.XMLIntrospector

     * @return descriptor for the singular property class type referenced.
     */
    protected ElementDescriptor getElementDescriptor( ElementDescriptor propertyDescriptor ) {
        Class beanClass = propertyDescriptor.getSingularPropertyType();
        if ( beanClass != null ) {
            XMLIntrospector introspector = getBeanReader().getXMLIntrospector();
            try {
                XMLBeanInfo xmlInfo = introspector.introspect( beanClass );
                return xmlInfo.getElementDescriptor();
               
            } catch (Exception e) {
                log.warn( "Could not introspect class: " + beanClass, e );
            }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

                new DynaProperty("one", Integer.class),
                new DynaProperty("two", String.class)};
        BasicDynaClass dynaClass = new BasicDynaClass("WibbleDynaBean", BasicDynaBean.class,
                dynaProperties);
        DynaBean dynaBean = dynaClass.newInstance();
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(dynaBean);
       
        ElementDescriptor dynaBeanDescriptor = xmlBeanInfo.getElementDescriptor();
        ElementDescriptor[] dynaPropertyDescriptors = dynaBeanDescriptor.getElementDescriptors();
        assertEquals("Two dyna properties expected", 2, dynaPropertyDescriptors.length);
       
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

    //todo: note to self need to consider how the design of the introspection will work when you have strategy which takes
    // singular property which is not know until after the digestion
   
    public void testDefaultMappingDerivationStrategy() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(Animals.class);
        ElementDescriptor animalsDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use bind time type", true, animalsDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use bind time type", true, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use bind time type", true, animalDescriptor.isUseBindTimeTypeForMapping());
    }
   
    public void testIntrospectionTimeMappingDerivationStrategy() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_INTROSPECTION_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(Animals.class);
        ElementDescriptor animalsDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use introspection time type", false, animalsDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use introspection time type", false, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use introspection time type", false, animalDescriptor.isUseBindTimeTypeForMapping());
    }

    public void testBindTypeMappingDerivationStrategy() throws Exception {
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_BIND_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(Animals.class);
        ElementDescriptor animalsDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use bind time type", true, animalsDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = animalsDescriptor.getElementDescriptors()[0];
        assertEquals("Use bind time type", true, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

        String mappingDocument="<?xml version='1.0'?><info>" +
            "<element name='pet-record'>" +
            "  <element name='pet' property='pet' mappingDerivation='bind'/>" +
            "</element>" +
            "</info>";
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_INTROSPECTION_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(PetBean.class, new InputSource(new StringReader(mappingDocument)));
        ElementDescriptor petDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use type from strategy", true, petDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = petDescriptor.getElementDescriptors()[0];
        assertEquals("Use type from document", true, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

        String mappingDocument="<?xml version='1.0'?><info>" +
            "<element name='pet-record'>" +
            "  <element name='pet' property='pet' mappingDerivation='introspection'/>" +
            "</element>" +
            "</info>";
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_BIND_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(PetBean.class, new InputSource(new StringReader(mappingDocument)));
        ElementDescriptor petDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use type from strategy", true, petDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = petDescriptor.getElementDescriptors()[0];
        assertEquals("Use type from document", false, animalDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

            "<element name='pet-record'>" +
            "  <element name='pet' property='pet' mappingDerivation='introspection'/>" +
            "   <addDefaults/>" +
            "</element>" +
            "</info>";
        XMLIntrospector xmlIntrospector = new XMLIntrospector();
        xmlIntrospector.getConfiguration().setMappingDerivationStrategy(MappingDerivationStrategy.USE_BIND_TIME_TYPE);
        XMLBeanInfo xmlBeanInfo = xmlIntrospector.introspect(PetBean.class, new InputSource(new StringReader(mappingDocument)));
        ElementDescriptor petDescriptor = xmlBeanInfo.getElementDescriptor();
        assertEquals("Use type from strategy", true, petDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor animalDescriptor = petDescriptor.getElementDescriptors()[0];
        assertEquals("Use type from document", false, animalDescriptor.isUseBindTimeTypeForMapping());
        ElementDescriptor personDescriptor = petDescriptor.getElementDescriptors()[1];
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

    /**
     * Test the helper's <code>createDescriptor</code> method when a hyphenated name
     * mapper is set.
     */
    public void testCreateDescriptorWithHyphenatedElementNameMapper() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setAttributesForPrimitives(false);
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        BeanInfo beanInfo = Introspector.getBeanInfo(CustomerBean.class);

        NodeDescriptor nickNameProperty = createDescriptor("nickName", beanInfo, introspector);
        assertNotNull("nickName property not found", nickNameProperty);
        assertEquals("nick name property", "nick-name", nickNameProperty.getLocalName());
View Full Code Here

Examples of org.apache.commons.betwixt.XMLIntrospector

        assertNotNull("projectNames property not found", projectNamesProperty);
        assertEquals("project names property", "project-names", projectNamesProperty.getLocalName());
    }
   
    public void testNullParameters() throws Exception {
        new XMLIntrospector().isLoopType(null);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.