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

ConstantFloat.java

00001 package de.fub.bytecode.classfile;
00002 
00003 import de.fub.bytecode.Constants;
00004 import java.io.*;
00005 
00006 /** 
00007  * This class is derived from the abstract 
00008  * <A HREF="de.fub.bytecode.classfile.Constant.html">Constant</A> class 
00009  * and represents a reference to a float object.
00010  *
00011  * @version $Id: ConstantFloat.java,v 1.1.1.1 2002/01/24 03:44:00 pserver Exp $
00012  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00013  * @see     Constant
00014  */
00015 public final class ConstantFloat extends Constant {
00016   private float bytes;
00017 
00018   /** 
00019    * @param bytes Data
00020    */
00021   public ConstantFloat(float bytes)
00022   {    
00023     super(CONSTANT_Float);
00024     this.bytes = bytes;
00025   }  
00026   /**
00027    * Initialize from another object. Note that both objects use the same
00028    * references (shallow copy). Use clone() for a physical copy.
00029    */
00030   public ConstantFloat(ConstantFloat c) {
00031     this(c.getBytes());
00032   }  
00033   /** 
00034    * Initialize instance from file data.
00035    *
00036    * @param file Input stream
00037    * @throw IOException
00038    */
00039   ConstantFloat(DataInputStream file) throws IOException
00040   {    
00041     this(file.readFloat());
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.visitConstantFloat(this);
00052   }  
00053   /**
00054    * Dump constant float 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.writeFloat(bytes);
00063   }  
00064   /**
00065    * @return data, i.e. 4 bytes.
00066    */  
00067   public final float getBytes() { return bytes; }  
00068   /**
00069    * @param bytes.
00070    */
00071   public final void setBytes(float 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:55 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001