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

FieldOrMethod.java

00001 package de.fub.bytecode.generic;
00002 
00003 import de.fub.bytecode.classfile.*;
00004 
00005 /**
00006  * Super class for InvokeInstruction and FieldInstruction, since they have
00007  * some methods in common!
00008  *
00009  * @version $Id: FieldOrMethod.java,v 1.1.1.1 2002/01/24 03:44:05 pserver Exp $
00010  * @author  <A HREF="http://www.inf.fu-berlin.de/~dahm">M. Dahm</A>
00011  */
00012 public abstract class FieldOrMethod extends CPInstruction implements LoadClass {
00013   /**
00014    * Empty constructor needed for the Class.newInstance() statement in
00015    * Instruction.readInstruction(). Not to be used otherwise.
00016    */
00017   FieldOrMethod() {}  
00018   /**
00019    * @param index to constant pool
00020    */
00021   protected FieldOrMethod(short tag, int index) {
00022     super(tag, index);
00023   }  
00024   /** @return name of the referenced class/interface
00025    */
00026   public String getClassName(ConstantPoolGen cpg) {
00027     ConstantPool cp  = cpg.getConstantPool();
00028     ConstantCP   cmr = (ConstantCP)cp.getConstant(index);
00029     return cp.getConstantString(cmr.getClassIndex(), CONSTANT_Class).replace('/', '.');
00030   }  
00031   /** @return type of the referenced class/interface
00032    */
00033   public ObjectType getClassType(ConstantPoolGen cpg) {
00034     return new ObjectType(getClassName(cpg));
00035   }  
00036   /** @return name of referenced method/field.
00037    */
00038   public String getName(ConstantPoolGen cpg) {
00039     ConstantPool        cp   = cpg.getConstantPool();
00040     ConstantCP          cmr  = (ConstantCP)cp.getConstant(index);
00041     ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex());
00042     return ((ConstantUtf8)cp.getConstant(cnat.getNameIndex())).getBytes();
00043   }  
00044   /** @return signature of referenced method/field.
00045    */
00046   public String getSignature(ConstantPoolGen cpg) {
00047     ConstantPool        cp   = cpg.getConstantPool();
00048     ConstantCP          cmr  = (ConstantCP)cp.getConstant(index);
00049     ConstantNameAndType cnat = (ConstantNameAndType)cp.getConstant(cmr.getNameAndTypeIndex());
00050 
00051     return ((ConstantUtf8)cp.getConstant(cnat.getSignatureIndex())).getBytes();
00052   }  
00053 }

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