KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > structures > attributes > SignatureAttribute


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7 package org.gjt.jclasslib.structures.attributes;
8
9 import org.gjt.jclasslib.structures.AttributeInfo;
10 import org.gjt.jclasslib.structures.InvalidByteCodeException;
11
12 import java.io.*;
13
14 /**
15  * Describes an <tt>Signature</tt> attribute structure.
16  *
17  * @author <a HREF="mailto:vitor.carreira@gmail.com">Vitor Carreira</a>
18  * @version $Revision: 1.1 $ $Date: 2004/12/28 13:04:32 $
19  */

20 public class SignatureAttribute extends AttributeInfo {
21     /**
22      * Name of the attribute as in the corresponding constant pool entry.
23      */

24     public static final String JavaDoc ATTRIBUTE_NAME = "Signature";
25
26     private static final int LENGTH = 2;
27
28     private int signatureIndex;
29
30     /**
31      * Get the constant pool index of the <tt>CONSTANT_Utf8_info</tt>
32      * structure representing the signature.
33      *
34      * @return the index
35      */

36     public int getSignatureIndex() {
37         return signatureIndex;
38     }
39
40     public void read(DataInput in)
41             throws InvalidByteCodeException, IOException {
42         super.read(in);
43
44         signatureIndex = in.readUnsignedShort();
45
46         if (debug) debug("read ");
47     }
48
49     public void write(DataOutput out)
50             throws InvalidByteCodeException, IOException {
51         super.write(out);
52
53         out.writeShort(signatureIndex);
54
55         if (debug) debug("wrote ");
56     }
57
58     public int getAttributeLength() {
59         return LENGTH;
60     }
61
62     protected void debug(String JavaDoc message) {
63         super.debug(message +
64                 "Signature attribute with signature index " + signatureIndex);
65     }
66 }
67
Popular Tags