View Javadoc

1   /*
2    * @(#) ExceptionEntry.java Jan 11, 2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.dsol.interpreter.classfile;
11  
12  import java.io.DataInput;
13  import java.io.IOException;
14  
15  /***
16   * A ExceptionEntry <br>
17   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
18   * University of Technology </a>, the Netherlands. <br>
19   * See for project information <a
20   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
21   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
22   * License (GPL) </a>, no warranty <br>
23   * 
24   * @version 1.0 Jan 11, 2004 <br>
25   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
26   *         Jacobs </a>
27   */
28  public class ExceptionEntry
29  {
30  	/*** the start byte of the entry */
31  	private int startByte;
32  
33  	/*** the end byte of the entry */
34  	private int endByte;
35  
36  	/*** the handler number */
37  	private int handler;
38  
39  	/*** the catchType of this handler */
40  	private Class catchType = Exception.class;
41  
42  	/***
43  	 * constructs a new ExceptionEntry
44  	 * 
45  	 * @param dataInput the input to read
46  	 * @param constantPool the constantPool of this entry
47  	 * @throws IOException on IOFailure
48  	 */
49  	public ExceptionEntry(final DataInput dataInput,
50  			final Constant[] constantPool) throws IOException
51  	{
52  		super();
53  		this.startByte = dataInput.readUnsignedShort();
54  		this.endByte = dataInput.readUnsignedShort();
55  		this.handler = dataInput.readUnsignedShort();
56  		int catchTypeIndex = dataInput.readUnsignedShort();
57  
58  		if (catchTypeIndex > 0)
59  		{
60  			try
61  			{
62  				this.catchType = ((ConstantClass) constantPool[catchTypeIndex])
63  						.getValue().getClassValue();
64  			} catch (Exception exception)
65  			{
66  				throw new IOException(
67  						"could not resolve catchType in ExceptionEntry");
68  			}
69  		}
70  	}
71  
72  	/***
73  	 * @return Returns the catchType.
74  	 */
75  	public Class getCatchType()
76  	{
77  		return this.catchType;
78  	}
79  
80  	/***
81  	 * @return Returns the endByte.
82  	 */
83  	public int getEndByte()
84  	{
85  		return this.endByte;
86  	}
87  
88  	/***
89  	 * @return Returns the handler.
90  	 */
91  	public int getHandler()
92  	{
93  		return this.handler;
94  	}
95  
96  	/***
97  	 * @return Returns the startByte.
98  	 */
99  	public int getStartByte()
100 	{
101 		return this.startByte;
102 	}
103 }