View Javadoc

1   /*
2    * Copyright  2000-2004 The Apache Software Foundation
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package org.apache.bcel.classfile;
18  
19  /***
20   * Unknown (non-standard) attributes may be read via user-defined factory
21   * objects that can be registered with the Attribute.addAttributeReader
22   * method. These factory objects should implement this interface.
23  
24   * @see Attribute
25   * @version $Id: AttributeReader.java 386056 2006-03-15 11:31:56Z tcurdt $
26   * @author  <A HREF="mailto:m.dahm@gmx.de">M. Dahm</A>
27   */
28  public interface AttributeReader {
29  
30      /***
31       When this attribute reader is added via the static method
32       Attribute.addAttributeReader, an attribute name is associated with it.
33       As the class file parser parses attributes, it will call various
34       AttributeReaders based on the name of the attributes it is
35       constructing.
36  
37       @param name_index An index into the constant pool, indexing a
38       ConstantUtf8 that represents the name of the attribute.
39  
40       @param length The length of the data contained in the attribute.  This
41       is written into the constant pool and should agree with what the
42       factory expects the length to be.
43  
44       @param file This is the data input stream that the factory needs to read
45       its data from.
46  
47       @param constant_pool This is the constant pool associated with the
48       Attribute that we are constructing.
49  
50       @return The user-defined AttributeReader should take this data and use
51       it to construct an attribute.  In the case of errors, a null can be
52       returned which will cause the parsing of the class file to fail.
53  
54       @see Attribute#addAttributeReader( String, AttributeReader )
55       */
56      public Attribute createAttribute( int name_index, int length, java.io.DataInputStream file,
57              ConstantPool constant_pool );
58  }