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_String_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_String_info structure is used to represent constant objects of
     19  * the type java.lang.String.<P>
     20  *
     21  * The value of the string_index item must be a valid index into the constant pool
     22  * table. The constant pool entry at that index must be a {@link CONSTANT_Utf8_info}
     23  * structure representing the sequence of characters to which the
     24  * java.lang.String object is to be initialized.
     25  *
     26  * @author (C) 2001, Vlad Roubtsov
     27  */
     28 public
     29 final class CONSTANT_String_info extends CONSTANT_literal_info
     30 {
     31     // public: ................................................................
     32 
     33     public static final byte TAG = 8;
     34 
     35     public int m_string_index;
     36 
     37 
     38     public CONSTANT_String_info (final int string_index)
     39     {
     40         m_string_index = string_index;
     41     }
     42 
     43 
     44     public final byte tag ()
     45     {
     46         return TAG;
     47     }
     48 
     49     // Visitor:
     50 
     51     public Object accept (final ICONSTANTVisitor visitor, final Object ctx)
     52     {
     53         return visitor.visit (this, ctx);
     54     }
     55 
     56     public String toString ()
     57     {
     58         return "CONSTANT_String: [string_index = " + m_string_index + ']';
     59     }
     60 
     61     // Cloneable: inherited clone() is Ok
     62 
     63     // IClassFormatOutput:
     64 
     65     public void writeInClassFormat (final UDataOutputStream out) throws IOException
     66     {
     67         super.writeInClassFormat (out);
     68 
     69         out.writeU2 (m_string_index);
     70     }
     71 
     72     // protected: .............................................................
     73 
     74 
     75     protected CONSTANT_String_info (final UDataInputStream bytes) throws IOException
     76     {
     77         m_string_index = bytes.readU2 ();
     78     }
     79 
     80     // package: ...............................................................
     81 
     82     // private: ...............................................................
     83 
     84 } // end of class
     85 // ----------------------------------------------------------------------------
     86