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: IInterfaceCollection.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.compiler.IClassFormatOutput; 12 13 // ---------------------------------------------------------------------------- 14 /** 15 * An abstraction of the 'interfaces' component of .class format. The contents 16 * are constant pool indices of {@link com.vladium.jcd.cls.constant.CONSTANT_Class_info} 17 * structures corresponding to direct superinterfaces of this class/interface. 18 * The order in which they appear is the left-to-right order of their declaration in 19 * the implements/extends clause. 20 * 21 * @author (C) 2001, Vlad Roubtsov 22 */ 23 public 24 interface IInterfaceCollection extends Cloneable, IClassFormatOutput 25 { 26 // public: ................................................................ 27 28 // ACCESSORS: 29 30 /** 31 * Returns the {@link com.vladium.jcd.cls.constant.CONSTANT_Class_info} 32 * constant pool index for offset'th direct superinterface. 33 * 34 * @param offset superinterface number [must be in [0, size()) range] 35 * @return constant pool index [always positive] 36 * 37 * @throws IndexOutOfBoundsException if 'offset' is outside of valid range 38 */ 39 int get (int offset); 40 41 /** 42 * Returns the number of direct superinterfaces for this class/interface. 43 * 44 * @return int number of direct superinterfaces [can be 0] 45 */ 46 int size (); 47 48 // Cloneable: adjust the access level of Object.clone(): 49 Object clone (); 50 51 // Visitor: 52 void accept (IClassDefVisitor visitor, Object ctx); 53 54 55 // MUTATORS: 56 57 /** 58 * Appends a new superinterface pointer to the collection. No duplicate checks are made. 59 * 60 * @param interface_index constant pool index [must be positive; input not validated] 61 * @return offset of the new pointer [same as {@link #size()}-1 when called 62 * after this method] 63 */ 64 int add (int interface_index); 65 66 /** 67 * Replaces superinterface pointer number 'offset' with new value 'interface_index'. 68 * No duplicate checks are made. It is the responsibility of the caller to 69 * ensure that the relevant CONSTANT_Class_info descriptor will be found 70 * in the constant pool, in the slot pointed to by 'interface_index'. 71 * 72 * @param offset offset of the superinterface pointer to replace [must be in [0, size()) range] 73 * @param interface_index constant pool index [must be positive; input not validated] 74 * @return previous value at the given index [always positive] 75 * 76 * @throws IndexOutOfBoundsException if 'offset' is outside of valid range 77 */ 78 int set (int offset, int interface_index); 79 80 } // end of interface 81 // ---------------------------------------------------------------------------- 82