Package org.apache.commons.betwixt.expression

Examples of org.apache.commons.betwixt.expression.Expression


            log.trace( "Element has attributes." );
            return false;
        }
       
        // an element is not empty if it has a non-empty body
        Expression expression = descriptor.getTextExpression();
        if ( expression != null ) {
            Object value = expression.evaluate( context );
            String text = convertToString( value, descriptor, context );
            if ( text != null && text.length() > 0 ) {
                log.trace( "Element has body text which isn't empty." );
                return false;
            }
        }
       
        // always write out loops - even when they have no elements
        if ( descriptor.isCollective() ) {
            log.trace("Loop type so not empty.");
            return false;
        }
       
        // now test child elements
        // an element is empty if it has no non-empty child elements
        if ( descriptor.hasChildren() ) {
            for ( int i=0, size=descriptor.getElementDescriptors().length; i<size; i++ ) {
                if ( ! isEmptyElement( descriptor.getElementDescriptors()[i], context ) ) {
                    log.trace( "Element has child which isn't empty." );
                    return false;
                }
            }
        }
       
        if ( descriptor.isHollow() )
        {
            Expression contentExpression = descriptor.getContextExpression();
            if (contentExpression != null) {
                Object childBean = contentExpression.evaluate(context);
                if (childBean != null)
                {
                    XMLBeanInfo xmlBeanInfo = findXMLBeanInfo(childBean, descriptor);
                    Object currentBean = context.getBean();
                    context.setBean(childBean);
View Full Code Here


    protected void writeAttribute(
                        AttributeDescriptor attributeDescriptor,
                        Context context )
                            throws
                                IOException, SAXException {
        Expression expression = attributeDescriptor.getTextExpression();
        if ( expression != null ) {
            Object value = expression.evaluate( context );
            if ( value != null ) {
                String text = value.toString();
                if ( text != null && text.length() > 0 ) {
                    expressAttribute(
                                    attributeDescriptor.getURI(),
View Full Code Here

            }
            length = index;
        }
       
        private String valueAttribute(AttributeDescriptor attribute) {
            Expression expression = attribute.getTextExpression();
            if ( expression != null ) {
                Object value = expression.evaluate( context );
                return convertToString( value, attribute, context );
            }
           
            return "";
        }
View Full Code Here

            log.trace("Creating descriptor for property: name="
                + getPropertyName() + " type=" + getPropertyType());
        }
       
        NodeDescriptor descriptor = null;
        Expression propertyExpression = getPropertyExpression();
        Updater propertyUpdater = getPropertyUpdater();
       
        if ( propertyExpression == null ) {
            if (log.isTraceEnabled()) {
                log.trace( "No read method for property: name="
View Full Code Here

        if ( childDescriptors != null && childDescriptors.length > 0 ) {
            // process child elements
            for ( int i = 0, size = childDescriptors.length; i < size; i++ ) {
                ElementDescriptor childDescriptor = childDescriptors[i];
                Context childContext = context;
                Expression childExpression = childDescriptor.getContextExpression();
                if ( childExpression != null ) {
                    Object childBean = childExpression.evaluate( context );
                    if ( childBean != null ) {
                        String qualifiedName = childDescriptor.getQualifiedName();
                        // XXXX: should we handle nulls better
                        if ( childBean instanceof Iterator ) {
                            for ( Iterator iter = (Iterator) childBean; iter.hasNext(); ) {
                                Object object = iter.next();
                                if (object == null) {
                                    continue;
                                }
                                if ( ! writtenContent ) {
                                    writtenContent = true;
                                    if (elementDescriptor.isWrapCollectionsInElement()) {
                                        expressTagClose();
                                    }
                                }
                                ++indentLevel;
                                write( qualifiedName, object );
                                --indentLevel;
                            }
                        } else {
                            if ( ! writtenContent ) {
                                writtenContent = true;
                                expressTagClose();
                            }
                            ++indentLevel;
                            write( qualifiedName, childBean );
                            --indentLevel;
                        }
                    }                   
                } else {
                    if ( ! writtenContent ) {
                        writtenContent = true;
                        expressTagClose();
                    }
                    if (childDescriptor.isWrapCollectionsInElement()) {
                        ++indentLevel;
                    }

                     write( childDescriptor.getQualifiedName(), childDescriptor, childContext );

                    if (childDescriptor.isWrapCollectionsInElement()) {
                        --indentLevel;
                    }
                }
            }
            if ( writtenContent ) {
                writePrintln();
                writeIndent();
            }
        } else {
            // evaluate the body text
            Expression expression = elementDescriptor.getTextExpression();
            if ( expression != null ) {
                Object value = expression.evaluate( context );
                if ( value != null ) {
                    String text = value.toString();
                    if ( text != null && text.length() > 0 ) {
                        if ( ! writtenContent ) {
                            writtenContent = true;
View Full Code Here

    protected void writeAttribute(
                        AttributeDescriptor attributeDescriptor,
                        Context context )
                            throws
                                IOException, SAXException {
        Expression expression = attributeDescriptor.getTextExpression();
        if ( expression != null ) {
            Object value = expression.evaluate( context );
            if ( value != null ) {
                String text = value.toString();
                if ( text != null && text.length() > 0 ) {
                    expressAttribute(attributeDescriptor.getQualifiedName(), text);
                }
View Full Code Here

TOP

Related Classes of org.apache.commons.betwixt.expression.Expression

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.