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

Signature.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 <href="http://wwwipd.ira.uka.de/~pizza/gj/">GJ</a> attribute.
00009  *
00010  * @version $Id: Signature.java,v 1.1.1.1 2002/01/24 03:41:37 pserver Exp $
00011  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00012  * @see     Attribute
00013  */
00014 public final class Signature extends Attribute {
00015   private int signature_index;
00016 
00017   /**
00018    * @param name_index Index in constant pool to CONSTANT_Utf8
00019    * @param length Content length in bytes
00020    * @param constant_pool Array of constants
00021    * @param Signature_index Index in constant pool to CONSTANT_Utf8
00022    */
00023   public Signature(int name_index, int length, int signature_index,
00024           ConstantPool constant_pool)
00025   {
00026     super(Constants.ATTR_SIGNATURE, name_index, length, constant_pool);
00027     this.signature_index = signature_index;
00028   }  
00029   /**
00030    * Construct object from file stream.
00031    * @param name_index Index in constant pool to CONSTANT_Utf8
00032    * @param length Content length in bytes
00033    * @param file Input stream
00034    * @param constant_pool Array of constants
00035    * @throw IOException
00036    */
00037   Signature(int name_index, int length, DataInputStream file,
00038        ConstantPool constant_pool) throws IOException
00039   {
00040     this(name_index, length, file.readUnsignedShort(), constant_pool);
00041   }  
00042   /**
00043    * Initialize from another object. Note that both objects use the same
00044    * references (shallow copy). Use clone() for a physical copy.
00045    */
00046   public Signature(Signature c) {
00047     this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool());
00048   }  
00049   /**
00050    * Called by objects that are traversing the nodes of the tree implicitely
00051    * defined by the contents of a Java class. I.e., the hierarchy of methods,
00052    * fields, attributes, etc. spawns a tree of objects.
00053    *
00054    * @param v Visitor object
00055    */
00056    public void accept(Visitor v) {
00057      System.err.println("Visiting non-standard Signature object");
00058    }   
00059   /**
00060    * @return deep copy of this attribute
00061    */
00062   public Attribute copy(ConstantPool constant_pool) {
00063     return (Signature)clone();
00064   }  
00065   /**
00066    * Dump source file attribute to file stream in binary format.
00067    *
00068    * @param file Output file stream
00069    * @throw IOException
00070    */ 
00071   public final void dump(DataOutputStream file) throws IOException
00072   {
00073     super.dump(file);
00074     file.writeShort(signature_index);
00075   }  
00076   /**
00077    * @return GJ signature.
00078    */ 
00079   public final String getSignature() {
00080     ConstantUtf8 c = (ConstantUtf8)constant_pool.getConstant(signature_index, 
00081                                  Constants.CONSTANT_Utf8);
00082     return c.getBytes();
00083   }  
00084   /**
00085    * @return Index in constant pool of source file name.
00086    */  
00087   public final int getSignatureIndex() { return signature_index; }  
00088   /**
00089    * @param Signature_index.
00090    */
00091   public final void setSignatureIndex(int signature_index) {
00092     this.signature_index = signature_index;
00093   }  
00094   /**
00095    * @return String representation
00096    */ 
00097   public final String toString() {
00098     return "Signature(" +  getSignature() + ")";
00099   }  
00100 }

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