001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     *
017     */
018    package org.apache.bcel.classfile;
019    
020    import java.io.DataInputStream;
021    import java.io.IOException;
022    import org.apache.bcel.Constants;
023    
024    /** 
025     * This class represents a constant pool reference to a method.
026     *
027     * @version $Id: ConstantMethodref.java 1152072 2011-07-29 01:54:05Z dbrosius $
028     * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
029     */
030    public final class ConstantMethodref extends ConstantCP {
031    
032        private static final long serialVersionUID = -864296320352750967L;
033    
034    
035        /**
036         * Initialize from another object.
037         */
038        public ConstantMethodref(ConstantMethodref c) {
039            super(Constants.CONSTANT_Methodref, c.getClassIndex(), c.getNameAndTypeIndex());
040        }
041    
042    
043        /**
044         * Initialize instance from file data.
045         *
046         * @param file input stream
047         * @throws IOException
048         */
049        ConstantMethodref(DataInputStream file) throws IOException {
050            super(Constants.CONSTANT_Methodref, file);
051        }
052    
053    
054        /**
055         * @param class_index Reference to the class containing the method
056         * @param name_and_type_index and the method signature
057         */
058        public ConstantMethodref(int class_index, int name_and_type_index) {
059            super(Constants.CONSTANT_Methodref, class_index, name_and_type_index);
060        }
061    
062    
063        /**
064         * Called by objects that are traversing the nodes of the tree implicitely
065         * defined by the contents of a Java class. I.e., the hierarchy of methods,
066         * fields, attributes, etc. spawns a tree of objects.
067         *
068         * @param v Visitor object
069         */
070        @Override
071        public void accept( Visitor v ) {
072            v.visitConstantMethodref(this);
073        }
074    }