1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.morph.reflect;
17
18 /**
19 * A reflector for 'container-like' structures that have a logical ordering
20 * which can be used to retrieve elements at a specific index within the
21 * structure. Lists, SortedSets, and arrays are good examples of indexed
22 * structures. Note that some indexed structures will have O(1) methods for
23 * retrieving objects at a given index (ArrayList, TreeSet, array) and others
24 * will have O(n) methods for retrieving objects at a given index (LinkedList).
25 *
26 * @author Matt Sgarlata
27 * @since Nov 14, 2004
28 */
29 public interface IndexedContainerReflector extends ContainerReflector, SizableReflector {
30
31 /**
32 * Gets the element at the specified index. Valid indexes range between 0
33 * and one less than the container object's size, inclusive.
34 *
35 * @param container
36 * the container object
37 * @param index
38 * a number indiciating which element should be retrieved
39 * @return the object at the specified index
40 * @throws ReflectionException
41 * if <code>container</code> is null or <br>
42 * <code>index</code> is not a valid index for the given
43 * container object or <br>
44 * the object at the specified index could not be retrieved for
45 * some reason
46 */
47 public Object get(Object container, int index) throws ReflectionException;
48
49 }