KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > bytecode > ImmediateIntInstruction


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.bytecode;
9
10 import org.gjt.jclasslib.io.ByteCodeInput;
11 import org.gjt.jclasslib.io.ByteCodeOutput;
12
13 import java.io.IOException JavaDoc;
14
15 /**
16     Describes an instruction that is followed by an immediate int.
17  
18     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
19     @version $Revision: 1.5 $ $Date: 2003/08/18 07:58:35 $
20 */

21 public class ImmediateIntInstruction extends AbstractInstruction {
22
23     private int immediateInt;
24    
25     /**
26         Constructor.
27         @param opcode the opcode.
28      */

29     public ImmediateIntInstruction(int opcode) {
30         super(opcode);
31     }
32
33     /**
34         Constructor.
35         @param opcode the opcode.
36         @param immediateInt the immediate int value.
37      */

38     public ImmediateIntInstruction(int opcode, int immediateInt) {
39         super(opcode);
40         this.immediateInt = immediateInt;
41     }
42     
43     public int getSize() {
44         return super.getSize() + 4;
45     }
46
47     /**
48         Get the immediate int of this instruction.
49         @return the int
50      */

51     public int getImmediateInt() {
52         return immediateInt;
53     }
54
55     /**
56         Set the immediate int of this instruction.
57         @param immediateInt the int
58      */

59     public void setImmediateInt(int immediateInt) {
60         this.immediateInt = immediateInt;
61     }
62     
63     public void read(ByteCodeInput in) throws IOException JavaDoc {
64         super.read(in);
65
66         immediateInt = in.readInt();
67     }
68
69     public void write(ByteCodeOutput out) throws IOException JavaDoc {
70         super.write(out);
71
72         out.writeInt(immediateInt);
73     }
74     
75 }
76
Popular Tags