1 17 package org.apache.bcel.classfile; 18 19 import java.io.DataInputStream ; 20 import java.io.DataOutputStream ; 21 import java.io.IOException ; 22 import org.apache.bcel.Constants; 23 24 33 public final class ConstantInteger extends Constant implements ConstantObject { 34 35 private int bytes; 36 37 38 41 public ConstantInteger(int bytes) { 42 super(Constants.CONSTANT_Integer); 43 this.bytes = bytes; 44 } 45 46 47 50 public ConstantInteger(ConstantInteger c) { 51 this(c.getBytes()); 52 } 53 54 55 61 ConstantInteger(DataInputStream file) throws IOException { 62 this(file.readInt()); 63 } 64 65 66 73 public void accept( Visitor v ) { 74 v.visitConstantInteger(this); 75 } 76 77 78 84 public final void dump( DataOutputStream file ) throws IOException { 85 file.writeByte(tag); 86 file.writeInt(bytes); 87 } 88 89 90 93 public final int getBytes() { 94 return bytes; 95 } 96 97 98 101 public final void setBytes( int bytes ) { 102 this.bytes = bytes; 103 } 104 105 106 109 public final String toString() { 110 return super.toString() + "(bytes = " + bytes + ")"; 111 } 112 113 114 116 public Object getConstantValue( ConstantPool cp ) { 117 return new Integer (bytes); 118 } 119 } 120 | Popular Tags |