KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > cojen > classfile > constant > ConstantLongInfo


1 /*
2  * Copyright 2004 Brian S O'Neill
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.cojen.classfile.constant;
18
19 import java.io.DataOutput JavaDoc;
20 import java.io.IOException JavaDoc;
21 import org.cojen.classfile.ConstantInfo;
22 import org.cojen.classfile.ConstantPool;
23
24 /**
25  * This class corresponds to the CONSTANT_Long_info structure as defined in
26  * section 4.4.5 of <i>The Java Virtual Machine Specification</i>.
27  *
28  * @author Brian S O'Neill
29  */

30 public class ConstantLongInfo extends ConstantInfo {
31     private final long mValue;
32     
33     public ConstantLongInfo(long value) {
34         super(TAG_LONG);
35         mValue = value;
36     }
37     
38     public long getValue() {
39         return mValue;
40     }
41
42     public int hashCode() {
43         return (int)(mValue ^ (mValue >>> 32));
44     }
45     
46     public boolean equals(Object JavaDoc obj) {
47         if (this == obj) {
48             return true;
49         }
50         if (obj instanceof ConstantLongInfo) {
51             ConstantLongInfo other = (ConstantLongInfo)obj;
52             return mValue == other.mValue;
53         }
54         return false;
55     }
56     
57     protected int getEntryCount() {
58         return 2;
59     }
60
61     public void writeTo(DataOutput JavaDoc dout) throws IOException JavaDoc {
62         super.writeTo(dout);
63         dout.writeLong(mValue);
64     }
65
66     public String JavaDoc toString() {
67         return "CONSTANT_Long_info: " + mValue;
68     }
69 }
70
Popular Tags