Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.XMLIntrospector$BeanType


    /**
     * Set up the XMLIntroSpector
     */
    protected XMLIntrospector createXMLIntrospector() {
        XMLIntrospector introspector = new XMLIntrospector();

        // set elements for attributes to true
        introspector.getConfiguration().setAttributesForPrimitives(true);
        introspector.getConfiguration().setWrapCollectionsInElement(false);

        return introspector;
    }
View Full Code Here


     *
     * @return TODO: DOCUMENT ME!
     */
    protected XMLIntrospector createXMLIntrospector()
    {
        XMLIntrospector introspector = new XMLIntrospector();

        // set elements for attributes to true
        introspector.getConfiguration().setAttributesForPrimitives(false);

        // wrap collections in an XML element
        //introspector.setWrapCollectionsInElement(true);
        // turn bean elements first letter into lower case
        introspector.getConfiguration().setElementNameMapper(new DecapitalizeNameMapper());
        introspector.getConfiguration().setAttributeNameMapper(new DecapitalizeNameMapper());

        introspector.getConfiguration().setPluralStemmer(new DefaultPluralStemmer());

        return introspector;
    }
View Full Code Here

     *
     * @return introspector
     */
    private XMLIntrospector createXMLIntrospector()
    {
        XMLIntrospector introspector = new XMLIntrospector();

        // set elements for attributes to true
        introspector.getConfiguration().setAttributesForPrimitives(false);

        // wrap collections in an XML element
        //introspector.setWrapCollectionsInElement(true);
        // turn bean elements first letter into lower case
        introspector.getConfiguration().setElementNameMapper(new DecapitalizeNameMapper());
        introspector.getConfiguration().setAttributeNameMapper(new DecapitalizeNameMapper());

        introspector.getConfiguration().setPluralStemmer(new DefaultPluralStemmer());

        return introspector;
    }
View Full Code Here

        if ( var == null ) {
            throw new MissingAttributeException( "var" );
        }
        invokeBody(output);       
       
        XMLIntrospector introspector = getIntrospector();
       
        context.setVariable( var, introspector );
       
        // now lets clear this introspector so that its recreated again next time
        this.introspector = null;
View Full Code Here

   
    /**
     * Factory method to create a new XMLIntrospector
     */
    protected XMLIntrospector createIntrospector() {
        return new XMLIntrospector();
    }
View Full Code Here

    /**
     * @return the introspector to be used, lazily creating one if required.
     */
    public XMLIntrospector getIntrospector() {
        if (introspector == null) {
            introspector = new XMLIntrospector();
        }
        return introspector;
    }
View Full Code Here

     * @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

        // simple test this one
        // a problem was reported when introspecting classes with 'add' properties
        // when using the HyphenatedNameMapper
        // basically, the test is that no exception is thrown
        //
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        introspector.introspect(new ArrayList());
    }
View Full Code Here

     * / Turbine projects. Maybe a static helper method - question is what to
     * call it???
     */
    protected XMLIntrospector createXMLIntrospector()
    {
        XMLIntrospector introspector = new XMLIntrospector();

        // set elements for attributes to true
        introspector.getConfiguration().setAttributesForPrimitives(false);

        // wrap collections in an XML element
        introspector.getConfiguration().setWrapCollectionsInElement(false);

        // turn bean elements first letter into lower case
        introspector.getConfiguration().setElementNameMapper( new DecapitalizeNameMapper() );

        // Set default plural stemmer.
        introspector.getConfiguration().setPluralStemmer( new DefaultPluralStemmer() );

        return introspector;
    }
View Full Code Here

    }
   
    public void testIntrospector() throws Exception {
        //SimpleLog log = new SimpleLog("testIntrospector:introspector");
        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
        XMLIntrospector introspector = new XMLIntrospector();
        //introspector.setLog(log);
       
        introspector.getConfiguration().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();
       
View Full Code Here

TOP

Related Classes of org.apache.commons.betwixt.XMLIntrospector$BeanType

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.