Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/chaoswg/xtc4y/classdesc/LongCPEntry.java


1   //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/classdesc/LongCPEntry.java,v 1.1.1.1 2003/08/07 13:40:28 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:28 $, 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 Long constant pool entry
26   * @author Mike Toggweiler
27   **/
28  public class LongCPEntry extends WideValueCPEntry {
29      /**
30       * The tag identifying a Long cp entry
31       **/
32      public static final byte TAG = 5;
33  
34      private long value;
35  
36      /**
37       * Construct a new long CP entry with a long value
38       **/
39      public LongCPEntry(long value) {
40    super(TAG);
41    this.value = value;
42      }
43  
44      /**
45       * Creates a new long contantpool entry and initalizes it from a 
46       * DataInputStream     
47       * @param dis the DataInputStream to read from
48       **/
49      protected LongCPEntry(DataInputStream dis) 
50    throws IOException {
51    super(TAG);
52    int high = dis.readInt();
53    int low = dis.readInt();
54    value =((long) high << 32) + low ;  
55      }
56  
57      /**
58       * Resolve the internal stored indices thorugh the Constantpool
59       * @param cp the constantpool to resolve indices
60       **/
61      protected void resolve(ConstantPool cp) {
62      }
63  
64      /**
65       * Write the type specific constant pool entry information onto a 
66       * DataOutputStream
67       * @param dos the DataOutputStream to write on     
68       * @param cp the constantpool entry used to register names
69       **/
70      protected void writeCPEntry(DataOutputStream dos, ConstantPool cp) 
71    throws IOException {
72    int high = (int)(value >> 32);
73    int low = (int)value;
74    dos.writeInt(high);
75    dos.writeInt(low);
76      }
77  
78      /**
79       * @return the bytes representing the long value
80       **/
81      public long getValue() {
82    return value;
83      }
84  
85      /**
86       * Set the long value
87       * @param value the new value
88       **/
89      public void setValue(long value) {
90    this.value = value;
91      }
92  
93      /**
94       * @return the number of pool enties used for this entry
95       **/
96      public int getUsedCPSpace() {
97    return 2;
98      }
99  
100     /**
101      * print in a readable way
102      **/
103     public String toString() {
104   return getClass().getName()+":"+hashCode()+":"+value;
105     }
106 }