Package org.apache.commons.jelly.expression

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


                        // this is O(N) operation, but we don't expect there to be a lot of collisions.
                        int idx = actual.getIndex(name);
                        if(idx>=0actual.removeAttribute(idx);
                    }

                    Expression expression = e.getValue().exp;
                    actual.addAttribute("",name,name,"CDATA",expression.evaluateAsString(context));
                }

                try {
                    output.startElement(tagName,actual);
                    getTagBody().run(context,output);
View Full Code Here


        }

        if ( defaultGoalName != null )
        {
            // By evaluating expression now it has the same scope as the POM.
            Expression e = JellyUtils.decomposeExpression( defaultGoalName, baseContext );
            defaultGoalName = e.evaluateAsString( baseContext );
            baseContext.setVariable( MavenConstants.DEFAULT_GOAL, defaultGoalName );

            if ( goals != null && goals.size() == 0 )
            {
                log.debug( "Using default goal: " + defaultGoalName );
View Full Code Here

    /** @see ExpressionFactory
     */
    public Expression createExpression( final String text )
        throws JellyException
    {
        Expression expression = null;
        try
        {
            expression = new JexlExpression( org.apache.commons.jexl.ExpressionFactory.createExpression( text ) );
        }
        catch ( Exception anException )
        {
            throw new JellyException( "error evaluating expression", anException );
        }

        final Expression jexlExpression = expression;

        if ( isSupportAntVariables() && isValidAntVariableName( text ) )
        {
            ExpressionSupport expr = new ExpressionSupport()
            {
                public Object evaluate( JellyContext context )
                {
                    Object answer = jexlExpression.evaluate( context );

                    if ( answer == null )
                    {
                        answer = context.getVariable( text );

View Full Code Here

     *
     * @return The recursively evaluated Jelly expression.
     */
    public static Expression decomposeExpression( String text, JellyContext context )
    {
        Expression expression = null;

        try
        {
            expression = CompositeExpression.parse( text, mavenExpressionFactory );

            String expressionText = expression.evaluateAsString( context );

            if ( CompositeExpression.parse( expressionText, mavenExpressionFactory ) instanceof CompositeExpression )
            {
                expression = decomposeExpression( expressionText, context );
            }
View Full Code Here

        if ( pomToExtend != null && useParentPom )
        {
            // We must look in the <extend/> element for expressions that may be present as
            //
            // <extend>../project.xml</extend>
            Expression e = JellyUtils.decomposeExpression( pomToExtend, context );
            pomToExtend = e.evaluateAsString( context );
            pomToExtend = MavenUtils.makeAbsolutePath( projectDescriptor.getParentFile(), pomToExtend );
            project.setExtend( pomToExtend );

            File parentPom = new File( pomToExtend );
            parentPom = parentPom.getCanonicalFile();
View Full Code Here

     */
    private static Project getInterpolatedPOM( Project project, JellyContext context )
        throws Exception
    {
        String projectString = project.getProjectAsString();
        Expression e = JellyUtils.decomposeExpression( projectString, context );
        String newProjectString = e.evaluateAsString( context );
        project = new Project( new StringReader( newProjectString ) );
        return project;
    }
View Full Code Here

                if ( value instanceof String )
                {
                    try
                    {
                        String literalValue = (String) value;
                        Expression expr = CompositeExpression.parse( literalValue, factory );

                        if ( expr != null )
                        {
                            value = expr;
                        }
View Full Code Here

        }

        if ( value instanceof Expression )
        {
            // TODO: need to handle instances of infinitely recursion when an expression contains itself
            Expression expression = (Expression) value;
            value = expression.evaluate( this );
        }

        return value;
    }
View Full Code Here

        assertExpression( "foo.equals( \"xyz\" )", Boolean.FALSE );
    }   
   
    /** Evaluates the given expression text and tests it against the expected value */
    protected void assertExpression( String expressionText, Object expectedValue ) throws Exception {
        Expression expr = factory.createExpression( expressionText );
        Object value = expr.evaluate( context );
        assertEquals( "Value of expression: " + expressionText, expectedValue, value );
    }       
View Full Code Here

        }
       
        return new JexlExpression( expr );
*/       

        final Expression jexlExpression = new JexlExpression(
            org.apache.commons.jexl.ExpressionFactory.createExpression(text)
            );

        if ( isSupportAntVariables() && isValidAntVariableName(text) ) {
            ExpressionSupport expr = new ExpressionSupport() {
                    public Object evaluate(JellyContext context) {
                        Object answer = jexlExpression.evaluate(context);

                        if ( answer == null ) {
                            answer = context.getVariable(text);
                        }

View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.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.