KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * CPUTFInfo.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  * A class representing the CONSTANT_Utf8 constant pool type.
30  *
31  * @author Thomas Ball
32  */

33 public final class CPUTF8Info extends CPName {
34     String JavaDoc name;
35     byte[] utf;
36
37     CPUTF8Info(ConstantPool pool, String JavaDoc name) {
38     super(pool);
39     this.name = name;
40     }
41
42     CPUTF8Info(ConstantPool pool, byte[] utf) {
43     super(pool);
44     this.utf = utf;
45     }
46
47     public final String JavaDoc getName() {
48     if (name == null) {
49         name = ConstantPoolReader.readUTF(utf, utf.length);
50         utf = null;
51     }
52     return name;
53     }
54
55     public final Object JavaDoc getValue() {
56         return getName();
57     }
58
59     public final int getTag() {
60     return ConstantPool.CONSTANT_Utf8;
61     }
62
63     public String JavaDoc toString() {
64     return getClass().getName() + ": name=" + getName(); //NOI18N
65
}
66 }
67
Popular Tags