morgand 2003/01/23 23:40:59
Modified:
jelly/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell
BeanShellExpressionFactory.java
jelly/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf
BSFExpressionFactory.java
jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl
JSLTagLibrary.java
jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit
JUnitTagLibrary.java
jelly/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml
XMLTagLibrary.java
jelly/src/java/org/apache/commons/jelly TagLibrary.java
jelly/src/java/org/apache/commons/jelly/expression
CompositeExpression.java ExpressionFactory.java
jelly/src/java/org/apache/commons/jelly/expression/jexl
JexlExpressionFactory.java
jelly/src/test/org/apache/commons/jelly/tags/junit
JUnitTagLibrary.java
Log:
converting Exceptions to JellyExceptions
Revision Changes Path
1.2 +5 -4
jakarta-commons-sandbox/jelly/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java
Index: BeanShellExpressionFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/beanshell/src/java/org/apache/commons/jelly/tags/beanshell/BeanShellExpressionFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BeanShellExpressionFactory.java 11 Jan 2003 13:27:29 -0000 1.1
+++ BeanShellExpressionFactory.java 24 Jan 2003 07:40:58 -0000 1.2
@@ -64,6 +64,7 @@
import bsh.EvalError;
import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.expression.Expression;
import org.apache.commons.jelly.expression.ExpressionFactory;
@@ -102,7 +103,7 @@
// ExpressionFactory interface
//-------------------------------------------------------------------------
- public Expression createExpression(String text) throws Exception {
+ public Expression createExpression(String text) throws JellyException {
return new BeanShellExpression(text);
}
}
1.2 +10 -5
jakarta-commons-sandbox/jelly/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpressionFactory.java
Index: BSFExpressionFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/bsf/src/java/org/apache/commons/jelly/tags/bsf/BSFExpressionFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BSFExpressionFactory.java 8 Jan 2003 05:02:47 -0000 1.1
+++ BSFExpressionFactory.java 24 Jan 2003 07:40:58 -0000 1.2
@@ -61,6 +61,7 @@
*/
package org.apache.commons.jelly.tags.bsf;
+import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.expression.Expression;
import org.apache.commons.jelly.expression.ExpressionFactory;
import org.apache.commons.logging.Log;
@@ -127,8 +128,12 @@
// ExpressionFactory interface
//-------------------------------------------------------------------------
- public Expression createExpression(String text) throws Exception {
- return new BSFExpression( text, getBSFEngine(), getBSFManager(), registry );
+ public Expression createExpression(String text) throws JellyException {
+ try {
+ return new BSFExpression( text, getBSFEngine(), getBSFManager(),
registry );
+ } catch (BSFException e) {
+ throw new JellyException("Could not obtain BSF engine",e);
+ }
}
// Implementation methods
1.11 +1 -1
jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/JSLTagLibrary.java
Index: JSLTagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/jsl/src/java/org/apache/commons/jelly/tags/jsl/JSLTagLibrary.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- JSLTagLibrary.java 16 Jan 2003 09:20:47 -0000 1.10
+++ JSLTagLibrary.java 24 Jan 2003 07:40:58 -0000 1.11
@@ -95,7 +95,7 @@
ExpressionFactory factory,
TagScript tagScript,
String attributeName,
- String attributeValue) throws Exception {
+ String attributeValue) throws JellyException {
// #### may need to include some namespace URI information in the XPath
instance?
1.2 +9 -14
jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
Index: JUnitTagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/junit/src/java/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JUnitTagLibrary.java 19 Jan 2003 06:17:10 -0000 1.1
+++ JUnitTagLibrary.java 24 Jan 2003 07:40:59 -0000 1.2
@@ -99,7 +99,7 @@
ExpressionFactory factory,
TagScript tagScript,
String attributeName,
- String attributeValue) throws Exception {
+ String attributeValue) throws JellyException {
// #### may need to include some namespace URI information in the XPath
instance?
@@ -108,18 +108,13 @@
log.debug( "Parsing XPath expression: " + attributeValue );
}
- try {
- // XPath xpath = new Dom4jXPath(attributeValue);
- Expression xpathExpr = super.createExpression( factory,
+ // XPath xpath = new Dom4jXPath(attributeValue);
+ Expression xpathExpr = super.createExpression( factory,
tagScript,
attributeName,
attributeValue );
- return new XPathExpression(attributeValue, xpathExpr, tagScript);
- }
- catch (JaxenException e) {
- throw new JellyException( "Could not parse XPath expression: \"" +
attributeValue + "\" reason: " + e, e );
- }
+ return new XPathExpression(attributeValue, xpathExpr, tagScript);
}
// will use the default expression instead
1.2 +8 -7
jakarta-commons-sandbox/jelly/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java
Index: XMLTagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLTagLibrary.java 15 Jan 2003 23:56:45 -0000 1.1
+++ XMLTagLibrary.java 24 Jan 2003 07:40:59 -0000 1.2
@@ -61,6 +61,7 @@
*/
package org.apache.commons.jelly.tags.xml;
+import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.TagLibrary;
import org.apache.commons.jelly.expression.Expression;
import org.apache.commons.jelly.expression.ExpressionFactory;
@@ -111,7 +112,7 @@
ExpressionFactory factory,
TagScript tagScript,
String attributeName,
- String attributeValue) throws Exception {
+ String attributeValue) throws JellyException {
// #### may need to include some namespace URI information in the XPath
instance?
@@ -131,7 +132,7 @@
return super.createExpression(factory, tagScript, attributeName,
attributeValue);
}
- protected Expression createXPathTextExpression(String exprText) throws
Exception {
+ protected Expression createXPathTextExpression(String exprText) throws
JellyException {
return CompositeExpression.parse( exprText,
this.jexlFactory );
}
1.22 +6 -6
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java
Index: TagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- TagLibrary.java 24 Jan 2003 06:41:22 -0000 1.21
+++ TagLibrary.java 24 Jan 2003 07:40:59 -0000 1.22
@@ -156,7 +156,7 @@
TagScript tagScript,
String attributeName,
String attributeValue)
- throws Exception {
+ throws JellyException {
ExpressionFactory myFactory = getExpressionFactory();
if (myFactory == null) {
1.6 +1 -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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CompositeExpression.java 27 Nov 2002 12:43:20 -0000 1.5
+++ CompositeExpression.java 24 Jan 2003 07:40:59 -0000 1.6
@@ -109,7 +109,7 @@
* @throws Exception if there was some problem creating the underlying
Expression object
* from the ExpressionFactory
*/
- public static Expression parse(String text, ExpressionFactory factory) throws
Exception {
+ public static Expression parse(String text, ExpressionFactory factory) throws
JellyException {
int len = text.length();
1.6 +8 -6
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/ExpressionFactory.java
Index: ExpressionFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/ExpressionFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ExpressionFactory.java 11 Dec 2002 12:41:00 -0000 1.5
+++ ExpressionFactory.java 24 Jan 2003 07:40:59 -0000 1.6
@@ -62,6 +62,8 @@
package org.apache.commons.jelly.expression;
+import org.apache.commons.jelly.JellyException;
+
/** <p><code>ExpressionFactory</code> is a factory of Expression objects.</p>
*
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
@@ -73,6 +75,6 @@
* Creates a new expression for the given text
*/
- public Expression createExpression(String text) throws Exception;
+ public Expression createExpression(String text) throws JellyException;
}
1.14 +44 -28
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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- JexlExpressionFactory.java 27 Nov 2002 13:07:27 -0000 1.13
+++ JexlExpressionFactory.java 24 Jan 2003 07:40:59 -0000 1.14
@@ -63,6 +63,7 @@
package org.apache.commons.jelly.expression.jexl;
import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyException;
import org.apache.commons.jelly.expression.Expression;
import org.apache.commons.jelly.expression.ExpressionSupport;
import org.apache.commons.jelly.expression.ExpressionFactory;
@@ -86,7 +87,7 @@
// ExpressionFactory interface
//-------------------------------------------------------------------------
- public Expression createExpression(final String text) throws Exception {
+ public Expression createExpression(String text) throws JellyException {
/*
org.apache.commons.jexl.Expression expr =
@@ -99,32 +100,18 @@
return new JexlExpression( expr );
*/
- final Expression jexlExpression = new JexlExpression(
+ Expression jexlExpression = null;
+ try {
+ // this method really does throw Exception
+ jexlExpression = new JexlExpression(
org.apache.commons.jexl.ExpressionFactory.createExpression(text)
);
+ } catch (Exception e) {
+ throw new JellyException(e);
+ }
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);
- }
-
- return answer;
- }
-
- public String getExpressionText() {
- return "${" + text + "}";
- }
-
- public String toString() {
- return super.toString() + "[expression:" + text + "]";
- }
- };
-
- return expr;
+ return new ExpressionSupportLocal(jexlExpression,text);
}
return jexlExpression;
}
@@ -165,6 +152,35 @@
}
}
return true;
+ }
+
+ private class ExpressionSupportLocal extends ExpressionSupport {
+
+ protected Expression jexlExpression = null;
+ protected String text = null;
+
+ public ExpressionSupportLocal(Expression jexlExpression, String text) {
+ this.jexlExpression = jexlExpression;
+ this.text = text;
+ }
+
+ public Object evaluate(JellyContext context) {
+ Object answer = jexlExpression.evaluate(context);
+
+ if ( answer == null ) {
+ answer = context.getVariable(text);
+ }
+
+ return answer;
+ }
+
+ public String getExpressionText() {
+ return "${" + text + "}";
+ }
+
+ public String toString() {
+ return super.toString() + "[expression:" + text + "]";
+ }
}
}
1.2 +12 -17
jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java
Index: JUnitTagLibrary.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/tags/junit/JUnitTagLibrary.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JUnitTagLibrary.java 19 Jan 2003 06:03:12 -0000 1.1
+++ JUnitTagLibrary.java 24 Jan 2003 07:40:59 -0000 1.2
@@ -99,7 +99,7 @@
ExpressionFactory factory,
TagScript tagScript,
String attributeName,
- String attributeValue) throws Exception {
+ String attributeValue) throws JellyException {
// #### may need to include some namespace URI information in the XPath
instance?
@@ -108,18 +108,13 @@
log.debug( "Parsing XPath expression: " + attributeValue );
}
- try {
- // XPath xpath = new Dom4jXPath(attributeValue);
- Expression xpathExpr = super.createExpression( factory,
- tagScript,
- attributeName,
- attributeValue );
+ // XPath xpath = new Dom4jXPath(attributeValue);
+ Expression xpathExpr = super.createExpression( factory,
+ tagScript,
+ attributeName,
+ attributeValue );
- return new XPathExpression(attributeValue, xpathExpr, tagScript);
- }
- catch (JaxenException e) {
- throw new JellyException( "Could not parse XPath expression: \"" +
attributeValue + "\" reason: " + e, e );
- }
+ return new XPathExpression(attributeValue, xpathExpr, tagScript);
}
// will use the default expression instead
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>