KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > api > persistence > enhancer > classfile > ConstBasicMemberRef


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25 package com.sun.jdo.api.persistence.enhancer.classfile;
26
27 import java.io.*;
28
29 /**
30  * The abstract base class used to represent the various type of
31  * references to members (fields/methods) within the constant pool.
32  */

33
34 public abstract class ConstBasicMemberRef extends ConstBasic {
35   /* The name of the class on which the member is defined */
36   protected ConstClass theClassName;
37
38   /* The index of the class on which the member is defined
39    * - used temporarily while reading from a class file */

40   protected int theClassNameIndex;
41
42   /* The name and type of the member */
43   protected ConstNameAndType theNameAndType;
44
45   /* The index of the name and type of the member
46    * - used temporarily while reading from a class file */

47   protected int theNameAndTypeIndex;
48
49   /* public accessors */
50
51   /**
52    * Return the name of the class defining the member
53    */

54   public ConstClass className() {
55     return theClassName;
56   }
57
58   /**
59    * Return the name and type of the member
60    */

61   public ConstNameAndType nameAndType() {
62     return theNameAndType;
63   }
64
65   public String JavaDoc toString () {
66       return "className(" + theClassName.toString() + ")" +//NOI18N
67
" nameAndType(" + theNameAndType.toString() + ")";//NOI18N
68
}
69
70   /* package local methods */
71
72   /**
73    * Constructor for "from scratch" creation
74    */

75   ConstBasicMemberRef (ConstClass cname, ConstNameAndType NT) {
76     theClassName = cname;
77     theNameAndType = NT;
78   }
79
80   /**
81    * Constructor for reading from a class file
82    */

83   ConstBasicMemberRef (int cnameIndex, int NT_index) {
84     theClassNameIndex = cnameIndex;
85     theNameAndTypeIndex = NT_index;
86   }
87
88   void formatData (DataOutputStream b) throws IOException {
89     b.writeShort(theClassName.getIndex());
90     b.writeShort(theNameAndType.getIndex());
91   }
92   void resolve (ConstantPool p) {
93     theClassName = (ConstClass) p.constantAt(theClassNameIndex);
94     theNameAndType = (ConstNameAndType) p.constantAt(theNameAndTypeIndex);
95   }
96 }
97
98
Popular Tags