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_Integer_info.java,v 1.1.1.1 2004/05/09 16:57:49 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_Integer_info structure contains the value of
     22  * the int constant. The bytes of the value are stored in big-endian (high byte
     23  * first) order.
     24  *
     25  * @author (C) 2001, Vlad Roubtsov
     26  */
     27 public
     28 final class CONSTANT_Integer_info extends CONSTANT_literal_info
     29 {
     30     // public: ................................................................
     31 
     32     public static final byte TAG = 3;
     33 
     34     public int m_value;
     35 
     36 
     37     public CONSTANT_Integer_info (final int value)
     38     {
     39         m_value = value;
     40     }
     41 
     42     public final byte tag ()
     43     {
     44         return TAG;
     45     }
     46 
     47     // Visitor:
     48 
     49     public Object accept (final ICONSTANTVisitor visitor, final Object ctx)
     50     {
     51         return visitor.visit (this, ctx);
     52     }
     53 
     54     public String toString ()
     55     {
     56         return Integer.toString (m_value);
     57     }
     58 
     59     // Cloneable: inherited clone() is Ok
     60 
     61     // IClassFormatOutput:
     62 
     63     public void writeInClassFormat (final UDataOutputStream out) throws IOException
     64     {
     65         super.writeInClassFormat (out);
     66 
     67         out.writeInt (m_value);
     68     }
     69 
     70     // protected: .............................................................
     71 
     72 
     73     protected CONSTANT_Integer_info (final UDataInputStream bytes) throws IOException
     74     {
     75         m_value = bytes.readInt ();
     76     }
     77 
     78     // package: ...............................................................
     79 
     80     // private: ...............................................................
     81 
     82 } // end of class
     83 // ----------------------------------------------------------------------------
     84