AttributeList.java revision f6c387128427e121477c1b32ad35cdcaa5101ba3
1/* 2 * Copyright (C) 2007 The Android Open Source Project 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 17package com.android.dx.cf.iface; 18 19/** 20 * Interface for lists of attributes. 21 */ 22public interface AttributeList { 23 /** 24 * Get whether this instance is mutable. Note that the 25 * <code>AttributeList</code> interface itself doesn't provide any means 26 * of mutation, but that doesn't mean that there isn't a non-interface 27 * way of mutating an instance. 28 * 29 * @return <code>true</code> iff this instance is somehow mutable 30 */ 31 public boolean isMutable(); 32 33 /** 34 * Get the number of attributes in the list. 35 * 36 * @return the size 37 */ 38 public int size(); 39 40 /** 41 * Get the <code>n</code>th attribute. 42 * 43 * @param n <code>n >= 0, n < size()</code>; which attribute 44 * @return non-null; the attribute in question 45 */ 46 public Attribute get(int n); 47 48 /** 49 * Get the total length of this list in bytes, when part of a 50 * class file. The returned value includes the two bytes for the 51 * <code>attributes_count</code> length indicator. 52 * 53 * @return >= 2; the total length, in bytes 54 */ 55 public int byteLength(); 56 57 /** 58 * Get the first attribute in the list with the given name, if any. 59 * 60 * @param name non-null; attribute name 61 * @return null-ok; first attribute in the list with the given name, 62 * or <code>null</code> if there is none 63 */ 64 public Attribute findFirst(String name); 65 66 /** 67 * Get the next attribute in the list after the given one, with the same 68 * name, if any. 69 * 70 * @param attrib non-null; attribute to start looking after 71 * @return null-ok; next attribute after <code>attrib</code> with the 72 * same name as <code>attrib</code> 73 */ 74 public Attribute findNext(Attribute attrib); 75} 76