KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > optional > depend > constantpool > InterfaceMethodRefCPInfo


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18 package org.apache.tools.ant.taskdefs.optional.depend.constantpool;
19
20 import java.io.DataInputStream JavaDoc;
21 import java.io.IOException JavaDoc;
22
23 /**
24  * A InterfaceMethodRef CP Info
25  *
26  */

27 public class InterfaceMethodRefCPInfo extends ConstantPoolEntry {
28     /** the class name of the class defining the interface method */
29     private String JavaDoc interfaceMethodClassName;
30     /** the name of the interface nmethod */
31     private String JavaDoc interfaceMethodName;
32     /** the method signature of the interface method */
33     private String JavaDoc interfaceMethodType;
34     /**
35      * the index into the constant pool of the class entry for the interface
36      * class
37      */

38     private int classIndex;
39     /**
40      * the index into the constant pool of the name and type entry
41      * describing the method
42      */

43     private int nameAndTypeIndex;
44
45     /** Constructor. */
46     public InterfaceMethodRefCPInfo() {
47         super(CONSTANT_INTERFACEMETHODREF, 1);
48     }
49
50     /**
51      * read a constant pool entry from a class stream.
52      *
53      * @param cpStream the DataInputStream which contains the constant pool
54      * entry to be read.
55      * @exception IOException if there is a problem reading the entry from
56      * the stream.
57      */

58     public void read(DataInputStream JavaDoc cpStream) throws IOException JavaDoc {
59         classIndex = cpStream.readUnsignedShort();
60         nameAndTypeIndex = cpStream.readUnsignedShort();
61     }
62
63     /**
64      * Resolve this constant pool entry with respect to its dependents in
65      * the constant pool.
66      *
67      * @param constantPool the constant pool of which this entry is a member
68      * and against which this entry is to be resolved.
69      */

70     public void resolve(ConstantPool constantPool) {
71         ClassCPInfo interfaceMethodClass
72              = (ClassCPInfo) constantPool.getEntry(classIndex);
73
74         interfaceMethodClass.resolve(constantPool);
75
76         interfaceMethodClassName = interfaceMethodClass.getClassName();
77
78         NameAndTypeCPInfo nt
79              = (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex);
80
81         nt.resolve(constantPool);
82
83         interfaceMethodName = nt.getName();
84         interfaceMethodType = nt.getType();
85
86         super.resolve(constantPool);
87     }
88
89     /**
90      * Print a readable version of the constant pool entry.
91      *
92      * @return the string representation of this constant pool entry.
93      */

94     public String JavaDoc toString() {
95         String JavaDoc value;
96
97         if (isResolved()) {
98             value = "InterfaceMethod : Class = " + interfaceMethodClassName
99                  + ", name = " + interfaceMethodName + ", type = "
100                  + interfaceMethodType;
101         } else {
102             value = "InterfaceMethod : Class index = " + classIndex
103                  + ", name and type index = " + nameAndTypeIndex;
104         }
105
106         return value;
107     }
108
109     /**
110      * Gets the name of the class defining the interface method
111      *
112      * @return the name of the class defining the interface method
113      */

114     public String JavaDoc getInterfaceMethodClassName() {
115         return interfaceMethodClassName;
116     }
117
118     /**
119      * Get the name of the interface method
120      *
121      * @return the name of the interface method
122      */

123     public String JavaDoc getInterfaceMethodName() {
124         return interfaceMethodName;
125     }
126
127     /**
128      * Gets the type of the interface method
129      *
130      * @return the interface method's type signature
131      */

132     public String JavaDoc getInterfaceMethodType() {
133         return interfaceMethodType;
134     }
135
136 }
137
138
Popular Tags