Source code: com/tripi/asp/ThrowExceptionNode.java
1 /**
2 * ArrowHead ASP Server
3 * This is a source file for the ArrowHead ASP Server - an 100% Java
4 * VBScript interpreter and ASP server.
5 *
6 * For more information, see http://www.tripi.com/arrowhead
7 *
8 * Copyright (C) 2002 Terence Haddock
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 */
25 package com.tripi.asp;
26
27 /**
28 * The ThrowExceptionNode handles nodes which automatically throw exceptions.
29 * This includes Exit nodes.
30 *
31 * @author Terence Haddock
32 * @version 0.9
33 */
34 public class ThrowExceptionNode extends DefaultNode
35 {
36 /** Exception to throw when this block is executed. */
37 AspException exception;
38
39 /**
40 * Constructor, gives exception to throw.
41 * @param exception Exception to throw when this block is executed.
42 */
43 public ThrowExceptionNode(AspException exception)
44 {
45 this.exception = exception;
46 }
47
48 /**
49 * Dumps this VBScript element.
50 * @see Node#dump()
51 */
52 public void dump() throws AspException
53 {
54 if (exception instanceof AspExitForException)
55 {
56 System.out.println("EXIT FOR");
57 } else if (exception instanceof AspExitFunctionException)
58 {
59 System.out.println("EXIT FUNCTION");
60 } else if (exception instanceof AspExitSubException)
61 {
62 System.out.println("EXIT SUB");
63 } else if (exception instanceof AspExitDoException)
64 {
65 System.out.println("EXIT DO");
66 } else super.dump();
67 }
68
69 /**
70 * Executes this node, throwing the exception we want to throw.
71 *
72 * @param context AspContext under which to execute this node.
73 * @return this function never returns
74 * @see Node#execute(AspContext)
75 */
76 public Object execute(AspContext context) throws AspException
77 {
78 throw exception;
79 }
80 };
81