KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > javaguard > classfile > LongCpInfo


1 /**
2  * JavaGuard -- an obfuscation package for Java classfiles.
3  *
4  * Copyright (c) 1999 Mark Welsh (markw@retrologic.com)
5  * Copyright (c) 2002 Thorsten Heit (theit@gmx.de)
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  * The author may be contacted at theit@gmx.de.
22  *
23  *
24  * $Id: LongCpInfo.java,v 1.3 2002/05/11 19:11:19 glurk Exp $
25  */

26 package net.sf.javaguard.classfile;
27
28 import java.io.*;
29 import java.util.*;
30
31 /** Representation of a 'long' entry in the ConstantPool (takes up two indices).
32  *
33  * @author <a HREF="mailto:theit@gmx.de">Thorsten Heit</a>
34  * @author <a HREF="mailto:markw@retrologic.com">Mark Welsh</a>
35  */

36 public class LongCpInfo extends CpInfo {
37   /** Holds the long value, stored in two 4-byte array in the class file. */
38   private long value;
39   
40   
41   
42   
43   /** Default constructor that creates a new LongCpInfo object.
44    */

45   protected LongCpInfo() {
46     super(CONSTANT_Long);
47   }
48   
49   
50   
51   
52   /** Sets the long value for the entry.
53    * @param value the long value for the entry
54    * @see #getLongValue
55    */

56   protected void setLongValue(long value) {
57     this.value = value;
58   }
59   
60   
61   /** Returns the long value for the entry.
62    * @return long value for the entry.
63    * @see #setLongValue
64    */

65   protected long getLongValue() {
66     return value;
67   }
68   
69   
70   
71   
72   /** Read the 'info' data (the double value) following the u1tag byte.
73    * @param din the input stream
74    * @throws IOException if an I/O error occurs
75    */

76   protected void readInfo(DataInput din)
77   throws IOException {
78     setLongValue(din.readLong());
79   }
80   
81   
82   /** Write the 'info' data (the double value) following the u1tag byte.
83    * @param dout the output stream
84    * @throws IOException if an I/O error occurs
85    */

86   protected void writeInfo(DataOutput dout)
87   throws IOException {
88     dout.writeLong(getLongValue());
89   }
90   
91   
92   
93   
94   /** Dump the content of the entry to the specified file (used for debugging).
95    * @param pw the print writer
96    * @param cf the class file the element belongs to
97    * @param index the index in the constant pool
98    */

99   public void dump(PrintWriter pw, ClassFile cf, int index) {
100     pw.print('['); pw.print(index); pw.println("]: LongCpInfo");
101     pw.print(" -> long value: ");
102     pw.println(getLongValue());
103   }
104 }
105
Popular Tags