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 20 package org.apache.bcel.classfile; 21 22 /** 23 * Unknown (non-standard) attributes may be read via user-defined factory objects that can be registered with the 24 * Attribute.addAttributeReader method. These factory objects should implement this interface. 25 * 26 * @see Attribute 27 * @since 6.0 28 */ 29 public interface UnknownAttributeReader { 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 * @param file This is the data input that the factory needs to read its data from. 40 * @param constantPool This is the constant pool associated with the Attribute that we are constructing. 41 * @return The user-defined AttributeReader should take this data and use it to construct an attribute. In the case of 42 * errors, a null can be returned which will cause the parsing of the class file to fail. 43 * 44 * @see Attribute#addAttributeReader(String, UnknownAttributeReader) 45 */ 46 Attribute createAttribute(int nameIndex, int length, java.io.DataInput file, ConstantPool constantPool); 47 }