1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.bcel.classfile;
20
21 /**
22 * Unknown (non-standard) attributes may be read via user-defined factory objects that can be registered with the
23 * Attribute.addAttributeReader method. These factory objects should implement this interface.
24 *
25 * @see Attribute
26 * @deprecated Use UnknownAttributeReader instead
27 */
28 @java.lang.Deprecated
29 public interface AttributeReader {
30
31 /**
32 * When this attribute reader is added via the static method Attribute.addAttributeReader, an attribute name is
33 * associated with it. As the class file parser parses attributes, it will call various AttributeReaders based on the
34 * name of the attributes it is constructing.
35 *
36 * @param nameIndex An index into the constant pool, indexing a ConstantUtf8 that represents the name of the attribute.
37 * @param length The length of the data contained in the attribute. This is written into the constant pool and should
38 * agree with what the factory expects the length to be.
39 *
40 * @param file This is the data input stream that the factory needs to read its data from.
41 * @param constantPool This is the constant pool associated with the Attribute that we are constructing.
42 * @return The user-defined AttributeReader should take this data and use it to construct an attribute. In the case of
43 * errors, a null can be returned which will cause the parsing of the class file to fail.
44 *
45 * @see Attribute#addAttributeReader( String, AttributeReader )
46 */
47 Attribute createAttribute(int nameIndex, int length, java.io.DataInputStream file, ConstantPool constantPool);
48 }