KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > structures > MethodInfo


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
8 package org.gjt.jclasslib.structures;
9
10 import java.io.*;
11
12 /**
13  * Describes a method in a <tt>ClassFile</tt> structure.
14  *
15  * @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>, <a HREF="mailto:vitor.carreira@gmail.com">Vitor Carreira</a>
16  * @version $Revision: 1.3 $ $Date: 2004/12/28 13:04:32 $
17  */

18 public class MethodInfo extends ClassMember {
19
20     /**
21      * Factory method for creating <tt>MethodInfo</tt> structures from a <tt>DataInput</tt>.
22      *
23      * @param in the <tt>DataInput</tt> from which to read the <tt>MethodInfo</tt> structure
24      * @param classFile the parent class file of the structure to be created
25      * @return the new <tt>MethodInfo</tt> structure
26      * @throws InvalidByteCodeException if the byte code is invalid
27      * @throws IOException if an exception occurs with the <tt>DataInput</tt>
28      */

29     public static MethodInfo create(DataInput in, ClassFile classFile)
30             throws InvalidByteCodeException, IOException {
31
32         MethodInfo methodInfo = new MethodInfo();
33         methodInfo.setClassFile(classFile);
34         methodInfo.read(in);
35
36         return methodInfo;
37     }
38
39     public void read(DataInput in)
40             throws InvalidByteCodeException, IOException {
41
42         super.read(in);
43
44         if (debug) debug("read ");
45     }
46
47     public void write(DataOutput out)
48             throws InvalidByteCodeException, IOException {
49
50         super.write(out);
51         if (debug) debug("wrote ");
52     }
53
54     protected void debug(String JavaDoc message) {
55         super.debug(message + "method with access flags " + printAccessFlags(accessFlags) +
56                 ", name_index " + nameIndex + ", descriptor_index " + descriptorIndex +
57                 ", " + getLength(attributes) + " attributes");
58     }
59
60     protected String JavaDoc printAccessFlagsVerbose(int accessFlags) {
61         return printAccessFlagsVerbose(AccessFlags.METHOD_ACCESS_FLAGS, AccessFlags.METHOD_ACCESS_FLAGS_VERBOSE, accessFlags);
62     }
63
64 }
65
Popular Tags