KickJava   Java API By Example, From Geeks To Geeks.

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


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 unsigned short.
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 ImmediateShortInstruction extends AbstractInstruction {
22
23     private int immediateShort;
24    
25     public int getSize() {
26         return super.getSize() + 2;
27     }
28
29     /**
30         Constructor.
31         @param opcode the opcode.
32      */

33     public ImmediateShortInstruction(int opcode) {
34         super(opcode);
35     }
36     
37     /**
38         Constructor.
39         @param opcode the opcode.
40         @param immediateShort the immediate short value.
41      */

42     public ImmediateShortInstruction(int opcode, int immediateShort) {
43         super(opcode);
44         this.immediateShort = immediateShort;
45     }
46     
47     /**
48         Get the immediate unsigned short of this instruction.
49         @return the short
50      */

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

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