1 /* Copyright (C) 2003 Vladimir Roubtsov. All rights reserved. 2 * 3 * This program and the accompanying materials are made available under 4 * the terms of the Common Public License v1.0 which accompanies this distribution, 5 * and is available at http://www.eclipse.org/legal/cpl-v10.html 6 * 7 * $Id: IAttributeCollection.java,v 1.1.1.1 2004/05/09 16:57:46 vlad_r Exp $ 8 */ 9 package com.vladium.jcd.cls; 10 11 import com.vladium.jcd.cls.attribute.*; 12 import com.vladium.jcd.compiler.IClassFormatOutput; 13 14 // ---------------------------------------------------------------------------- 15 /** 16 * An abstraction of the 'attributes' component of .class format. The contents 17 * are {@link Attribute_info} structures. The order in which they appear is 18 * unspecified. 19 * 20 * @author (C) 2001, Vlad Roubtsov 21 */ 22 public 23 interface IAttributeCollection extends Cloneable, IClassFormatOutput 24 { 25 // public: ................................................................ 26 27 // ACCESSORS: 28 29 /** 30 * Returns the attribute descriptor at a given offset. 31 * 32 * @param offset attribute offset [must be in [0, size()) range; input not checked] 33 * @return Attribute_info descriptor [never null] 34 * 35 * @throws IndexOutOfBoundsException if 'offset' is outside of valid range 36 */ get(int offset)37 Attribute_info get (int offset); 38 hasSynthetic()39 boolean hasSynthetic (); hasBridge()40 boolean hasBridge (); getInnerClassesAttribute()41 InnerClassesAttribute_info getInnerClassesAttribute (); 42 43 /** 44 * Returns the number of attributes in this collection [can be 0]. 45 */ size()46 int size (); 47 48 /** 49 * Returns the total length of this collection when converted to 50 * .class format [including 2 count bytes] 51 */ length()52 long length (); 53 54 // Cloneable: adjust the access level of Object.clone(): clone()55 Object clone (); 56 57 // Visitor: accept(IClassDefVisitor visitor, Object ctx)58 void accept (IClassDefVisitor visitor, Object ctx); 59 60 61 // MUTATORS: 62 63 /** 64 * Adds a new Attribute_info descriptor to this collection. No duplicate 65 * checks are made. It is the responsibility of the caller to ensure 66 * that all data referenced in 'attribute' will eventually appear in the 67 * constant pool. 68 * 69 * @param attribute new attribute descriptor [may not be null] 70 */ add(Attribute_info attribute)71 int add (Attribute_info attribute); 72 73 /** 74 * Replaces the Attribute_info descriptor at a given offset. No duplicate 75 * checks are made. It is the responsibility of the caller to ensure that 76 * all data referenced in 'attribute' will eventually appear in the constant 77 * pool. 78 * 79 * @param offset attribute offset [must be in [0, size()) range; input not checked] 80 * @param attribute new attribute descriptor [may not be null] 81 * @return previous attribute descriptor at this offset [never null] 82 * 83 * @throws IndexOutOfBoundsException if 'offset' is outside of valid range 84 */ set(int offset, Attribute_info attribute)85 Attribute_info set (int offset, Attribute_info attribute); 86 87 /** 88 * Removes the Attribute_info descriptor at a given offset. 89 * 90 * @param offset attribute offset [must be in [0, size()) range; input not checked] 91 * @return current attribute descriptor at this offset [never null] 92 * 93 * @throws IndexOutOfBoundsException if 'offset' is outside of valid range 94 */ remove(int offset)95 Attribute_info remove (int offset); 96 97 } // end of interface 98 // ---------------------------------------------------------------------------- 99