Source code: com/chaoswg/xtc4y/classdesc/FloatCPEntry.java
1 //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/classdesc/FloatCPEntry.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 Float constant pool entry
26 * @author Mike Toggweiler
27 **/
28 public final class FloatCPEntry extends ShortValueCPEntry {
29 /**
30 * The tag identifying a Float cp entry
31 **/
32 public static final byte TAG = 4;
33
34 private float value;
35
36 /**
37 * Constructor for internal usage to overwrite the tag flag
38 **/
39 public FloatCPEntry(float value) {
40 super(TAG);
41 this.value = value;
42 }
43
44 /**
45 * Creates a new Integer contantpool entry and initalizes it from a
46 * DataInputStream
47 * @param dis the DataInputStream to read from
48 **/
49 protected FloatCPEntry(DataInputStream dis)
50 throws IOException {
51 super(TAG);
52 value = Float.intBitsToFloat(dis.readInt());
53 }
54
55 /**
56 * Resolve the internal stored indices thorugh the Constantpool
57 * @param cp the constantpool to resolve indices
58 **/
59 protected void resolve(ConstantPool cp) {
60 }
61
62 /**
63 * Write the type specific constant pool entry information onto a
64 * DataOutputStream
65 * @param dos the DataOutputStream to write on
66 * @param cp the constantpool entry used to register names
67 **/
68 protected void writeCPEntry(DataOutputStream dos, ConstantPool cp)
69 throws IOException {
70 dos.writeInt(Float.floatToIntBits(value));
71 }
72
73 /**
74 * @return the bytes representing the int value
75 **/
76 public float getValue() {
77 return value;
78 }
79
80 /**
81 * Set the float value
82 * @param value the new value
83 **/
84 public void setValue(float value) {
85 this.value = value;
86 }
87
88 /**
89 * print in a readable way
90 **/
91 public String toString() {
92 return getClass().getName()+":"+hashCode()+":"+value;
93 }
94 }