Package org.apache.commons.betwixt

Examples of org.apache.commons.betwixt.AttributeDescriptor


    Log log = getLog();
    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(this, value);
        }
      }
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

     * @param attributes The attribute list of this element
     * @throws SAXException if the attribute tag is not inside an element tag
     */
    public void begin(Attributes attributes) throws SAXException {
       
        AttributeDescriptor descriptor = new AttributeDescriptor();
        String name = attributes.getValue( "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

                    if ( writeIDs ) {
                        ref = (String) idMap.get( context.getBean() );
                    }
                    if ( ref == null ) {
                        // this is the first time that this bean has be written
                        AttributeDescriptor idAttribute = beanInfo.getIDAttribute();
                        if (idAttribute == null) {
                            // use a generated id
                            id = idGenerator.nextId();
                            idMap.put( bean, id );
                           
                            if ( writeIDs ) {
                                // write element with id
                                write(
                                    qualifiedName,
                                    elementDescriptor,
                                    context ,
                                    beanInfo.getIDAttributeName(),
                                    id);
                                   
                            } else {   
                                // write element without ID
                                write(
                                    qualifiedName,
                                    elementDescriptor,
                                    context );
                            }
                                                       
                        } else {
                            // use id from bean property
                            // it's up to the user to ensure uniqueness
                            // XXX should we trap nulls?
                            Object exp = idAttribute.getTextExpression().evaluate( context );
                            if (exp == null) {
                                // we'll use a random id
                                log.debug("Using random id");
                                id = idGenerator.nextId();
                               
View Full Code Here

        }
           
        AttributeDescriptor[] attributeDescriptors = elementDescriptor.getAttributeDescriptors();
        if ( attributeDescriptors != null ) {
            for ( int i = 0, size = attributeDescriptors.length; i < size; i++ ) {
                AttributeDescriptor attributeDescriptor = attributeDescriptors[i];
                writeAttribute( attributeDescriptor, context );
            }
        }
    }
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

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.