00001 package de.fub.bytecode.classfile;
00002
00003 import de.fub.bytecode.Constants;
00004 import java.io.*;
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 public final class Signature extends Attribute {
00015 private int signature_index;
00016
00017
00018
00019
00020
00021
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
00031
00032
00033
00034
00035
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
00044
00045
00046 public Signature(Signature c) {
00047 this(c.getNameIndex(), c.getLength(), c.getSignatureIndex(), c.getConstantPool());
00048 }
00049
00050
00051
00052
00053
00054
00055
00056 public void accept(Visitor v) {
00057 System.err.println("Visiting non-standard Signature object");
00058 }
00059
00060
00061
00062 public Attribute copy(ConstantPool constant_pool) {
00063 return (Signature)clone();
00064 }
00065
00066
00067
00068
00069
00070
00071 public final void dump(DataOutputStream file) throws IOException
00072 {
00073 super.dump(file);
00074 file.writeShort(signature_index);
00075 }
00076
00077
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
00086
00087 public final int getSignatureIndex() { return signature_index; }
00088
00089
00090
00091 public final void setSignatureIndex(int signature_index) {
00092 this.signature_index = signature_index;
00093 }
00094
00095
00096
00097 public final String toString() {
00098 return "Signature(" + getSignature() + ")";
00099 }
00100 }