Examples of XMLBeanInfo


Examples of org.apache.commons.betwixt.XMLBeanInfo

   
    /**
     * Process the end of this element.
     */
    public void end() {
        XMLBeanInfo xmlBeanInfo = (XMLBeanInfo) getDigester().pop();
        MultiMappingBeanInfoDigester digester = (MultiMappingBeanInfoDigester) getDigester();
        Map xmlBeanInfoMapping = digester.getBeanInfoMap();
        xmlBeanInfoMapping.put(xmlBeanInfo.getBeanClass(), xmlBeanInfo);
        digester.setBeanClass(null);
    }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

   
    public void testDefaultClassNormalizer() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
       
        FaceImpl face = new FaceImpl();
        XMLBeanInfo info = introspector.introspect( face );
        ElementDescriptor elementDescriptor = info.getElementDescriptor();
   
        AttributeDescriptor[] attributeDescriptor = elementDescriptor.getAttributeDescriptors();     
        ElementDescriptor[] children = elementDescriptor.getElementDescriptors();
       
        assertEquals("Expected no attributes", 0, attributeDescriptor.length);
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

                    return super.normalize( clazz );
               
            });
       
        FaceImpl face = new FaceImpl();
        XMLBeanInfo info = introspector.introspect( face );
        ElementDescriptor elementDescriptor = info.getElementDescriptor();
        assertEquals("Expected only itself", 1, elementDescriptor.getElementDescriptors().length);
   
        AttributeDescriptor[] attributeDescriptor = elementDescriptor.getAttributeDescriptors();     
        ElementDescriptor[] children = elementDescriptor.getElementDescriptors();
       
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

        XMLIntrospector introspector = new XMLIntrospector();
        introspector.setClassNormalizer(classNormalizer);
       
        FaceImpl face = new FaceImpl();
       
        XMLBeanInfo info = introspector.introspect( face );
        ElementDescriptor elementDescriptor = info.getElementDescriptor();
        AttributeDescriptor[] attributeDescriptor = elementDescriptor.getAttributeDescriptors();     
        ElementDescriptor[] children = elementDescriptor.getElementDescriptors();
       
        assertEquals("Expected no attributes", 0, attributeDescriptor.length);
        assertEquals("Expected one elements", 1, children.length);
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

        //SimpleLog log = new SimpleLog("[testClassAttribute:ElementRule]");
        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
        //ElementRule.setLog(log);
       
        XMLIntrospector introspector = new XMLIntrospector();
        XMLBeanInfo beanInfo = introspector.introspect(ExampleBean.class);
        ElementDescriptor[] elementDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
        ElementDescriptor elementsElementDescriptor = null;
        for ( int i=0, size = elementDescriptors.length; i<size ; i++ ) {
            if ( "examples".equals( elementDescriptors[i].getLocalName() ) ) {
                elementsElementDescriptor = elementDescriptors[i];
            }
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

            "</info>";
           
        XMLBeanInfoDigester digester = new XMLBeanInfoDigester();
        digester.setXMLIntrospector(new XMLIntrospector());
        digester.setBeanClass(ExampleBean.class);
        XMLBeanInfo xmlBeanInfo = (XMLBeanInfo) digester.parse(new StringReader(xml));
        ElementDescriptor baseDescriptor = xmlBeanInfo.getElementDescriptor();
       
        assertEquals("Value one set on base", "value one",  baseDescriptor.getOptions().getValue("one"));
        assertEquals("Value two set on base", "value two",  baseDescriptor.getOptions().getValue("two"));
        assertNull("Value three not set on base",  baseDescriptor.getOptions().getValue("three"));
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
        writer.getXMLIntrospector().setAttributesForPrimitives(false);
        XMLBeanInfo elementInfo = writer.getXMLIntrospector().introspect(Element.class);
        elementInfo.getElementDescriptor().getElementDescriptors()[0]
            .getOptions().addOption(MixedContentEncodingStrategy.ENCODING_OPTION_NAME, "CDATA")
        
        writer.write(element);
       
        String expected = "<?xml version='1.0'?><Element>\n<value><![CDATA[<greeting>What Ho Jeeves!</greeting>]]></value>\n</Element>\n";
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
        writer.getXMLIntrospector().setAttributesForPrimitives(false);
        XMLBeanInfo elementInfo = writer.getXMLIntrospector().introspect(Element.class);
        elementInfo.getElementDescriptor().getElementDescriptors()[0]
            .getOptions().addOption("org.apache.commons.betwixt.mixed-content-encoding", "escaped");
        writer.write(element);
       
        String expected = "<?xml version='1.0'?><Element>\n<value>&lt;greeting&gt;What Ho Jeeves!&lt;/greeting&gt;</value>\n</Element>\n";
        String xml = out.getBuffer().toString();
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

       
        introspector.setAttributesForPrimitives(true);
       
        Object bean = createBean();
       
        XMLBeanInfo info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        ElementDescriptor descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        AttributeDescriptor[] attributes = descriptor.getAttributeDescriptors();
       
        assertTrue( "Found attributes", attributes != null && attributes.length > 0 );
       
        // test second introspection with caching on
        info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        attributes = descriptor.getAttributeDescriptors();
       
        assertTrue( "Found attributes", attributes != null && attributes.length > 0 );


        // test introspection with caching off     
        //introspector.setCachingEnabled(false); 
        introspector.setRegistry(new NoCacheRegistry());
        info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        attributes = descriptor.getAttributeDescriptors();
       
        assertTrue( "Found attributes", attributes != null && attributes.length > 0 );


        // test introspection after flushing cache
//        introspector.setCachingEnabled(true);
        introspector.setRegistry(new DefaultXMLBeanInfoRegistry());
        //introspector.flushCache();
        info = introspector.introspect( bean );
       
        assertTrue( "Found XMLBeanInfo", info != null );
       
        descriptor = info.getElementDescriptor();
       
        assertTrue( "Found root element descriptor", descriptor != null );
       
        attributes = descriptor.getAttributeDescriptors();
       
View Full Code Here

Examples of org.apache.commons.betwixt.XMLBeanInfo

        XMLIntrospector introspector = new XMLIntrospector();
        introspector.setAttributesForPrimitives(false);
//        introspector.setLog(log);
       
        XMLBeanInfo xmlBeanInfo = introspector.introspect(BeanWithBeanInfoBean.class);
       
        ElementDescriptor[] elementDescriptors = xmlBeanInfo.getElementDescriptor().getElementDescriptors();
       
//        log = new SimpleLog("[testBeanWithBeanInfo]");
//        log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
       
//        log.debug("XMLBeanInfo:");
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.