View Javadoc
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.bcel.classfile;
19  
20  import java.io.DataInput;
21  import java.io.IOException;
22  
23  import org.apache.bcel.Const;
24  
25  /**
26   * This class represents a constant pool reference to a field.
27   *
28   */
29  public final class ConstantFieldref extends ConstantCP {
30  
31      /**
32       * Initialize from another object.
33       */
34      public ConstantFieldrefantFieldref.html#ConstantFieldref">ConstantFieldref(final ConstantFieldref c) {
35          super(Const.CONSTANT_Fieldref, c.getClassIndex(), c.getNameAndTypeIndex());
36      }
37  
38  
39      /**
40       * Initialize instance from input data.
41       *
42       * @param input input stream
43       * @throws IOException
44       */
45      ConstantFieldref(final DataInput input) throws IOException {
46          super(Const.CONSTANT_Fieldref, input);
47      }
48  
49  
50      /**
51       * @param class_index Reference to the class containing the Field
52       * @param name_and_type_index and the Field signature
53       */
54      public ConstantFieldref(final int class_index, final int name_and_type_index) {
55          super(Const.CONSTANT_Fieldref, class_index, name_and_type_index);
56      }
57  
58  
59      /**
60       * Called by objects that are traversing the nodes of the tree implicitely
61       * defined by the contents of a Java class. I.e., the hierarchy of Fields,
62       * fields, attributes, etc. spawns a tree of objects.
63       *
64       * @param v Visitor object
65       */
66      @Override
67      public void accept( final Visitor v ) {
68          v.visitConstantFieldref(this);
69      }
70  }