KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > vladium > jcd > cls > constant > CONSTANT_Utf8_info


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_Utf8_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 JavaDoc;
12
13 import com.vladium.jcd.lib.UDataInputStream;
14 import com.vladium.jcd.lib.UDataOutputStream;
15
16 // ----------------------------------------------------------------------------
17
/**
18  * The CONSTANT_Utf8_info structure is used to represent constant string values.<P>
19  *
20  * The bytes of multibyte characters are stored in the class file in big-endian
21  * (high byte first) order. There are two differences between this format and the
22  * "standard" UTF-8 format. First, the null byte (byte)0 is encoded using the
23  * two-byte format rather than the one-byte format, so that Java Virtual Machine
24  * UTF-8 strings never have embedded nulls. Second, only the one-byte, two-byte,
25  * and three-byte formats are used. The Java Virtual Machine does not recognize
26  * the longer UTF-8 formats.
27  *
28  * @author (C) 2001, Vlad Roubtsov
29  */

30 public
31 final class CONSTANT_Utf8_info extends CONSTANT_info
32 {
33     // public: ................................................................
34

35     public static final byte TAG = 1;
36     
37     public String JavaDoc m_value;
38     
39     
40     public CONSTANT_Utf8_info (final String JavaDoc value)
41     {
42         m_value = value;
43     }
44
45
46     public final byte tag ()
47     {
48         return TAG;
49     }
50     
51     // Visitor:
52

53     public Object JavaDoc accept (final ICONSTANTVisitor visitor, final Object JavaDoc ctx)
54     {
55         return visitor.visit (this, ctx);
56     }
57     
58     public String JavaDoc toString ()
59     {
60         return "CONSTANT_Utf8: [" + m_value + ']';
61     }
62        
63     // Cloneable: inherited clone() is Ok
64

65     // IClassFormatOutput:
66

67     public void writeInClassFormat (final UDataOutputStream out) throws IOException JavaDoc
68     {
69         super.writeInClassFormat (out);
70         
71         out.writeUTF (m_value);
72     }
73     
74     // protected: .............................................................
75

76     
77     protected CONSTANT_Utf8_info (final UDataInputStream bytes) throws IOException JavaDoc
78     {
79         m_value = bytes.readUTF ();
80     }
81     
82     // package: ...............................................................
83

84     // private: ...............................................................
85

86 } // end of class
87
// ----------------------------------------------------------------------------
88
Popular Tags