morgand 2003/01/24 11:03:25
Modified: jelly/src/java/org/apache/commons/jelly
MissingAttributeException.java Script.java Tag.java
TagSupport.java
jelly/src/java/org/apache/commons/jelly/impl
BreakException.java ExpressionScript.java
ScriptBlock.java StaticTagScript.java
TagScript.java TextScript.java
jelly/src/test/org/apache/commons/jelly/core TestArgTag.java
Log:
implementing JellyTagException as an script execution time version of
JellyException
Revision Changes Path
1.3 +1 -1
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/MissingAttributeException.java
Index: MissingAttributeException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/MissingAttributeException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- MissingAttributeException.java 30 Oct 2002 19:16:26 -0000 1.2
+++ MissingAttributeException.java 24 Jan 2003 19:03:23 -0000 1.3
@@ -68,7 +68,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
* @version $Revision$
*/
-public class MissingAttributeException extends JellyException {
+public class MissingAttributeException extends JellyTagException {
private String missingAttribute;
1.9 +6 -6
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Script.java
Index: Script.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Script.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Script.java 24 Jan 2003 05:26:13 -0000 1.8
+++ Script.java 24 Jan 2003 19:03:24 -0000 1.9
@@ -80,6 +80,6 @@
public Script compile() throws JellyException;
/** Evaluates the body of a tag */
- public void run(JellyContext context, XMLOutput output) throws JellyException;
+ public void run(JellyContext context, XMLOutput output) throws
JellyTagException;
}
1.12 +6 -6
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java
Index: Tag.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Tag.java 24 Jan 2003 06:41:22 -0000 1.11
+++ Tag.java 24 Jan 2003 19:03:24 -0000 1.12
@@ -113,6 +113,6 @@
/**
* A helper method to invoke this tags body
*/
- public void invokeBody(XMLOutput output) throws JellyException;
+ public void invokeBody(XMLOutput output) throws JellyTagException;
}
1.22 +6 -6
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java
Index: TagSupport.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- TagSupport.java 24 Jan 2003 06:41:22 -0000 1.21
+++ TagSupport.java 24 Jan 2003 19:03:24 -0000 1.22
@@ -229,7 +229,7 @@
/**
* Invokes the body of this tag using the given output
*/
- public void invokeBody(XMLOutput output) throws JellyException {
+ public void invokeBody(XMLOutput output) throws JellyTagException {
getBody().run(context, output);
}
1.3 +2 -1
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/BreakException.java
Index: BreakException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/BreakException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BreakException.java 30 Oct 2002 19:16:24 -0000 1.2
+++ BreakException.java 24 Jan 2003 19:03:24 -0000 1.3
@@ -63,6 +63,7 @@
package org.apache.commons.jelly.impl;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
/**
* <p><code>BreakException</code> is used to terminate loops such as
@@ -72,7 +73,7 @@
* @version $Revision$
*/
-public class BreakException extends JellyException {
+public class BreakException extends JellyTagException {
public BreakException() {
super("Break exception, terminating the parent loop");
1.4 +3 -2
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ExpressionScript.java
Index: ExpressionScript.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ExpressionScript.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExpressionScript.java 24 Jan 2003 05:26:13 -0000 1.3
+++ ExpressionScript.java 24 Jan 2003 19:03:24 -0000 1.4
@@ -63,6 +63,7 @@
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;
import org.apache.commons.jelly.expression.Expression;
@@ -108,14 +109,14 @@
}
/** Evaluates the body of a tag */
- public void run(JellyContext context, XMLOutput output) throws JellyException {
+ public void run(JellyContext context, XMLOutput output) throws
JellyTagException {
String text = expression.evaluateAsString(context);
if ( text != null ) {
try {
output.write(text);
} catch (SAXException e) {
- throw new JellyException("Could not write to XMLOutput",e);
+ throw new JellyTagException("Could not write to XMLOutput",e);
}
}
1.12 +7 -6
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java
Index: ScriptBlock.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- ScriptBlock.java 24 Jan 2003 05:26:13 -0000 1.11
+++ ScriptBlock.java 24 Jan 2003 19:03:24 -0000 1.12
@@ -67,6 +67,7 @@
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;
@@ -122,7 +123,7 @@
}
/** Evaluates the body of a tag */
- public void run(JellyContext context, XMLOutput output) throws JellyException {
+ public void run(JellyContext context, XMLOutput output) throws
JellyTagException {
/*
for (int i = 0, size = scripts.length; i < size; i++) {
Script script = scripts[i];
1.14 +19 -10
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/StaticTagScript.java
Index: StaticTagScript.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/StaticTagScript.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- StaticTagScript.java 24 Jan 2003 05:26:13 -0000 1.13
+++ StaticTagScript.java 24 Jan 2003 19:03:24 -0000 1.14
@@ -67,6 +67,7 @@
import org.apache.commons.jelly.DynaTag;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.Tag;
import org.apache.commons.jelly.TagLibrary;
import org.apache.commons.jelly.XMLOutput;
@@ -100,22 +101,27 @@
// Script interface
//-------------------------------------------------------------------------
- public void run(JellyContext context, XMLOutput output) throws JellyException {
+ public void run(JellyContext context, XMLOutput output) throws
JellyTagException {
try {
startNamespacePrefixes(output);
} catch (SAXException e) {
- throw new JellyException("could not start namespace prefixes",e);
+ throw new JellyTagException("could not start namespace prefixes",e);
}
- Tag tag = getTag();
+ Tag tag = null;
+ try {
+ tag = getTag();
- // lets see if we have a dynamic tag
- if (tag instanceof StaticTag) {
- tag = findDynamicTag(context, (StaticTag) tag);
- }
+ // lets see if we have a dynamic tag
+ if (tag instanceof StaticTag) {
+ tag = findDynamicTag(context, (StaticTag) tag);
+ }
- setTag(tag);
+ setTag(tag);
+ } catch (JellyException e) {
+ throw new JellyTagException(e);
+ }
try {
if ( tag == null ) {
@@ -136,7 +142,10 @@
}
tag.doTag(output);
- }
+ }
+ catch (JellyTagException e) {
+ handleException(e);
+ }
catch (JellyException e) {
handleException(e);
}
@@ -147,7 +156,7 @@
try {
endNamespacePrefixes(output);
} catch (SAXException e) {
- throw new JellyException("could not end namespace prefixes",e);
+ throw new JellyTagException("could not end namespace prefixes",e);
}
}
1.35 +32 -14
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java
Index: TagScript.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- TagScript.java 24 Jan 2003 10:04:32 -0000 1.34
+++ TagScript.java 24 Jan 2003 19:03:24 -0000 1.35
@@ -74,6 +74,7 @@
import org.apache.commons.jelly.CompilableTag;
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.DynaTag;
import org.apache.commons.jelly.LocationAware;
import org.apache.commons.jelly.NamespaceAwareTag;
@@ -219,7 +220,7 @@
//-------------------------------------------------------------------------
/** Evaluates the body of a tag */
- public void run(JellyContext context, XMLOutput output) throws JellyException {
+ public void run(JellyContext context, XMLOutput output) throws
JellyTagException {
if ( ! context.isCacheTags() ) {
clearTag();
}
@@ -277,6 +278,9 @@
tag.doTag(output);
}
+ catch (JellyTagException e) {
+ handleException(e);
+ }
catch (JellyException e) {
handleException(e);
}
@@ -605,13 +609,13 @@
reason, cause, fileName, elementName, columnNumber, lineNumber
);
}
-
+
/**
* A helper method to handle this Jelly exception.
* This method adorns the JellyException with location information
* such as adding line number information etc.
*/
- protected void handleException(JellyException e) throws JellyException {
+ protected void handleException(JellyTagException e) throws JellyTagException {
if (log.isTraceEnabled()) {
log.trace( "Caught exception: " + e, e );
}
@@ -621,6 +625,21 @@
throw e;
}
+ /**
+ * A helper method to handle this Jelly exception.
+ * This method adorns the JellyException with location information
+ * such as adding line number information etc.
+ */
+ protected void handleException(JellyException e) throws JellyTagException {
+ if (log.isTraceEnabled()) {
+ log.trace( "Caught exception: " + e, e );
+ }
+
+ applyLocation(e);
+
+ throw new JellyTagException(e);
+ }
+
protected void applyLocation(LocationAware locationAware) {
if (locationAware.getLineNumber() == -1) {
locationAware.setColumnNumber(columnNumber);
@@ -639,7 +658,7 @@
* This method will rethrow the exception, wrapped in a JellyException
* while adding line number information etc.
*/
- protected void handleException(Exception e) throws JellyException {
+ protected void handleException(Exception e) throws JellyTagException {
if (log.isTraceEnabled()) {
log.trace( "Caught exception: " + e, e );
}
@@ -650,18 +669,17 @@
if ( e instanceof JellyException ) {
e.fillInStackTrace();
- throw (JellyException) e;
}
if ( e instanceof InvocationTargetException) {
- throw new JellyException(
((InvocationTargetException)e).getTargetException(),
+ throw new JellyTagException(
((InvocationTargetException)e).getTargetException(),
fileName,
elementName,
columnNumber,
lineNumber );
}
- throw new JellyException(e, fileName, elementName, columnNumber,
lineNumber);
+ throw new JellyTagException(e, fileName, elementName, columnNumber,
lineNumber);
}
/**
@@ -671,7 +689,7 @@
*
* Is this method wise?
*/
- protected void handleException(Error e) throws Error, JellyException {
+ protected void handleException(Error e) throws Error, JellyTagException {
if (log.isTraceEnabled()) {
log.trace( "Caught exception: " + e, e );
}
@@ -680,6 +698,6 @@
applyLocation((LocationAware) e);
}
- throw new JellyException(e, fileName, elementName, columnNumber,
lineNumber);
+ throw new JellyTagException(e, fileName, elementName, columnNumber,
lineNumber);
}
}
1.13 +8 -7
jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TextScript.java
Index: TextScript.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TextScript.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- TextScript.java 24 Jan 2003 05:26:13 -0000 1.12
+++ TextScript.java 24 Jan 2003 19:03:24 -0000 1.13
@@ -63,6 +63,7 @@
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.XMLOutput;
@@ -146,12 +147,12 @@
}
/** Evaluates the body of a tag */
- public void run(JellyContext context, XMLOutput output) throws JellyException {
+ public void run(JellyContext context, XMLOutput output) throws
JellyTagException {
if ( text != null ) {
try {
output.write(text);
} catch (SAXException e) {
- throw new JellyException("could not write to XMLOutput",e);
+ throw new JellyTagException("could not write to XMLOutput",e);
}
}
}
1.4 +7 -6
jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/TestArgTag.java
Index: TestArgTag.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/core/TestArgTag.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TestArgTag.java 24 Jan 2003 05:26:14 -0000 1.3
+++ TestArgTag.java 24 Jan 2003 19:03:25 -0000 1.4
@@ -68,6 +68,7 @@
import org.apache.commons.jelly.JellyContext;
import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
import org.apache.commons.jelly.Script;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
@@ -269,7 +270,7 @@
return this;
}
- public void run(JellyContext context, XMLOutput output) throws
JellyException {
+ public void run(JellyContext context, XMLOutput output) throws
JellyTagException {
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>