Package org.apache.commons.jelly.expression

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


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

     *             if there is an error parsing the project FIXME
     */
    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 );
        // We can use a Reader and not an URL/path here to read
        // the POM because this is a memory model without XML entities.
        project = new Project( new StringReader( newProjectString ) );
        return project;
    }
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

                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 ( 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 ) )
            {
                LOGGER.debug( "Using default goal: " + defaultGoalName );
View Full Code Here

            if ( log.isDebugEnabled() ) {
                log.debug( "Parsing XPath expression: " + attributeValue );
            }

            // XPath xpath = new Dom4jXPath(attributeValue);
            Expression xpathExpr = super.createExpression( factory,
                                                           tagScript,
                                                           attributeName,
                                                           attributeValue );

            return new XPathExpression(attributeValue, xpathExpr, tagScript);
View Full Code Here

        }

        return new JexlExpression( expr );
*/

        Expression jexlExpression = null;
        try {
            // this method really does throw Exception
            jexlExpression = new JexlExpression(
            org.apache.commons.jexl.ExpressionFactory.createExpression(text)
            );
View Full Code Here

                if ( attribute.isRequired() ) {
                    throw new MissingAttributeException(name);
                }
                // lets get the default value
                Object value = null;
                Expression expression = attribute.getDefaultValue();
                if ( expression != null ) {
                    value = expression.evaluate(context);
                }

                // only set non-null values?
                if ( value != null ) {
                    super.setAttribute(name, value);
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.