Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

ConstantInteger.java

00001 package de.fub.bytecode.classfile;
00002 
00003 
00004 import  de.fub.bytecode.Constants;
00005 import  java.io.*;
00006 
00007 /** 
00008  * This class is derived from the abstract 
00009  * <A HREF="de.fub.bytecode.classfile.Constant.html">Constant</A> class 
00010  * and represents a reference to an int object.
00011  *
00012  * @version $Id: ConstantInteger.java,v 1.1.1.1 2002/01/24 03:41:37 pserver Exp $
00013  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00014  * @see     Constant
00015  */
00016 public final class ConstantInteger extends Constant {
00017   private int bytes;
00018 
00019   /** 
00020    * @param bytes Data
00021    */
00022   public ConstantInteger(int bytes)
00023   {    
00024     super(Constants.CONSTANT_Integer);
00025     this.bytes = bytes;
00026   }  
00027   /**
00028    * Initialize from another object.
00029    */
00030   public ConstantInteger(ConstantInteger c) {
00031     this(c.getBytes());
00032   }  
00033   /** 
00034    * Initialize instance from file data.
00035    *
00036    * @param file Input stream
00037    * @throw IOException
00038    */
00039   ConstantInteger(DataInputStream file) throws IOException
00040   {    
00041     this(file.readInt());
00042   }  
00043   /**
00044    * Called by objects that are traversing the nodes of the tree implicitely
00045    * defined by the contents of a Java class. I.e., the hierarchy of methods,
00046    * fields, attributes, etc. spawns a tree of objects.
00047    *
00048    * @param v Visitor object
00049    */
00050   public void accept(Visitor v) {
00051     v.visitConstantInteger(this);
00052   }  
00053   /**
00054    * Dump constant integer to file stream in binary format.
00055    *
00056    * @param file Output file stream
00057    * @throw IOException
00058    */ 
00059   public final void dump(DataOutputStream file) throws IOException
00060   {
00061     file.writeByte(tag);
00062     file.writeInt(bytes);
00063   }  
00064   /**
00065    * @return data, i.e., 4 bytes.
00066    */  
00067   public final int getBytes() { return bytes; }  
00068   /**
00069    * @param bytes.
00070    */
00071   public final void setBytes(int bytes) {
00072     this.bytes = bytes;
00073   }  
00074   /**
00075    * @return String representation.
00076    */
00077   public final String toString() {
00078     return super.toString() + "(bytes = " + bytes + ")";
00079   }  
00080 }

Generated at Thu Feb 7 06:42:56 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001