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

Quick Search    Search Deep

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


1   //$Header: /cvsroot/xtc4y/xtc4y/src/com/chaoswg/xtc4y/classdesc/ConstantPoolEntry.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   * A Constant pool consists of a set of Constant pool entries. There are 
26   * types of a constantpool entry defined, which wil be implemented in 
27   * subclasses
28   * @author Mike Toggweiler
29   **/
30  public abstract class ConstantPoolEntry {
31      private byte tag;
32  
33      /**
34       * Create a constant pool entry with a tag, representing the type 
35       **/
36      protected ConstantPoolEntry(byte tag) {
37    this.tag = tag;
38      }
39  
40      /**
41       * Write the constant pool entry information onto a DataOutputStream
42       * @param dos the DataOutputStream to write on     
43       * @param cp the constantpool entry used to register names
44       **/
45      protected final void write(DataOutputStream dos, ConstantPool cp) 
46    throws IOException {
47    dos.writeByte(tag);
48    writeCPEntry(dos, cp);
49      }
50  
51      /**
52       * Resolve the internal stored indices thorugh the Constantpool
53       * @param cp the constantpool to resolve indices
54       **/
55      protected abstract void resolve(ConstantPool cp);
56  
57      /**
58       * Write the type specific constant pool entry information onto a 
59       * DataOutputStream
60       * @param dos the DataOutputStream to write on   
61       * @param cp the constantpool to register variables
62       **/
63      protected abstract void writeCPEntry(DataOutputStream dos, 
64             ConstantPool cp) 
65    throws IOException;
66  
67      /**
68       * @return the tag of the constant pool entry
69       **/
70      public byte getTag() {
71    return tag;
72      }
73  
74      /**
75       * @return the number of places used in the cp table, default is 1
76       **/
77      public int getUsedCPSpace() {
78    return 1;
79      }
80  }