Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

PMGClass.java

00001 package de.fub.bytecode.classfile;
00002 
00003 import  de.fub.bytecode.Constants;
00004 import  java.io.*;
00005 
00006 /**
00007  * This class is derived from <em>Attribute</em> and represents a reference
00008  * to a <a href="http://www.inf.fu-berlin.de/~bokowski/pmgjava/index.html">PMG</a>
00009  * attribute.
00010  *
00011  * @version $Id: PMGClass.java,v 1.1.1.1 2002/01/24 03:44:01 pserver Exp $
00012  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00013  * @see     Attribute
00014  */
00015 public final class PMGClass extends Attribute {
00016   private int pmg_class_index, pmg_index;
00017 
00018   /**
00019    * @param name_index Index in constant pool to CONSTANT_Utf8
00020    * @param length Content length in bytes
00021    * @param constant_pool Array of constants
00022    * @param PMGClass_index Index in constant pool to CONSTANT_Utf8
00023    */
00024   public PMGClass(int name_index, int length, int pmg_index, int pmg_class_index,
00025           ConstantPool constant_pool)
00026   {
00027     super(ATTR_PMG, name_index, length, constant_pool);
00028     this.pmg_index       = pmg_index;
00029     this.pmg_class_index = pmg_class_index;
00030   }  
00031   /**
00032    * Construct object from file stream.
00033    * @param name_index Index in constant pool to CONSTANT_Utf8
00034    * @param length Content length in bytes
00035    * @param file Input stream
00036    * @param constant_pool Array of constants
00037    * @throw IOException
00038    */
00039   PMGClass(int name_index, int length, DataInputStream file,
00040        ConstantPool constant_pool) throws IOException
00041   {
00042     this(name_index, length, file.readUnsignedShort(), file.readUnsignedShort(),
00043      constant_pool);
00044   }  
00045   /**
00046    * Initialize from another object. Note that both objects use the same
00047    * references (shallow copy). Use clone() for a physical copy.
00048    */
00049   public PMGClass(PMGClass c) {
00050     this(c.getNameIndex(), c.getLength(), c.getPMGIndex(), c.getPMGClassIndex(),
00051      c.getConstantPool());
00052   }  
00053   /**
00054    * Called by objects that are traversing the nodes of the tree implicitely
00055    * defined by the contents of a Java class. I.e., the hierarchy of methods,
00056    * fields, attributes, etc. spawns a tree of objects.
00057    *
00058    * @param v Visitor object
00059    */
00060    public void accept(Visitor v) {
00061      System.err.println("Visiting non-standard PMGClass object");
00062    }   
00063   /**
00064    * @return deep copy of this attribute
00065    */
00066   public Attribute copy(ConstantPool constant_pool) {
00067     return (PMGClass)clone();
00068   }  
00069   /**
00070    * Dump source file attribute to file stream in binary format.
00071    *
00072    * @param file Output file stream
00073    * @throw IOException
00074    */ 
00075   public final void dump(DataOutputStream file) throws IOException
00076   {
00077     super.dump(file);
00078     file.writeShort(pmg_index);
00079     file.writeShort(pmg_class_index);
00080   }  
00081   /**
00082    * @return Index in constant pool of source file name.
00083    */  
00084   public final int getPMGClassIndex() { return pmg_class_index; }  
00085   /**
00086    * @return PMG class name.
00087    */ 
00088   public final String getPMGClassName() {
00089     ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_class_index, 
00090                                  CONSTANT_Utf8);
00091     return c.getBytes();
00092   }  
00093   /**
00094    * @return Index in constant pool of source file name.
00095    */  
00096   public final int getPMGIndex() { return pmg_index; }  
00097   /**
00098    * @return PMG name.
00099    */ 
00100   public final String getPMGName() {
00101     ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(pmg_index, 
00102                                  CONSTANT_Utf8);
00103     return c.getBytes();
00104   }  
00105   /**
00106    * @param PMGClass_index.
00107    */
00108   public final void setPMGClassIndex(int pmg_class_index) {
00109     this.pmg_class_index = pmg_class_index;
00110   }  
00111   /**
00112    * @param PMGClass_index.
00113    */
00114   public final void setPMGIndex(int pmg_index) {
00115     this.pmg_index = pmg_index;
00116   }  
00117   /**
00118    * @return String representation
00119    */ 
00120   public final String toString() {
00121     return "PMGClass(" + getPMGName() + ", " + getPMGClassName() + ")";
00122   }  
00123 }

Generated at Thu Feb 7 06:52:04 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001