View Javadoc

1   /*
2    * Copyright 2004-2005 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * 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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package net.sf.morph.wrap;
17  
18  
19  /**
20   * A wrapper for 'container-like' structures that have a logical ordering which
21   * can be used to retrieve elements at a specific index within the structure.
22   * Lists, SortedSets, and arrays are good examples of indexed structures. Note
23   * that some indexed structures will have O(1) methods for retrieving objects at
24   * a given index (ArrayList, TreeSet, array) and others will have O(n) methods
25   * for retrieving objects at a given index (LinkedList).
26   * 
27   * @author Matt Sgarlata
28   * @since Jan 16, 2005
29   */
30  public interface IndexedContainer extends Container, Sizable {
31  
32  	/**
33  	 * Gets the element at the specified index. Valid indexes range between 0
34  	 * and one less than the container object's size, inclusive.
35  	 * 
36  	 * @param index
37  	 *            a number indiciating which element should be retrieved
38  	 * @return the object at the specified index
39  	 * @throws WrapperException
40  	 *             if <code>index</code> is not a valid index for this
41  	 *             container object or <br>
42  	 *             the object at the specified index could not be retrieved for
43  	 *             some reason
44  	 */
45  	public Object get(Object container, int index) throws WrapperException;
46  
47  }