KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > vladium > jcd > cls > constant > CONSTANT_Double_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_Double_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 JavaDoc;
12
13 import com.vladium.jcd.lib.UDataInputStream;
14 import com.vladium.jcd.lib.UDataOutputStream;
15
16 // ----------------------------------------------------------------------------
17
/**
18  * The {@link CONSTANT_Long_info} and CONSTANT_Double_info represent eight-byte
19  * numeric (long and double) constants.<P>
20  *
21  * The high_bytes and low_bytes items of the CONSTANT_Double_info structure contain
22  * the double value in IEEE 754 floating-point "double format" bit layout.
23  *
24  * @author (C) 2001, Vlad Roubtsov
25  */

26 public
27 final class CONSTANT_Double_info extends CONSTANT_literal_info
28 {
29     // public: ................................................................
30

31     public static final byte TAG = 6;
32     
33     public double m_value;
34     
35     
36     public CONSTANT_Double_info (final double 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 JavaDoc accept (final ICONSTANTVisitor visitor, final Object JavaDoc ctx)
49     {
50         return visitor.visit (this, ctx);
51     }
52     
53     public String JavaDoc toString ()
54     {
55         return Double.toString (m_value);
56     }
57     
58     /**
59      * Overrides the default implementation to return '2'.
60      */

61     public int width ()
62     {
63         return 2;
64     }
65     
66     // Cloneable: inherited clone() is Ok
67

68     
69     // IClassFormatOutput:
70

71     public void writeInClassFormat (final UDataOutputStream out) throws IOException JavaDoc
72     {
73         super.writeInClassFormat (out);
74         
75         out.writeDouble (m_value);
76     }
77     
78     // protected: .............................................................
79

80     
81     protected CONSTANT_Double_info (final UDataInputStream bytes) throws IOException JavaDoc
82     {
83         m_value = bytes.readDouble ();
84     }
85     
86     // package: ...............................................................
87

88     // private: ...............................................................
89

90 } // end of class
91
// ----------------------------------------------------------------------------
92
Popular Tags