KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > structures > constants > ConstantDoubleInfo


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.structures.constants;
9
10 import org.gjt.jclasslib.structures.InvalidByteCodeException;
11
12 import java.io.*;
13
14 /**
15     Describes a <tt>CONSTANT_Double_info</tt> constant pool data structure.
16  
17     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
18     @version $Revision: 1.4 $ $Date: 2003/08/20 17:14:37 $
19 */

20 public class ConstantDoubleInfo extends ConstantLargeNumeric {
21
22     public byte getTag() {
23         return CONSTANT_DOUBLE;
24     }
25
26     public String JavaDoc getTagVerbose() {
27         return CONSTANT_DOUBLE_VERBOSE;
28     }
29
30     public String JavaDoc getVerbose() throws InvalidByteCodeException {
31         return String.valueOf(getDouble());
32     }
33     
34     /**
35         Get the double value of this constant pool entry.
36         @return the value
37      */

38     public double getDouble() {
39         long longBits = (long)highBytes << 32 | (long)lowBytes & 0xFFFFFFFFL;
40         return Double.longBitsToDouble(longBits);
41     }
42
43     /**
44         Set the double value of this constant pool entry.
45         @param number the value
46      */

47     public void setDouble(double number) {
48         long longBits = Double.doubleToLongBits(number);
49         highBytes = (int)(longBits >>> 32 & 0xFFFFFFFFL);
50         lowBytes = (int)(longBits & 0xFFFFFFFFL);
51     }
52
53     public void read(DataInput in)
54         throws InvalidByteCodeException, IOException {
55         
56         super.read(in);
57         if (debug) debug("read ");
58     }
59
60     public void write(DataOutput out)
61         throws InvalidByteCodeException, IOException {
62         
63         out.writeByte(CONSTANT_DOUBLE);
64         super.write(out);
65         if (debug) debug("wrote ");
66     }
67     
68     protected void debug(String JavaDoc message) {
69         super.debug(message + getTagVerbose() + " with high_bytes " + highBytes +
70               " and low_bytes " + lowBytes);
71     }
72 }
73
Popular Tags