Home | History | Annotate | Download | only in constant
      1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved.
      2  *
      3  * This program and the accompanying materials are made available under
      4  * the terms of the Common Public License v1.0 which accompanies this distribution,
      5  * and is available at http://www.eclipse.org/legal/cpl-v10.html
      6  *
      7  * $Id: CONSTANT_Float_info.java,v 1.1.1.1 2004/05/09 16:57:48 vlad_r Exp $
      8  */
      9 package com.vladium.jcd.cls.constant;
     10 
     11 import java.io.IOException;
     12 
     13 import com.vladium.jcd.lib.UDataInputStream;
     14 import com.vladium.jcd.lib.UDataOutputStream;
     15 
     16 // ----------------------------------------------------------------------------
     17 /**
     18  * The CONSTANT_Integer_info and CONSTANT_Float_info structures represent
     19  * four-byte numeric (int and float) constants.<P>
     20  *
     21  * The bytes item of the CONSTANT_Float_info structure contains the value of
     22  * the float constant in IEEE 754 floating-point "single format" bit layout.
     23  *
     24  * @author (C) 2001, Vlad Roubtsov
     25  */
     26 public
     27 final class CONSTANT_Float_info extends CONSTANT_literal_info
     28 {
     29     // public: ................................................................
     30 
     31     public static final byte TAG = 4;
     32 
     33     public float m_value;
     34 
     35 
     36     public CONSTANT_Float_info (final float value)
     37     {
     38         m_value = value;
     39     }
     40 
     41     public final byte tag ()
     42     {
     43         return TAG;
     44     }
     45 
     46     // Visitor:
     47 
     48     public Object accept (final ICONSTANTVisitor visitor, final Object ctx)
     49     {
     50         return visitor.visit (this, ctx);
     51     }
     52 
     53     public String toString ()
     54     {
     55         return Float.toString (m_value);
     56     }
     57 
     58     // Cloneable: inherited clone() is Ok
     59 
     60     // IClassFormatOutput:
     61 
     62     public void writeInClassFormat (final UDataOutputStream out) throws IOException
     63     {
     64         super.writeInClassFormat (out);
     65 
     66         out.writeFloat (m_value);
     67     }
     68 
     69     // protected: .............................................................
     70 
     71 
     72     protected CONSTANT_Float_info (final UDataInputStream bytes) throws IOException
     73     {
     74         m_value = bytes.readFloat ();
     75     }
     76 
     77     // package: ...............................................................
     78 
     79     // private: ...............................................................
     80 
     81 } // end of class
     82 // ----------------------------------------------------------------------------
     83