Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/milligan/eccles/tags/ThrowTag.java


1   package org.milligan.eccles.tags;
2   
3   import org.milligan.eccles.*;
4   
5   
6   /**
7    * Throws (or re-throws) an exception
8    * @author Ian Tomey
9    *
10   */
11  
12  public class ThrowTag extends Tag {
13  
14    public ThrowTag() {
15    }
16  
17    public String getTagName() {
18      return "throw";
19    }
20  
21    /**
22     * Tag properties for output
23     */
24    protected static final String tagSpecificProperties[]= new String[] {"type","message"};
25    private String type;
26    private String message;
27    private Class _type;
28    /**
29     * Get a list of properties to be output
30     * @return list of properties
31     */
32    public String[] getTagPropertiesForDisplay() {
33      return tagSpecificProperties;
34    }
35  
36    public void setType(String type) {
37      this.type = CatchTag.transformExceptionTypeName(type);
38    }
39  
40    public String getType() {
41      return type;
42    }
43    public void setMessage(String message) {
44      this.message = message;
45    }
46    public String getMessage() {
47      return message;
48    }
49    public Class get_type() {
50      return _type;
51    }
52  
53    /**
54     *
55     * @param state
56     * @return
57     * @throws EcclesException
58     */
59    public EcclesReturnValue doStartTag(RunState state) throws org.milligan.eccles.EcclesException {
60      EcclesException toThrow;
61      try {
62        toThrow = new EcclesException( state, state.evaluateString(message), (Exception) _type.newInstance() );
63      } catch( Exception e ) {
64        throw new EcclesException( state, "Unable to create exception class for throwing",e );
65      }
66      throw toThrow;
67    }
68  
69    /**
70     *
71     * @throws EcclesException
72     */
73    public void validate() throws org.milligan.eccles.EcclesException {
74      super.validate();
75      try {
76        _type = Thread.currentThread().getContextClassLoader().loadClass(type);
77      }
78      catch (Exception e) {
79        throw new EcclesException( this, "Invalid exception class", e);
80      }
81    }
82  }