Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/chaoswg/xtc4y/classdesc/DoubleCPEntry.java


1   //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/classdesc/DoubleCPEntry.java,v 1.1.1.1 2003/08/07 13:40:30 toggm Exp $
2   /******************************************************************************
3    * XTC4y - eXtreme Testing Collection 4 you                                   *
4    * -------------------------------------------------------------------------- *
5    * URL: http://www.chaoswg.com/xtc4y                                          *
6    * Author: Mike Toggweiler (2.dog@gmx.ch)                                     *
7    *                                                                            *
8    * Last Updated: $Date: 2003/08/07 13:40:30 $, by $Author: toggm $            *
9    * Version: $Revision: 1.1.1.1 $                                                  *
10   * -------------------------------------------------------------------------- *
11   * COPYRIGHT:   (c) 2003 by Mike Toggweiler                                   *
12   *                                                                            *
13   * This program is free software; you can redistribute it and/or modify       *
14   * it under the terms of the GNU General Public License as published by       *
15   * the Free Software Foundation; either version 2 of the License, or          *
16   * (at your option) any later version.                                        *
17   *****************************************************************************/
18  package com.chaoswg.xtc4y.classdesc;
19  
20  import java.io.DataInputStream;
21  import java.io.DataOutputStream;
22  import java.io.IOException;
23  
24  /**
25   * this class represent a Double constant pool entry
26   * @author Mike Toggweiler
27   **/
28  public final class DoubleCPEntry extends WideValueCPEntry {
29      /**
30       * The tag identifying a Double cp entry
31       **/
32      public static final byte TAG = 6;
33  
34      private double value;
35  
36      /**
37       * Construct a new long CP entry with a long value
38       **/
39      public DoubleCPEntry(double value) {
40    super(TAG);
41    this.value = value;
42      }
43  
44      /**
45       * Creates a new double contantpool entry and initalizes it from a 
46       * DataInputStream     
47       * @param dis the DataInputStream to read from
48       **/
49      protected DoubleCPEntry(DataInputStream dis) 
50    throws IOException {
51    super(TAG);
52    int high = dis.readInt();
53    int low = dis.readInt();
54    long longValue =((long) high << 32) + low ;  
55    value = Double.longBitsToDouble(longValue);
56      }
57  
58      /**
59       * Resolve the internal stored indices thorugh the Constantpool
60       * @param cp the constantpool to resolve indices
61       **/
62      protected void resolve(ConstantPool cp) {
63      }
64  
65      /**
66       * Write the type specific constant pool entry information onto a 
67       * DataOutputStream
68       * @param dos the DataOutputStream to write on     
69       * @param cp the constantpool entry used to register names
70       **/
71      protected void writeCPEntry(DataOutputStream dos, ConstantPool cp) 
72    throws IOException {
73    
74    long longValue = Double.doubleToLongBits(value);
75    int high = (int)(longValue >> 32);
76    int low = (int)longValue;
77    dos.writeInt(high);
78    dos.writeInt(low);
79      }
80  
81      /**
82       * @return the bytes representing the double value
83       **/
84      public double getValue() {
85    return value;
86      }
87  
88      /**
89       * Set the double value
90       * @param value the new value
91       **/
92      public void setValue(double value) {
93    this.value = value;
94      }
95  
96      /**
97       * @return the number of pool enties used for this entry
98       **/
99      public int getUsedCPSpace() {
100   return 2;
101     }
102 
103     /**
104      * print in a readable way
105      **/
106     public String toString() {
107   return getClass().getName()+":"+hashCode()+":"+value;
108     }
109 }