Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.ElementDescriptor


        if ( ! registeredClasses.contains( beanClass ) ) {
            registeredClasses.add( beanClass );
           
            // introspect and find the ElementDescriptor to use as the root
            XMLBeanInfo xmlInfo = introspector.introspect( beanClass );
            ElementDescriptor elementDescriptor = xmlInfo.getElementDescriptor();       

            addBeanCreateRule( path, elementDescriptor, beanClass );
        } else {
            if ( log.isWarnEnabled() ) {
                log.warn("Cannot add class "  + beanClass.getName() + " since it already exists");
View Full Code Here


        }
       
        Object top = digester.peek();
        if ( top instanceof XMLBeanInfo ) {
            XMLBeanInfo beanInfo = (XMLBeanInfo) top;
            ElementDescriptor elementDescriptor = beanInfo.getElementDescriptor();
            if (elementDescriptor == null) {
                elementDescriptor.addContentDescriptor( descriptor );
            }
           
        } else if ( top instanceof ElementDescriptor ) {
            ElementDescriptor parent = (ElementDescriptor) top;
            parent.addContentDescriptor( descriptor );
           
        } else {
            throw new SAXException( "Invalid use of <text>. It should "
                + "be nested <text> nodes" );
        }
View Full Code Here

        XMLBeanInfo movieXmlBeanInfo
            = writer.getXMLIntrospector().introspect(MovieBean.class);
        writer.write(bean);
       
        List expected = new ArrayList();
        ElementDescriptor movieElementdescriptor
            = movieXmlBeanInfo.getElementDescriptor();
        ElementDescriptor nameDescriptor
            = movieElementdescriptor.getElementDescriptors()[0];
        ElementDescriptor yearDescriptor
            = movieElementdescriptor.getElementDescriptors()[1];
        ElementDescriptor directorDescriptor
            = movieElementdescriptor.getElementDescriptors()[2];
        ElementDescriptor actorsDescriptor
            = movieElementdescriptor.getElementDescriptors()[3];
        ElementDescriptor personDescriptor
            = personXmlBeanInfo.getElementDescriptor();           
       
        expected.add(
            new TestWritingAPI.Record(
                TestWritingAPI.START_ELEMENT,
View Full Code Here

    // 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

   
    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

    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

            "</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

            "</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

            "</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];
        assertEquals("Use type from document", true, personDescriptor.isUseBindTimeTypeForMapping());
    }
View Full Code Here

                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);
       
        for (int i=0; i<2; i++) {
            if ("one".equals(dynaPropertyDescriptors[i].getPropertyName())
                    || "two".equals(dynaPropertyDescriptors[i].getPropertyName())) {
View Full Code Here

TOP

Related Classes of org.apache.commons.betwixt.ElementDescriptor

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.