KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > asm > tree > FieldNode


1 /***
2  * ASM: a very small and fast Java bytecode manipulation framework
3  * Copyright (c) 2000-2005 INRIA, France Telecom
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */

30 package org.objectweb.asm.tree;
31
32 import org.objectweb.asm.Attribute;
33 import org.objectweb.asm.ClassVisitor;
34 import org.objectweb.asm.FieldVisitor;
35
36 /**
37  * A node that represents a field.
38  *
39  * @author Eric Bruneton
40  */

41 public class FieldNode extends MemberNode implements FieldVisitor {
42
43     /**
44      * The field's access flags (see {@link Opcodes}). This field also
45      * indicates if the field is synthetic and/or deprecated.
46      */

47     public int access;
48
49     /**
50      * The field's name.
51      */

52     public String JavaDoc name;
53
54     /**
55      * The field's descriptor (see {@link Type}).
56      */

57     public String JavaDoc desc;
58
59     /**
60      * The field's signature. May be <tt>null</tt>.
61      */

62     public String JavaDoc signature;
63
64     /**
65      * The field's initial value. This field, which may be <tt>null</tt> if
66      * the field does not have an initial value, must be an {@link Integer}, a
67      * {@link Float}, a {@link Long}, a {@link Double} or a {@link String}.
68      */

69     public Object JavaDoc value;
70
71     /**
72      * Constructs a new {@link FieldNode}.
73      *
74      * @param access the field's access flags (see {@link Opcodes}). This
75      * parameter also indicates if the field is synthetic and/or
76      * deprecated.
77      * @param name the field's name.
78      * @param desc the field's descriptor (see {@link Type Type}).
79      * @param signature the field's signature.
80      * @param value the field's initial value. This parameter, which may be
81      * <tt>null</tt> if the field does not have an initial value, must
82      * be an {@link Integer}, a {@link Float}, a {@link Long}, a
83      * {@link Double} or a {@link String}.
84      */

85     public FieldNode(
86         final int access,
87         final String JavaDoc name,
88         final String JavaDoc desc,
89         final String JavaDoc signature,
90         final Object JavaDoc value)
91     {
92         this.access = access;
93         this.name = name;
94         this.desc = desc;
95         this.signature = signature;
96         this.value = value;
97     }
98
99     /**
100      * Makes the given class visitor visit this field.
101      *
102      * @param cv a class visitor.
103      */

104     public void accept(final ClassVisitor cv) {
105         FieldVisitor fv = cv.visitField(access, name, desc, signature, value);
106         int i, n;
107         n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
108         for (i = 0; i < n; ++i) {
109             AnnotationNode an = (AnnotationNode) visibleAnnotations.get(i);
110             an.accept(fv.visitAnnotation(an.desc, true));
111         }
112         n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
113         for (i = 0; i < n; ++i) {
114             AnnotationNode an = (AnnotationNode) invisibleAnnotations.get(i);
115             an.accept(fv.visitAnnotation(an.desc, false));
116         }
117         n = attrs == null ? 0 : attrs.size();
118         for (i = 0; i < n; ++i) {
119             fv.visitAttribute((Attribute) attrs.get(i));
120         }
121         fv.visitEnd();
122     }
123 }
124
Popular Tags