KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > classfile > CPNameAndTypeInfo


1 /*
2  * CPNameAndTypeInfo.java
3  *
4  * The contents of this file are subject to the terms of the Common Development
5  * and Distribution License (the License). You may not use this file except in
6  * compliance with the License.
7  *
8  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
9  * or http://www.netbeans.org/cddl.txt.
10  *
11  * When distributing Covered Code, include this CDDL Header Notice in each file
12  * and include the License file at http://www.netbeans.org/cddl.txt.
13  * If applicable, add the following below the CDDL Header, with the fields
14  * enclosed by brackets [] replaced by your own identifying information:
15  * "Portions Copyrighted [year] [name of copyright owner]"
16  *
17  * The Original Software is NetBeans. The Initial Developer of the Original
18  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
19  * Microsystems, Inc. All Rights Reserved.
20  *
21  * Contributor(s): Thomas Ball
22  *
23  * Version: $Revision: 1.4 $
24  */

25
26 package org.netbeans.modules.classfile;
27
28
29 /**
30  * A class representing the CONSTANT_NameAndType constant pool type.
31  *
32  * @author Thomas Ball
33  */

34 public class CPNameAndTypeInfo extends CPEntry {
35     int iName;
36     int iDesc;
37
38     CPNameAndTypeInfo(ConstantPool pool,int iName,int iDesc) {
39     super(pool);
40         this.iName = iName;
41         this.iDesc = iDesc;
42     }
43
44     protected CPNameAndTypeInfo(ConstantPool pool) {
45         super(pool);
46         iName = CPName.INVALID_INDEX;
47         iDesc = CPName.INVALID_INDEX;
48     }
49
50     public final String JavaDoc getName() {
51     return ((CPName)pool.cpEntries[iName]).getName();
52     }
53
54     void setNameIndex(int index) {
55     iName = index;
56     }
57
58     public final String JavaDoc getDescriptor() {
59     return ((CPName)pool.cpEntries[iDesc]).getName();
60     }
61
62     void setDescriptorIndex(int index) {
63     iDesc = index;
64     }
65
66     public int getTag() {
67     return ConstantPool.CONSTANT_NameAndType;
68     }
69
70     public String JavaDoc toString() {
71         return getClass().getName() + ": name=" + getName() + //NOI18N
72
", descriptor=" + getDescriptor(); //NOI18N
73
}
74 }
75
Popular Tags