View Javadoc

1   /*
2    * Copyright 2005 The Apache Software Foundation.
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  
18  package org.apache.jdo.impl.enhancer.classfile;
19  
20  import java.io.*;
21  import java.util.Stack;
22  
23  /***
24   * Class representing a long constant in the constant pool of a class file
25   */
26  public class ConstLong extends ConstValue {
27      /* The tag value associated with ConstLong */
28      public static final int MyTag = CONSTANTLong;
29  
30      /* The value */
31      private long longValue;
32  
33      /* public accessors */
34  
35      /***
36       * The tag of this constant entry
37       */
38      public int tag() { return MyTag; }
39  
40      /***
41       * return the value associated with the entry
42       */
43      public long value() {
44          return longValue;
45      }
46  
47      /***
48       * Return the descriptor string for the constant type.
49       */
50      public String descriptor() {
51          return "J";
52      }
53  
54      /***
55       * A printable representation
56       */
57      public String toString() {
58          return "CONSTANTLong(" + indexAsString() + "): " + 
59              "longValue(" + Long.toString(longValue) + ")";
60      }
61  
62      /***
63       * Compares this instance with another for structural equality.
64       */
65      //@olsen: added method
66      public boolean isEqual(Stack msg, Object obj) {
67          if (!(obj instanceof ConstLong)) {
68              msg.push("obj/obj.getClass() = "
69                       + (obj == null ? null : obj.getClass()));
70              msg.push("this.getClass() = "
71                       + this.getClass());
72              return false;
73          }
74          ConstLong other = (ConstLong)obj;
75  
76          if (!super.isEqual(msg, other)) {
77              return false;
78          }
79  
80          if (this.longValue != other.longValue) {
81              msg.push(String.valueOf("longValue = "
82                                      + other.longValue));
83              msg.push(String.valueOf("longValue = "
84                                      + this.longValue));
85              return false;
86          }
87          return true;
88      }
89  
90      /* package local methods *//package-summary/html">class="comment"> package local methods *//package-summary.html">/* package local methods *//package-summary.html">class="comment"> package local methods */
91  
92      ConstLong(long i) {
93          longValue = i;
94      }
95  
96      void formatData(DataOutputStream b) throws IOException {
97          b.writeLong(longValue);
98      }
99  
100     static ConstLong read(DataInputStream input) throws IOException {
101         return new ConstLong(input.readLong());
102     }
103 
104     void resolve(ConstantPool p) { }
105 }