commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly JellyContext.java
Date Wed, 27 Nov 2002 12:43:20 GMT
jstrachan    2002/11/27 04:43:20

  Modified:    jelly/src/java/org/apache/commons/jelly/expression/jexl
                        JexlExpressionFactory.java JexlExpression.java
               jelly/src/java/org/apache/commons/jelly/tags/xml
                        XPathExpression.java XMLTagLibrary.java
               jelly/src/java/org/apache/commons/jelly/tags/junit
                        JUnitTagLibrary.java
               jelly/src/java/org/apache/commons/jelly/tags/jsl
                        XPathPatternExpression.java JSLTagLibrary.java
               jelly/src/java/org/apache/commons/jelly/expression
                        CompositeExpression.java ConstantExpression.java
                        Expression.java
               jelly/src/java/org/apache/commons/jelly/tags/beanshell
                        BeanShellExpression.java
               jelly/src/java/org/apache/commons/jelly/tags/bsf
                        BSFExpression.java
               jelly/src/java/org/apache/commons/jelly JellyContext.java
  Log:
  Added a new getExpressionText() method to Expression so that we can easily find the textual
representation of what the expression really looks like.
  
  Revision  Changes    Path
  1.12      +9 -5      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/jexl/JexlExpressionFactory.java
  
  Index: JexlExpressionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/jexl/JexlExpressionFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JexlExpressionFactory.java	30 Oct 2002 19:16:31 -0000	1.11
  +++ JexlExpressionFactory.java	27 Nov 2002 12:43:18 -0000	1.12
  @@ -115,6 +115,10 @@
                       return answer;
                   }
                   
  +                public String getExpressionText() {
  +                    return text;
  +                }
  +                
                   public String toString() {
                       return super.toString() + "[expression:" + text + "]";
                   }
  
  
  
  1.12      +16 -6     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java
  
  Index: JexlExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JexlExpression.java	30 Oct 2002 19:16:31 -0000	1.11
  +++ JexlExpression.java	27 Nov 2002 12:43:19 -0000	1.12
  @@ -102,13 +102,23 @@
       
       // Expression interface
       //------------------------------------------------------------------------- 
  +    public String getExpressionText() {
  +        return expression.getExpression();
  +    }
  +    
       public Object evaluate(JellyContext context) {
           try {
               JexlContext jexlContext = new JellyJexlContext( context );
               if (log.isDebugEnabled()) {
                   log.debug("Evaluating EL: " + expression);
               }           
  -            return expression.evaluate(jexlContext);
  +            Object value = expression.evaluate(jexlContext);
  +            
  +            if (log.isDebugEnabled()) {
  +                log.debug("value of expression: " + value);
  +            }
  +            
  +            return value;           
           }
           catch (Exception e) {
               log.warn("Caught exception evaluating: " + expression + ". Reason: " + e, e);
  
  
  
  1.10      +12 -6     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathExpression.java
  
  Index: XPathExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathExpression.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XPathExpression.java	13 Nov 2002 09:03:31 -0000	1.9
  +++ XPathExpression.java	27 Nov 2002 12:43:19 -0000	1.10
  @@ -91,13 +91,15 @@
       /** The Log to which logging calls will be made. */
       private Log log = LogFactory.getLog(XPathExpression.class);
   
  +    private String text;
       private XPath xpath;
       private JellyContext context;
       
       public XPathExpression() {
       }
   
  -    public XPathExpression(XPath xpath, TagScript tagScript) {
  +    public XPathExpression(String text, XPath xpath, TagScript tagScript) {
  +        this.text = text;
           this.xpath = xpath;
           
           Map namespaceContext = tagScript.getNamespaceContext();
  @@ -117,6 +119,10 @@
               
       // Expression interface
       //------------------------------------------------------------------------- 
  +    public String getExpressionText() {
  +        return text;
  +    }
  +    
       public Object evaluate(JellyContext context) {
           this.context = context;
           xpath.setVariableContext(this);
  
  
  
  1.16      +6 -6      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java
  
  Index: XMLTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- XMLTagLibrary.java	8 Nov 2002 18:27:51 -0000	1.15
  +++ XMLTagLibrary.java	27 Nov 2002 12:43:19 -0000	1.16
  @@ -117,7 +117,7 @@
   
               try {
                   XPath xpath = new Dom4jXPath(attributeValue);
  -                return new XPathExpression(xpath, tagScript);
  +                return new XPathExpression(attributeValue, xpath, tagScript);
               }
               catch (JaxenException e) {
                   throw new JellyException( "Could not parse XPath expression: \"" + attributeValue
+ "\" reason: " + e, e );
  
  
  
  1.6       +1 -1      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
  
  Index: JUnitTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JUnitTagLibrary.java	8 Nov 2002 18:27:51 -0000	1.5
  +++ JUnitTagLibrary.java	27 Nov 2002 12:43:19 -0000	1.6
  @@ -111,7 +111,7 @@
               
               try {
                   XPath xpath = new Dom4jXPath(attributeValue);
  -                return new XPathExpression(xpath, tagScript);
  +                return new XPathExpression(attributeValue, xpath, tagScript);
               }
               catch (JaxenException e) {
                   throw new JellyException( "Could not parse XPath expression: \"" + attributeValue
+ "\" reason: " + e, e );            
  
  
  
  1.3       +8 -4      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/XPathPatternExpression.java
  
  Index: XPathPatternExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/XPathPatternExpression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XPathPatternExpression.java	30 Oct 2002 19:16:34 -0000	1.2
  +++ XPathPatternExpression.java	27 Nov 2002 12:43:19 -0000	1.3
  @@ -79,18 +79,22 @@
     * @version $Revision$
     */
   public class XPathPatternExpression extends ExpressionSupport implements VariableContext
{
  -    
  +
  +    private String text;    
       private Pattern pattern;
       private JellyContext context;
       
  -    public XPathPatternExpression() {
  -    }
  -    public XPathPatternExpression(Pattern pattern) {
  +    public XPathPatternExpression(String text, Pattern pattern) {
  +        this.text = text;
           this.pattern = pattern;
       }
       
       // Expression interface
       //------------------------------------------------------------------------- 
  +    public String getExpressionText() {
  +        return text;
  +    }
  +    
       public Object evaluate(JellyContext context) {
           this.context = context;
           //pattern.setVariableContext(this);
  
  
  
  1.6       +2 -2      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/JSLTagLibrary.java
  
  Index: JSLTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/JSLTagLibrary.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JSLTagLibrary.java	8 Nov 2002 18:27:52 -0000	1.5
  +++ JSLTagLibrary.java	27 Nov 2002 12:43:20 -0000	1.6
  @@ -119,7 +119,7 @@
               
               try {
                   XPath xpath = new Dom4jXPath(attributeValue);
  -                return new XPathExpression(xpath, tagScript);
  +                return new XPathExpression(attributeValue, xpath, tagScript);
               }
               catch (JaxenException e) {
                   throw new JellyException( "Could not parse XPath expression: \"" + attributeValue
+ "\" reason: " + e, e );            
  @@ -133,7 +133,7 @@
               
               try {
                   Pattern pattern = DocumentHelper.createPattern( attributeValue );
  -                return new XPathPatternExpression(pattern);
  +                return new XPathPatternExpression(attributeValue, pattern);
               }
               catch (Exception e) {
                   throw new JellyException( "Could not parse XPath expression: \"" + attributeValue
+ "\" reason: " + e, e );            
  
  
  
  1.5       +10 -1     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/CompositeExpression.java
  
  Index: CompositeExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/CompositeExpression.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CompositeExpression.java	13 Nov 2002 16:55:27 -0000	1.4
  +++ CompositeExpression.java	27 Nov 2002 12:43:20 -0000	1.5
  @@ -94,7 +94,7 @@
       public String toString() {
           return super.toString() + "[expressions=" + expressions +"]";
       }
  -
  +    
       /**
        * Parses the given String to be either a ConstantExpresssion, an Expression denoted
as
        * "${foo}" or some String with embedded expresssions such as "abc${something}def${else}xyz"
  @@ -330,6 +330,15 @@
       
       // Expression interface
       //-------------------------------------------------------------------------
  +    
  +    public String getExpressionText() {
  +        StringBuffer buffer = new StringBuffer();
  +        for (Iterator iter = expressions.iterator(); iter.hasNext(); ) {
  +            Expression expression = (Expression) iter.next();
  +            buffer.append( expression.getExpressionText() );
  +        }
  +        return buffer.toString();
  +    }
       
           
       // inherit javadoc from interface
  
  
  
  1.6       +9 -5      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/ConstantExpression.java
  
  Index: ConstantExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/ConstantExpression.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ConstantExpression.java	30 Oct 2002 19:16:18 -0000	1.5
  +++ ConstantExpression.java	27 Nov 2002 12:43:20 -0000	1.6
  @@ -90,6 +90,10 @@
           return super.toString() + "[value=" + value +"]";
       }
       
  +    public String getExpressionText() {
  +        return value == null ? "null" : value.toString();
  +    }
  +    
       /** 
         * Evaluate expression against given context.
         *
  
  
  
  1.8       +9 -5      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/Expression.java
  
  Index: Expression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/Expression.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Expression.java	30 Oct 2002 19:16:19 -0000	1.7
  +++ Expression.java	27 Nov 2002 12:43:20 -0000	1.8
  @@ -73,6 +73,10 @@
     */
   public interface Expression {
   
  +    /**
  +     * @return the textual representation of this expression
     */
  +    public String getExpressionText();
  +    
       /** 
        * Evaluates the expression with the given context
        * and returns the result 
  
  
  
  1.9       +4 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpression.java
  
  Index: BeanShellExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpression.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BeanShellExpression.java	30 Oct 2002 19:16:27 -0000	1.8
  +++ BeanShellExpression.java	27 Nov 2002 12:43:20 -0000	1.9
  @@ -87,6 +87,10 @@
   
       // Expression interface
       //------------------------------------------------------------------------- 
  +    public String getExpressionText() {
  +        return text;
  +    }
  +    
       public Object evaluate(JellyContext context) {
           try {
               JellyInterpreter interpreter = new JellyInterpreter();
  
  
  
  1.8       +4 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/bsf/BSFExpression.java
  
  Index: BSFExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/bsf/BSFExpression.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BSFExpression.java	30 Oct 2002 19:16:22 -0000	1.7
  +++ BSFExpression.java	27 Nov 2002 12:43:20 -0000	1.8
  @@ -103,6 +103,10 @@
   
       // Expression interface
       //------------------------------------------------------------------------- 
  +    public String getExpressionText() {
  +        return text;
  +    }
  +    
       public Object evaluate(JellyContext context) {
           // XXXX: unfortunately we must sychronize evaluations
           // so that we can swizzle in the context.
  
  
  
  1.35      +4 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java
  
  Index: JellyContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/JellyContext.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- JellyContext.java	27 Nov 2002 08:30:17 -0000	1.34
  +++ JellyContext.java	27 Nov 2002 12:43:20 -0000	1.35
  @@ -208,6 +208,10 @@
                   // ignore security exceptions
               }
           }
  +        
  +        if (log.isDebugEnabled()) {
  +            log.debug("findVariable: " + name + " value: " + answer );
  +        }
           return answer;
       }
               
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message