View Javadoc

1   /*
2    * @(#) Constant.java Jan 9, 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  import nl.tudelft.simulation.language.reflection.FieldSignature;
16  
17  /***
18   * A Constant <br>
19   * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
20   * University of Technology </a>, the Netherlands. <br>
21   * See for project information <a
22   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
23   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
24   * License (GPL) </a>, no warranty <br>
25   * 
26   * @version 1.0 Jan 9, 2004 <br>
27   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
28   *         Jacobs </a>
29   */
30  public class LocalVariableDescriptor
31  {
32  	/*** the start attribute of a localVariable */
33  	private int startByte = -1;
34  
35  	/*** the length attribute of a localVariable */
36  	private int length = -1;
37  
38  	/*** the index attribute of a localVariable */
39  	private int index = -1;
40  
41  	/*** the name of the variable */
42  	private String name;
43  
44  	/*** the descriptor of the variable */
45  	private FieldSignature fieldSignature;
46  
47  	/***
48  	 * constructs a new LocalVariableDescriptor
49  	 * 
50  	 * @param dataInput the dataInput to read
51  	 * @param constantPool the constantPool for this variable
52  	 * @throws IOException on failure
53  	 */
54  	public LocalVariableDescriptor(final DataInput dataInput,
55  			final Constant[] constantPool) throws IOException
56  	{
57  		this.startByte = dataInput.readUnsignedShort();
58  		this.length = dataInput.readUnsignedShort();
59  		this.name = ((ConstantUTF8) constantPool[dataInput.readUnsignedShort()])
60  				.getValue();
61  		this.fieldSignature = new FieldSignature(
62  				((ConstantUTF8) constantPool[dataInput.readUnsignedShort()])
63  						.getValue());
64  		this.index = dataInput.readUnsignedShort();
65  	}
66  
67  	/***
68  	 * @return Returns the fieldSignature.
69  	 */
70  	public FieldSignature getFieldSignature()
71  	{
72  		return this.fieldSignature;
73  	}
74  
75  	/***
76  	 * @return Returns the length.
77  	 */
78  	public int getIndex()
79  	{
80  		return this.index;
81  	}
82  
83  	/***
84  	 * @return Returns the length.
85  	 */
86  	public int getLength()
87  	{
88  		return this.length;
89  	}
90  
91  	/***
92  	 * @return Returns the name.
93  	 */
94  	public String getName()
95  	{
96  		return this.name;
97  	}
98  
99  	/***
100 	 * @return Returns the startByte.
101 	 */
102 	public int getStartByte()
103 	{
104 		return this.startByte;
105 	}
106 
107 	/***
108 	 * @see java.lang.Object#toString()
109 	 */
110 	public String toString()
111 	{
112 		return "[" + this.name + ";" + this.fieldSignature + "]";
113 	}
114 }