View Javadoc

1   /*
2    * @(#) ConstantInteger.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  /***
16   * A ConstantInteger <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 9, 2004 <br>
25   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
26   *         Jacobs </a>
27   */
28  public class ConstantInteger extends Constant
29  {
30  	/*** the value */
31  	private int bytes;
32  
33  	/***
34  	 * constructs a new ConstantInteger
35  	 * 
36  	 * @param constantPool the constantPool it is part of
37  	 * @param inputStream the inputstream to read from
38  	 * @throws IOException on failure
39  	 */
40  	public ConstantInteger(final Constant[] constantPool,
41  			final DataInput inputStream) throws IOException
42  	{
43  		this(constantPool, inputStream.readInt());
44  	}
45  
46  	/***
47  	 * constructs a new ConstantInteger
48  	 * 
49  	 * @param constantPool the constantPool it is part of
50  	 * @param bytes the bytes
51  	 */
52  	public ConstantInteger(final Constant[] constantPool, final int bytes)
53  	{
54  		super(constantPool);
55  		this.bytes = bytes;
56  	}
57  
58  	/***
59  	 * @see nl.tudelft.simulation.dsol.interpreter.classfile.Constant#getTag()
60  	 */
61  	public int getTag()
62  	{
63  		return 3;
64  	}
65  
66  	/***
67  	 * returns the value
68  	 * 
69  	 * @return int the value
70  	 */
71  	public int getValue()
72  	{
73  		return this.bytes;
74  	}
75  
76  	/***
77  	 * @see java.lang.Object#toString()
78  	 */
79  	public String toString()
80  	{
81  		return "ConstantInteger[value=" + this.bytes + "]";
82  	}
83  }