KickJava   Java API By Example, From Geeks To Geeks.

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


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.CPInfo;
11 import org.gjt.jclasslib.structures.InvalidByteCodeException;
12
13 import java.io.*;
14
15 /**
16     Base class for large numeric constant pool data structures.
17
18     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
19     @version $Revision: 1.5 $ $Date: 2003/08/18 07:51:44 $
20 */

21 public abstract class ConstantLargeNumeric extends CPInfo {
22
23     /** Length of the constant pool data structure in bytes. */
24     public static final int SIZE = 8;
25     
26     /** <tt>high_bytes</tt> field. */
27     protected int highBytes;
28     /** <tt>low_bytes</tt> field. */
29     protected int lowBytes;
30     
31     /**
32         Get the <tt>high_bytes</tt> field of this constant pool entry.
33         @return the <tt>high_bytes</tt> field
34      */

35     public int getHighBytes() {
36         return highBytes;
37     }
38
39     /**
40         Set the <tt>high_bytes</tt> field of this constant pool entry.
41         @param highBytes the <tt>high_bytes</tt> field
42      */

43     public void setHighBytes(int highBytes) {
44         this.highBytes = highBytes;
45     }
46
47     /**
48         Get the <tt>low_bytes</tt> field of this constant pool entry.
49         @return the <tt>low_bytes</tt> field
50      */

51     public int getLowBytes() {
52         return lowBytes;
53     }
54
55     /**
56         Set the <tt>low_bytes</tt> field of this constant pool entry.
57         @param lowBytes the <tt>low_bytes</tt> field
58      */

59     public void setLowBytes(int lowBytes) {
60         this.lowBytes = lowBytes;
61     }
62     
63     /**
64         Get the the <tt>high_bytes</tt> field of this constant pool
65         entry as a hex string.
66         @return the hex string
67      */

68     public String JavaDoc getFormattedHighBytes() {
69         return printBytes(highBytes);
70     }
71
72     /**
73         Get the the <tt>low_bytes</tt> field of this constant pool
74         entry as a hex string.
75         @return the hex string
76      */

77     public String JavaDoc getFormattedLowBytes() {
78         return printBytes(lowBytes);
79     }
80
81     public void read(DataInput in)
82         throws InvalidByteCodeException, IOException {
83             
84         highBytes = in.readInt();
85         lowBytes = in.readInt();
86     }
87
88     public void write(DataOutput out)
89         throws InvalidByteCodeException, IOException {
90         
91         out.writeInt(highBytes);
92         out.writeInt(lowBytes);
93     }
94     
95     public boolean equals(Object JavaDoc object) {
96         if (!(object instanceof ConstantLargeNumeric)) {
97             return false;
98         }
99         ConstantLargeNumeric constantLargeNumeric = (ConstantLargeNumeric)object;
100         return super.equals(object) &&
101                constantLargeNumeric.highBytes == highBytes &&
102                constantLargeNumeric.lowBytes == lowBytes;
103     }
104
105     public int hashCode() {
106         return super.hashCode() ^ highBytes ^ lowBytes;
107     }
108     
109 }
110
Popular Tags