Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.AttributeDescriptor


            }
            if ( useAttributesForPrimitives ) {
                if (log.isTraceEnabled()) {
                    log.trace( "Adding property as attribute: " + name );
                }
                nodeDescriptor = new AttributeDescriptor();
            } else {
                if (log.isTraceEnabled()) {
                    log.trace( "Adding property as element: " + name );
                }
                nodeDescriptor = new ElementDescriptor(true);
View Full Code Here


                // iterate through all attributes       
                AttributeDescriptor[] attributeDescriptors
                    = typeDescriptor.getAttributeDescriptors();
                if ( attributeDescriptors != null ) {
                    for ( int i = 0, size = attributeDescriptors.length; i < size; i++ ) {
                        AttributeDescriptor attributeDescriptor = attributeDescriptors[i];
                       
                        // The following isn't really the right way to find the attribute
                        // but it's quite robust.
                        // The idea is that you try both namespace and local name first
                        // and if this returns null try the qName.
                        String value = attributes.getValue(
                            attributeDescriptor.getURI(),
                            attributeDescriptor.getLocalName()
                        );
                       
                        if (value == null) {
                            value = attributes.getValue(attributeDescriptor.getQualifiedName());
                        }
                       
                        if (log.isTraceEnabled()) {
                            log.trace("Attr URL:" + attributeDescriptor.getURI());
                            log.trace("Attr LocalName:" + attributeDescriptor.getLocalName() );
                            log.trace(value);
                        }
                       
                        Updater updater = attributeDescriptor.getUpdater();
                        log.trace(updater);
                        if ( updater != null && value != null ) {
                            updater.update( context, value );
                        }
                    }
View Full Code Here

     * @throws SAXException 1. If the attribute tag is not inside an element tag.
     * 2. If the name attribute is not valid XML attribute name.
     */
    public void begin(Attributes attributes) throws SAXException {
       
        AttributeDescriptor descriptor = new AttributeDescriptor();
        String name = attributes.getValue( "name" );

        // check that name is well formed
        if ( !XMLUtils.isWellFormedXMLName( name ) ) {
            throw new SAXException("'" + name + "' would not be a well formed xml attribute name.");
        }
       
        descriptor.setQualifiedName( name );
        descriptor.setLocalName( name );
        String uri = attributes.getValue( "uri" );
        if ( uri != null ) {
            descriptor.setURI( uri );       
        }
        String propertyName = attributes.getValue( "property" );
        descriptor.setPropertyName( propertyName );
        descriptor.setPropertyType( loadClass( attributes.getValue( "type" ) ) );
       
        if ( propertyName != null && propertyName.length() > 0 ) {
            configureDescriptor(descriptor);
        } else {
            String value = attributes.getValue( "value" );
            if ( value != null ) {
                descriptor.setTextExpression( new ConstantExpression( value ) );
            }
        }

        Object top = digester.peek();
        if ( top instanceof ElementDescriptor ) {
View Full Code Here

                // iterate through all attributes       
                AttributeDescriptor[] attributeDescriptors
                    = typeDescriptor.getAttributeDescriptors();
                if ( attributeDescriptors != null ) {
                    for ( int i = 0, size = attributeDescriptors.length; i < size; i++ ) {
                        AttributeDescriptor attributeDescriptor = attributeDescriptors[i];
                       
                        // The following isn't really the right way to find the attribute
                        // but it's quite robust.
                        // The idea is that you try both namespace and local name first
                        // and if this returns null try the qName.
                        String value = attributes.getValue(
                            attributeDescriptor.getURI(),
                            attributeDescriptor.getLocalName()
                        );
                       
                        if ( value == null ) {
                            value = attributes.getValue(
                                attributeDescriptor.getQualifiedName());
                        }
                       
                        if ( log.isTraceEnabled() ) {
                            log.trace("Attr URL:" + attributeDescriptor.getURI());
                            log.trace(
                                        "Attr LocalName:"
                                        + attributeDescriptor.getLocalName() );
                            log.trace(value);
                        }
                       
                        Updater updater = attributeDescriptor.getUpdater();
                        if ( log.isTraceEnabled() ) {
                            log.trace("Updater : "+updater);
                        }
                        if ( updater != null && value != null ) {
                            updater.update( context, value );
View Full Code Here

        XMLBeanInfo beanInfo = introspector.introspect(TuneBean.class);
        ElementDescriptor tuneBeanDescriptor = beanInfo.getElementDescriptor();
       
        AttributeDescriptor[] tuneBeanAttributes = tuneBeanDescriptor.getAttributeDescriptors();
        assertEquals("Only expect one attribute", 1, tuneBeanAttributes.length);
        AttributeDescriptor recordedAttribute = tuneBeanAttributes[0];
        assertEquals("Expected recorded to be bound as an attribute", "recorded", recordedAttribute.getLocalName());
       
        ElementDescriptor[] tuneBeanChildElements = tuneBeanDescriptor.getElementDescriptors();
        assertEquals("Expected three child elements", 3 , tuneBeanChildElements.length);
       
        int bits = 0;
View Full Code Here

        AttributeDescriptor[] attributeDescriptors = beanInfo
                .getElementDescriptor().getAttributeDescriptors();
        assertEquals("Need 2 attribute descriptors", 2,
                attributeDescriptors.length);

        AttributeDescriptor attribute1Descriptor = beanInfo
                .getElementDescriptor().getAttributeDescriptor("attribute1");
        log.info("attribute1Descriptor: " + attribute1Descriptor);
        debugOptions(attribute1Descriptor.getOptions());
        assertNotNull(attribute1Descriptor);
        assertEquals("2", attribute1Descriptor.getOptions().getValue(
                "version-from"));
        assertNull(attribute1Descriptor.getOptions().getValue("version-until"));

        AttributeDescriptor attribute2Descriptor = beanInfo
                .getElementDescriptor().getAttributeDescriptor("attribute2");
        log.info("attribute2Descriptor: " + attribute2Descriptor);
        debugOptions(attribute2Descriptor.getOptions());
        assertNotNull(attribute2Descriptor);
        assertEquals("1", attribute2Descriptor.getOptions().getValue(
                "version-from"));
        assertEquals("2", attribute2Descriptor.getOptions().getValue(
                "version-until"));

        log.info("testIntrospection() complete");
    }
View Full Code Here

                // iterate through all attributes       
                AttributeDescriptor[] attributeDescriptors
                    = typeDescriptor.getAttributeDescriptors();
                if ( attributeDescriptors != null ) {
                    for ( int i = 0, size = attributeDescriptors.length; i < size; i++ ) {
                        AttributeDescriptor attributeDescriptor = attributeDescriptors[i];
                       
                        // The following isn't really the right way to find the attribute
                        // but it's quite robust.
                        // The idea is that you try both namespace and local name first
                        // and if this returns null try the qName.
                        String value = attributes.getValue(
                            attributeDescriptor.getURI(),
                            attributeDescriptor.getLocalName()
                        );
                       
                        if (value == null) {
                            value = attributes.getValue(attributeDescriptor.getQualifiedName());
                        }
                       
                        if (log.isTraceEnabled()) {
                            log.trace("Attr URL:" + attributeDescriptor.getURI());
                            log.trace("Attr LocalName:" + attributeDescriptor.getLocalName() );
                            log.trace(value);
                        }
                       
                        Updater updater = attributeDescriptor.getUpdater();
                        log.trace(updater);
                        if ( updater != null && value != null ) {
                            updater.update( context, value );
                        }
                    }
View Full Code Here

        XMLBeanInfo beanInfo = introspector.introspect(TuneBean.class);
        ElementDescriptor tuneBeanDescriptor = beanInfo.getElementDescriptor();
       
        AttributeDescriptor[] tuneBeanAttributes = tuneBeanDescriptor.getAttributeDescriptors();
        assertEquals("Only expect one attribute", 1, tuneBeanAttributes.length);
        AttributeDescriptor recordedAttribute = tuneBeanAttributes[0];
        assertEquals("Expected recorded to be bound as an attribute", "recorded", recordedAttribute.getLocalName());
       
        ElementDescriptor[] tuneBeanChildElements = tuneBeanDescriptor.getElementDescriptors();
        assertEquals("Expected three child elements", 3 , tuneBeanChildElements.length);
       
        int bits = 0;
View Full Code Here

            }
            if ( useAttributesForPrimitives ) {
                if (log.isTraceEnabled()) {
                    log.trace( "Adding property as attribute: " + name );
                }
                nodeDescriptor = new AttributeDescriptor();
            } else {
                if (log.isTraceEnabled()) {
                    log.trace( "Adding property as element: " + name );
                }
                nodeDescriptor = new ElementDescriptor(true);
View Full Code Here

     * @throws SAXException 1. If the attribute tag is not inside an element tag.
     * 2. If the name attribute is not valid XML attribute name.
     */
    public void begin(String name, String namespace, Attributes attributes) throws SAXException {
       
        AttributeDescriptor descriptor = new AttributeDescriptor();
        String nameAttributeValue = attributes.getValue( "name" );

        // check that name is well formed
        if ( !XMLUtils.isWellFormedXMLName( nameAttributeValue ) ) {
            throw new SAXException("'" + nameAttributeValue + "' would not be a well formed xml attribute name.");
        }
       
        String qName = nameAttributeValue;
        descriptor.setLocalName( nameAttributeValue );
        String uri = attributes.getValue( "uri" );
        if ( uri != null ) {
            descriptor.setURI( uri )
            String prefix = getXMLIntrospector().getConfiguration().getPrefixMapper().getPrefix(uri);
            qName = prefix + ":" + nameAttributeValue;
        }
        descriptor.setQualifiedName( qName );
       
        String propertyName = attributes.getValue( "property" );
        descriptor.setPropertyName( propertyName );
        descriptor.setPropertyType( loadClass( attributes.getValue( "type" ) ) );
       
        if ( propertyName != null && propertyName.length() > 0 ) {
            configureDescriptor(descriptor);
        } else {
            String value = attributes.getValue( "value" );
            if ( value != null ) {
                descriptor.setTextExpression( new ConstantExpression( value ) );
            }
        }

        Object top = digester.peek();
        if ( top instanceof ElementDescriptor ) {
View Full Code Here

TOP

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

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.