Examples of AttributeDescriptor


Examples of org.apache.commons.betwixt.AttributeDescriptor

                    if ( getBindingConfiguration().getMapIDs() ) {
                       ref = getBindingConfiguration().getIdMappingStrategy().getReferenceFor(context, 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();
                            getBindingConfiguration().getIdMappingStrategy().setReference(context, bean, id);
                           
                            if ( getBindingConfiguration().getMapIDs() ) {
                                // write element with id
                                writeElement(
                                    namespaceUri,
                                    localName,
                                    qualifiedName,
                                    elementDescriptor,
                                    context ,
                                    beanInfo.getIDAttributeName(),
                                    id);
                                   

                            } else {   
                                // write element without ID
                                writeElement(
                                    namespaceUri,
                                    localName,
                                    qualifiedName,
                                    elementDescriptor,
                                    context );
                            }
                                                       
                        } else {
                            // use id from bean property
                            // it's up to the user to ensure uniqueness
                            Expression idExpression = idAttribute.getTextExpression();
                            if(idExpression == null) {
                                   throw new IntrospectionException(
                                         "The specified id property wasn't found in the bean ("
                                        + idAttribute + ").");
                            }
View Full Code Here

Examples of org.apache.commons.betwixt.AttributeDescriptor

        }
           
        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

Examples of org.apache.commons.betwixt.AttributeDescriptor

        private void init(AttributeDescriptor[] baseAttributes) {
            attributes = new AttributeDescriptor[baseAttributes.length];
            values = new String[baseAttributes.length];
            int index = 0;
            for (int i=0, size=baseAttributes.length; i<size; i++) {
                AttributeDescriptor baseAttribute = baseAttributes[i];
                String attributeValue = valueAttribute(baseAttribute);
                if (attributeValue != null
                        && !context.getValueSuppressionStrategy()
                            .suppressAttribute(baseAttribute, attributeValue)) {
                    values[index] = attributeValue;
View Full Code Here

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

Examples of org.apache.commons.betwixt.AttributeDescriptor

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

Examples of org.apache.commons.betwixt.AttributeDescriptor

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

Examples of org.apache.commons.betwixt.AttributeDescriptor

    /**
     * Process the end of this element.
     */
    public void end(String name, String namespace) {
        AttributeDescriptor descriptor = (AttributeDescriptor)digester.pop();
        ElementDescriptor parent = (ElementDescriptor)digester.peek();

        // check for attribute suppression
        if( getXMLIntrospector().getConfiguration().getAttributeSuppressionStrategy().suppress(descriptor)) {
            parent.removeAttributeDescriptor(descriptor);
View Full Code Here

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

Examples of org.apache.commons.betwixt.AttributeDescriptor

                    if ( getBindingConfiguration().getMapIDs() ) {
                        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 ( getBindingConfiguration().getMapIDs() ) {
                                // write element with id
                                writeElement(
                                    namespaceUri,
                                    localName,
                                    qualifiedName,
                                    elementDescriptor,
                                    context ,
                                    beanInfo.getIDAttributeName(),
                                    id);
                                   
                            } else {   
                                // write element without ID
                                writeElement(
                                    namespaceUri,
                                    localName,
                                    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

Examples of org.apache.commons.betwixt.AttributeDescriptor

        }
           
        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
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.