| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.apache.commons.jelly.impl; |
| 17 |
|
|
| 18 |
|
import java.io.IOException; |
| 19 |
|
import java.lang.reflect.InvocationTargetException; |
| 20 |
|
import java.net.MalformedURLException; |
| 21 |
|
import java.net.URL; |
| 22 |
|
import java.util.Collections; |
| 23 |
|
import java.util.Hashtable; |
| 24 |
|
import java.util.Iterator; |
| 25 |
|
import java.util.Map; |
| 26 |
|
import java.util.WeakHashMap; |
| 27 |
|
|
| 28 |
|
import org.apache.commons.beanutils.ConvertingWrapDynaBean; |
| 29 |
|
import org.apache.commons.beanutils.ConvertUtils; |
| 30 |
|
import org.apache.commons.beanutils.DynaBean; |
| 31 |
|
import org.apache.commons.beanutils.DynaProperty; |
| 32 |
|
|
| 33 |
|
import org.apache.commons.jelly.CompilableTag; |
| 34 |
|
import org.apache.commons.jelly.JellyContext; |
| 35 |
|
import org.apache.commons.jelly.JellyException; |
| 36 |
|
import org.apache.commons.jelly.JellyTagException; |
| 37 |
|
import org.apache.commons.jelly.DynaTag; |
| 38 |
|
import org.apache.commons.jelly.LocationAware; |
| 39 |
|
import org.apache.commons.jelly.NamespaceAwareTag; |
| 40 |
|
import org.apache.commons.jelly.Script; |
| 41 |
|
import org.apache.commons.jelly.Tag; |
| 42 |
|
import org.apache.commons.jelly.XMLOutput; |
| 43 |
|
import org.apache.commons.jelly.expression.Expression; |
| 44 |
|
|
| 45 |
|
import org.apache.commons.logging.Log; |
| 46 |
|
import org.apache.commons.logging.LogFactory; |
| 47 |
|
|
| 48 |
|
import org.xml.sax.Attributes; |
| 49 |
|
import org.xml.sax.Locator; |
| 50 |
|
import org.xml.sax.SAXException; |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
public class TagScript implements Script { |
| 62 |
|
|
| 63 |
|
|
| 64 |
1001 |
private static final Log log = LogFactory.getLog(TagScript.class); |
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
19968 |
protected Map attributes = new Hashtable(); |
| 69 |
|
|
| 70 |
|
|
| 71 |
|
private Map tagNamespacesMap; |
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
private Map namespaceContext; |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
private String fileName; |
| 82 |
|
|
| 83 |
|
|
| 84 |
|
private String elementName; |
| 85 |
|
|
| 86 |
|
|
| 87 |
|
private String localName; |
| 88 |
|
|
| 89 |
|
|
| 90 |
19968 |
private int lineNumber = -1; |
| 91 |
|
|
| 92 |
|
|
| 93 |
19968 |
private int columnNumber = -1; |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
private TagFactory tagFactory; |
| 97 |
|
|
| 98 |
|
|
| 99 |
|
private Script tagBody; |
| 100 |
|
|
| 101 |
|
|
| 102 |
|
private TagScript parent; |
| 103 |
|
|
| 104 |
|
|
| 105 |
|
private Attributes saxAttributes; |
| 106 |
|
|
| 107 |
|
|
| 108 |
19968 |
private URL scriptURL = null; |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
19968 |
private Map threadLocalTagCache = Collections.synchronizedMap(new WeakHashMap()); |
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
public static TagScript newInstance(Class tagClass) { |
| 119 |
19721 |
TagFactory factory = new DefaultTagFactory(tagClass); |
| 120 |
19721 |
return new TagScript(factory); |
| 121 |
|
} |
| 122 |
|
|
| 123 |
0 |
public TagScript() { |
| 124 |
0 |
} |
| 125 |
|
|
| 126 |
19968 |
public TagScript(TagFactory tagFactory) { |
| 127 |
19968 |
this.tagFactory = tagFactory; |
| 128 |
19968 |
} |
| 129 |
|
|
| 130 |
|
public String toString() { |
| 131 |
13 |
return super.toString() + "[tag=" + elementName + ";at=" + lineNumber + ":" + columnNumber + "]"; |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
public Script compile() throws JellyException { |
| 138 |
19903 |
if (tagBody != null) { |
| 139 |
19903 |
tagBody = tagBody.compile(); |
| 140 |
|
} |
| 141 |
19903 |
return this; |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
public void setTagNamespacesMap(Map tagNamespacesMap) { |
| 149 |
|
|
| 150 |
1040 |
if ( ! (tagNamespacesMap instanceof Hashtable) ) { |
| 151 |
1040 |
tagNamespacesMap = new Hashtable( tagNamespacesMap ); |
| 152 |
|
} |
| 153 |
1040 |
this.tagNamespacesMap = tagNamespacesMap; |
| 154 |
1040 |
} |
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
public void setLocator(Locator locator) { |
| 161 |
19968 |
setLineNumber( locator.getLineNumber() ); |
| 162 |
19968 |
setColumnNumber( locator.getColumnNumber() ); |
| 163 |
19968 |
} |
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
public void addAttribute(String name, Expression expression) { |
| 170 |
26130 |
if (log.isDebugEnabled()) { |
| 171 |
0 |
log.debug("adding attribute name: " + name + " expression: " + expression); |
| 172 |
|
} |
| 173 |
26130 |
attributes.put(name, expression); |
| 174 |
26130 |
} |
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
private URL getJellyContextURL(URL url) throws MalformedURLException { |
| 181 |
19864 |
String text = url.toString(); |
| 182 |
19864 |
int idx = text.lastIndexOf('/'); |
| 183 |
19864 |
text = text.substring(0, idx + 1); |
| 184 |
19864 |
return new URL(text); |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
public void run(JellyContext context, XMLOutput output) throws JellyTagException { |
| 192 |
12207 |
URL rootURL = context.getRootURL(); |
| 193 |
12207 |
URL currentURL = context.getCurrentURL(); |
| 194 |
|
try { |
| 195 |
12207 |
Tag tag = getTag(context); |
| 196 |
12207 |
if ( tag == null ) { |
| 197 |
|
return; |
| 198 |
|
} |
| 199 |
12207 |
tag.setContext(context); |
| 200 |
12207 |
setContextURLs(context); |
| 201 |
|
|
| 202 |
12207 |
if ( tag instanceof DynaTag ) { |
| 203 |
117 |
DynaTag dynaTag = (DynaTag) tag; |
| 204 |
|
|
| 205 |
|
|
| 206 |
117 |
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { |
| 207 |
442 |
Map.Entry entry = (Map.Entry) iter.next(); |
| 208 |
442 |
String name = (String) entry.getKey(); |
| 209 |
442 |
Expression expression = (Expression) entry.getValue(); |
| 210 |
|
|
| 211 |
442 |
Class type = dynaTag.getAttributeType(name); |
| 212 |
442 |
Object value = null; |
| 213 |
442 |
if (type != null && type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { |
| 214 |
0 |
value = expression; |
| 215 |
0 |
} |
| 216 |
|
else { |
| 217 |
442 |
value = expression.evaluateRecurse(context); |
| 218 |
|
} |
| 219 |
442 |
dynaTag.setAttribute(name, value); |
| 220 |
442 |
} |
| 221 |
117 |
} |
| 222 |
|
else { |
| 223 |
|
|
| 224 |
12090 |
DynaBean dynaBean = new ConvertingWrapDynaBean( tag ); |
| 225 |
12090 |
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) { |
| 226 |
15782 |
Map.Entry entry = (Map.Entry) iter.next(); |
| 227 |
15782 |
String name = (String) entry.getKey(); |
| 228 |
15782 |
Expression expression = (Expression) entry.getValue(); |
| 229 |
|
|
| 230 |
15782 |
DynaProperty property = dynaBean.getDynaClass().getDynaProperty(name); |
| 231 |
15782 |
if (property == null) { |
| 232 |
0 |
throw new JellyException("This tag does not understand the '" + name + "' attribute" ); |
| 233 |
|
} |
| 234 |
15782 |
Class type = property.getType(); |
| 235 |
|
|
| 236 |
15782 |
Object value = null; |
| 237 |
15782 |
if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { |
| 238 |
8723 |
value = expression; |
| 239 |
8723 |
} |
| 240 |
|
else { |
| 241 |
7059 |
value = expression.evaluateRecurse(context); |
| 242 |
|
} |
| 243 |
15782 |
dynaBean.set(name, value); |
| 244 |
15782 |
} |
| 245 |
|
} |
| 246 |
|
|
| 247 |
12207 |
tag.doTag(output); |
| 248 |
11570 |
if (output != null) { |
| 249 |
11570 |
output.flush(); |
| 250 |
|
} |
| 251 |
|
} |
| 252 |
637 |
catch (JellyTagException e) { |
| 253 |
637 |
handleException(e); |
| 254 |
0 |
} catch (JellyException e) { |
| 255 |
0 |
handleException(e); |
| 256 |
0 |
} catch (IOException e) { |
| 257 |
0 |
handleException(e); |
| 258 |
0 |
} catch (RuntimeException e) { |
| 259 |
0 |
handleException(e); |
| 260 |
|
} |
| 261 |
0 |
catch (Error e) { |
| 262 |
|
|
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
0 |
handleException(e); |
| 268 |
|
} finally { |
| 269 |
12207 |
context.setRootURL(rootURL); |
| 270 |
12207 |
context.setCurrentURL(currentURL); |
| 271 |
12207 |
} |
| 272 |
|
|
| 273 |
11570 |
} |
| 274 |
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
|
|
| 279 |
|
|
| 280 |
|
protected void setContextURLs(JellyContext context) throws JellyTagException { |
| 281 |
12363 |
if ((context.getCurrentURL() == null || context.getRootURL() == class="keyword">null) && scriptURL != class="keyword">null) |
| 282 |
|
{ |
| 283 |
806 |
if (context.getRootURL() == null) context.setRootURL(scriptURL); |
| 284 |
806 |
if (context.getCurrentURL() == null) context.setCurrentURL(scriptURL); |
| 285 |
|
} |
| 286 |
12363 |
} |
| 287 |
|
|
| 288 |
|
|
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
public Tag getTag(JellyContext context) throws JellyException { |
| 295 |
21034 |
Thread t = Thread.currentThread(); |
| 296 |
21034 |
Tag tag = (Tag) threadLocalTagCache.get(t); |
| 297 |
21034 |
if ( tag == null ) { |
| 298 |
9646 |
tag = createTag(); |
| 299 |
9646 |
if ( tag != null ) { |
| 300 |
9646 |
threadLocalTagCache.put(t,tag); |
| 301 |
9646 |
configureTag(tag,context); |
| 302 |
|
} |
| 303 |
|
} |
| 304 |
21034 |
return tag; |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
public TagFactory getTagFactory() { |
| 312 |
0 |
return tagFactory; |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
|
| 316 |
|
|
| 317 |
|
|
| 318 |
|
|
| 319 |
|
public void setTagFactory(TagFactory tagFactory) { |
| 320 |
0 |
this.tagFactory = tagFactory; |
| 321 |
0 |
} |
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
|
|
| 327 |
|
public TagScript getParent() { |
| 328 |
0 |
return parent; |
| 329 |
|
} |
| 330 |
|
|
| 331 |
|
|
| 332 |
|
|
| 333 |
|
|
| 334 |
|
|
| 335 |
|
public Script getTagBody() { |
| 336 |
0 |
return tagBody; |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
|
| 340 |
|
|
| 341 |
|
|
| 342 |
|
|
| 343 |
|
public void setParent(TagScript parent) { |
| 344 |
19968 |
this.parent = parent; |
| 345 |
19968 |
} |
| 346 |
|
|
| 347 |
|
|
| 348 |
|
|
| 349 |
|
|
| 350 |
|
|
| 351 |
|
public void setTagBody(Script tagBody) { |
| 352 |
19968 |
this.tagBody = tagBody; |
| 353 |
19968 |
} |
| 354 |
|
|
| 355 |
|
|
| 356 |
|
|
| 357 |
|
|
| 358 |
|
public String getFileName() { |
| 359 |
0 |
return fileName; |
| 360 |
|
} |
| 361 |
|
|
| 362 |
|
|
| 363 |
|
|
| 364 |
|
|
| 365 |
|
public void setFileName(String fileName) { |
| 366 |
19968 |
this.fileName = fileName; |
| 367 |
|
try |
| 368 |
|
{ |
| 369 |
19968 |
this.scriptURL = getJellyContextURL(new URL(fileName)); |
| 370 |
104 |
} catch (MalformedURLException e) { |
| 371 |
104 |
log.debug("error setting script url", e); |
| 372 |
19864 |
} |
| 373 |
19968 |
} |
| 374 |
|
|
| 375 |
|
|
| 376 |
|
|
| 377 |
|
|
| 378 |
|
|
| 379 |
|
public String getElementName() { |
| 380 |
0 |
return elementName; |
| 381 |
|
} |
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
|
|
| 386 |
|
public void setElementName(String elementName) { |
| 387 |
19968 |
this.elementName = elementName; |
| 388 |
19968 |
} |
| 389 |
|
|
| 390 |
|
|
| 391 |
|
|
| 392 |
|
public int getLineNumber() { |
| 393 |
0 |
return lineNumber; |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
|
| 397 |
|
|
| 398 |
|
|
| 399 |
|
public void setLineNumber(int lineNumber) { |
| 400 |
19968 |
this.lineNumber = lineNumber; |
| 401 |
19968 |
} |
| 402 |
|
|
| 403 |
|
|
| 404 |
|
|
| 405 |
|
|
| 406 |
|
public int getColumnNumber() { |
| 407 |
0 |
return columnNumber; |
| 408 |
|
} |
| 409 |
|
|
| 410 |
|
|
| 411 |
|
|
| 412 |
|
|
| 413 |
|
public void setColumnNumber(int columnNumber) { |
| 414 |
19968 |
this.columnNumber = columnNumber; |
| 415 |
19968 |
} |
| 416 |
|
|
| 417 |
|
|
| 418 |
|
|
| 419 |
|
|
| 420 |
|
|
| 421 |
|
public Attributes getSaxAttributes() { |
| 422 |
9646 |
return saxAttributes; |
| 423 |
|
} |
| 424 |
|
|
| 425 |
|
|
| 426 |
|
|
| 427 |
|
|
| 428 |
|
|
| 429 |
|
public void setSaxAttributes(Attributes saxAttributes) { |
| 430 |
19721 |
this.saxAttributes = saxAttributes; |
| 431 |
19721 |
} |
| 432 |
|
|
| 433 |
|
|
| 434 |
|
|
| 435 |
|
|
| 436 |
|
|
| 437 |
|
public String getLocalName() { |
| 438 |
0 |
return localName; |
| 439 |
|
} |
| 440 |
|
|
| 441 |
|
|
| 442 |
|
|
| 443 |
|
|
| 444 |
|
|
| 445 |
|
public void setLocalName(String localName) { |
| 446 |
19968 |
this.localName = localName; |
| 447 |
19968 |
} |
| 448 |
|
|
| 449 |
|
|
| 450 |
|
|
| 451 |
|
|
| 452 |
|
|
| 453 |
|
|
| 454 |
|
|
| 455 |
|
|
| 456 |
|
|
| 457 |
|
|
| 458 |
|
public synchronized Map getNamespaceContext() { |
| 459 |
0 |
if (namespaceContext == null) { |
| 460 |
0 |
if (parent != null) { |
| 461 |
0 |
namespaceContext = getParent().getNamespaceContext(); |
| 462 |
0 |
if (tagNamespacesMap != null && !tagNamespacesMap.isEmpty()) { |
| 463 |
|
|
| 464 |
0 |
Hashtable newContext = new Hashtable(namespaceContext.size()+1); |
| 465 |
0 |
newContext.putAll(namespaceContext); |
| 466 |
0 |
newContext.putAll(tagNamespacesMap); |
| 467 |
0 |
namespaceContext = newContext; |
| 468 |
0 |
} |
| 469 |
|
} |
| 470 |
|
else { |
| 471 |
0 |
namespaceContext = tagNamespacesMap; |
| 472 |
0 |
if (namespaceContext == null) { |
| 473 |
0 |
namespaceContext = new Hashtable(); |
| 474 |
|
} |
| 475 |
|
} |
| 476 |
|
} |
| 477 |
0 |
return namespaceContext; |
| 478 |
|
} |
| 479 |
|
|
| 480 |
|
|
| 481 |
|
|
| 482 |
|
|
| 483 |
|
|
| 484 |
|
|
| 485 |
|
|
| 486 |
|
|
| 487 |
|
protected Tag createTag() throws JellyException { |
| 488 |
9646 |
if ( tagFactory != null) { |
| 489 |
9646 |
return tagFactory.createTag(localName, getSaxAttributes()); |
| 490 |
|
} |
| 491 |
0 |
return null; |
| 492 |
|
} |
| 493 |
|
|
| 494 |
|
|
| 495 |
|
|
| 496 |
|
|
| 497 |
|
|
| 498 |
|
protected void configureTag(Tag tag, JellyContext context) throws JellyException { |
| 499 |
9646 |
if (tag instanceof CompilableTag) { |
| 500 |
0 |
((CompilableTag) tag).compile(); |
| 501 |
|
} |
| 502 |
9646 |
Tag parentTag = null; |
| 503 |
9646 |
if ( parent != null ) { |
| 504 |
8671 |
parentTag = parent.getTag(context); |
| 505 |
|
} |
| 506 |
9646 |
tag.setParent( parentTag ); |
| 507 |
9646 |
tag.setBody( tagBody ); |
| 508 |
|
|
| 509 |
9646 |
if (tag instanceof NamespaceAwareTag) { |
| 510 |
0 |
NamespaceAwareTag naTag = (NamespaceAwareTag) tag; |
| 511 |
0 |
naTag.setNamespaceContext(getNamespaceContext()); |
| 512 |
|
} |
| 513 |
9646 |
if (tag instanceof LocationAware) { |
| 514 |
0 |
applyLocation((LocationAware) tag); |
| 515 |
|
} |
| 516 |
9646 |
} |
| 517 |
|
|
| 518 |
|
|
| 519 |
|
|
| 520 |
|
|
| 521 |
|
|
| 522 |
|
|
| 523 |
|
protected void setTag(Tag tag, JellyContext context) { |
| 524 |
156 |
Thread t = Thread.currentThread(); |
| 525 |
156 |
threadLocalTagCache.put(t,tag); |
| 526 |
156 |
} |
| 527 |
|
|
| 528 |
|
|
| 529 |
|
|
| 530 |
|
|
| 531 |
|
protected void startNamespacePrefixes(XMLOutput output) throws SAXException { |
| 532 |
156 |
if ( tagNamespacesMap != null ) { |
| 533 |
13 |
for ( Iterator iter = tagNamespacesMap.entrySet().iterator(); iter.hasNext(); ) { |
| 534 |
13 |
Map.Entry entry = (Map.Entry) iter.next(); |
| 535 |
13 |
String prefix = (String) entry.getKey(); |
| 536 |
13 |
String uri = (String) entry.getValue(); |
| 537 |
13 |
output.startPrefixMapping(prefix, uri); |
| 538 |
13 |
} |
| 539 |
|
} |
| 540 |
156 |
} |
| 541 |
|
|
| 542 |
|
|
| 543 |
|
|
| 544 |
|
|
| 545 |
|
protected void endNamespacePrefixes(XMLOutput output) throws SAXException { |
| 546 |
156 |
if ( tagNamespacesMap != null ) { |
| 547 |
13 |
for ( Iterator iter = tagNamespacesMap.keySet().iterator(); iter.hasNext(); ) { |
| 548 |
13 |
String prefix = (String) iter.next(); |
| 549 |
13 |
output.endPrefixMapping(prefix); |
| 550 |
13 |
} |
| 551 |
|
} |
| 552 |
156 |
} |
| 553 |
|
|
| 554 |
|
|
| 555 |
|
|
| 556 |
|
|
| 557 |
|
|
| 558 |
|
|
| 559 |
|
|
| 560 |
|
protected Object convertType(Object value, Class requiredType) |
| 561 |
|
throws JellyException { |
| 562 |
0 |
if (requiredType.isInstance(value)) { |
| 563 |
0 |
return value; |
| 564 |
|
} |
| 565 |
0 |
if (value instanceof String) { |
| 566 |
0 |
return ConvertUtils.convert((String) value, requiredType); |
| 567 |
|
} |
| 568 |
0 |
return value; |
| 569 |
|
} |
| 570 |
|
|
| 571 |
|
|
| 572 |
|
|
| 573 |
|
|
| 574 |
|
protected JellyException createJellyException(String reason) { |
| 575 |
0 |
return new JellyException( |
| 576 |
|
reason, fileName, elementName, columnNumber, lineNumber |
| 577 |
|
); |
| 578 |
|
} |
| 579 |
|
|
| 580 |
|
|
| 581 |
|
|
| 582 |
|
|
| 583 |
|
protected JellyException createJellyException(String reason, Exception cause) { |
| 584 |
0 |
if (cause instanceof JellyException) { |
| 585 |
0 |
return (JellyException) cause; |
| 586 |
|
} |
| 587 |
|
|
| 588 |
0 |
if (cause instanceof InvocationTargetException) { |
| 589 |
0 |
return new JellyException( |
| 590 |
|
reason, |
| 591 |
|
((InvocationTargetException) cause).getTargetException(), |
| 592 |
|
fileName, |
| 593 |
|
elementName, |
| 594 |
|
columnNumber, |
| 595 |
|
lineNumber); |
| 596 |
|
} |
| 597 |
0 |
return new JellyException( |
| 598 |
|
reason, cause, fileName, elementName, columnNumber, lineNumber |
| 599 |
|
); |
| 600 |
|
} |
| 601 |
|
|
| 602 |
|
|
| 603 |
|
|
| 604 |
|
|
| 605 |
|
|
| 606 |
|
|
| 607 |
|
protected void handleException(JellyTagException e) throws JellyTagException { |
| 608 |
637 |
if (log.isTraceEnabled()) { |
| 609 |
0 |
log.trace( "Caught exception: " + e, e ); |
| 610 |
|
} |
| 611 |
|
|
| 612 |
637 |
applyLocation(e); |
| 613 |
|
|
| 614 |
637 |
throw e; |
| 615 |
|
} |
| 616 |
|
|
| 617 |
|
|
| 618 |
|
|
| 619 |
|
|
| 620 |
|
|
| 621 |
|
|
| 622 |
|
protected void handleException(JellyException e) throws JellyTagException { |
| 623 |
0 |
if (log.isTraceEnabled()) { |
| 624 |
0 |
log.trace( "Caught exception: " + e, e ); |
| 625 |
|
} |
| 626 |
|
|
| 627 |
0 |
applyLocation(e); |
| 628 |
|
|
| 629 |
0 |
throw new JellyTagException(e); |
| 630 |
|
} |
| 631 |
|
|
| 632 |
|
protected void applyLocation(LocationAware locationAware) { |
| 633 |
637 |
if (locationAware.getLineNumber() == -1) { |
| 634 |
338 |
locationAware.setColumnNumber(columnNumber); |
| 635 |
338 |
locationAware.setLineNumber(lineNumber); |
| 636 |
|
} |
| 637 |
637 |
if ( locationAware.getFileName() == null ) { |
| 638 |
338 |
locationAware.setFileName( fileName ); |
| 639 |
|
} |
| 640 |
637 |
if ( locationAware.getElementName() == null ) { |
| 641 |
338 |
locationAware.setElementName( elementName ); |
| 642 |
|
} |
| 643 |
637 |
} |
| 644 |
|
|
| 645 |
|
|
| 646 |
|
|
| 647 |
|
|
| 648 |
|
|
| 649 |
|
|
| 650 |
|
protected void handleException(Exception e) throws JellyTagException { |
| 651 |
0 |
if (log.isTraceEnabled()) { |
| 652 |
0 |
log.trace( "Caught exception: " + e, e ); |
| 653 |
|
} |
| 654 |
|
|
| 655 |
0 |
if (e instanceof LocationAware) { |
| 656 |
0 |
applyLocation((LocationAware) e); |
| 657 |
|
} |
| 658 |
|
|
| 659 |
0 |
if ( e instanceof JellyException ) { |
| 660 |
0 |
e.fillInStackTrace(); |
| 661 |
|
} |
| 662 |
|
|
| 663 |
0 |
if ( e instanceof InvocationTargetException) { |
| 664 |
0 |
throw new JellyTagException( ((InvocationTargetException)e).getTargetException(), |
| 665 |
|
fileName, |
| 666 |
|
elementName, |
| 667 |
|
columnNumber, |
| 668 |
|
lineNumber ); |
| 669 |
|
} |
| 670 |
|
|
| 671 |
0 |
throw new JellyTagException(e, fileName, elementName, columnNumber, lineNumber); |
| 672 |
|
} |
| 673 |
|
|
| 674 |
|
|
| 675 |
|
|
| 676 |
|
|
| 677 |
|
|
| 678 |
|
|
| 679 |
|
|
| 680 |
|
|
| 681 |
|
protected void handleException(Error e) throws Error, JellyTagException { |
| 682 |
0 |
if (log.isTraceEnabled()) { |
| 683 |
0 |
log.trace( "Caught exception: " + e, e ); |
| 684 |
|
} |
| 685 |
|
|
| 686 |
0 |
if (e instanceof LocationAware) { |
| 687 |
0 |
applyLocation((LocationAware) e); |
| 688 |
|
} |
| 689 |
|
|
| 690 |
0 |
throw new JellyTagException(e, fileName, elementName, columnNumber, lineNumber); |
| 691 |
|
} |
| 692 |
|
} |