1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sf.morph.reflect;
17
18 import java.util.Iterator;
19
20 /**
21 * Exposes information available in 'container-like' structures. A
22 * 'container-like' structure contains a certain number of objects, each of
23 * which has a particular type. Examples of 'container-like' objects include
24 * arrays and java.util.Collections.
25 *
26 * @author Matt Sgarlata
27 * @since Nov 26, 2004
28 */
29 public interface ContainerReflector extends Reflector {
30
31 /**
32 * Returns the type of the elements that are contained in objects of the
33 * given class. For example, if <code>indexedClass</code> represents an
34 * array of <code>int</code>s,<code>Integer.TYPE</code> should be
35 * returned. This method should only be called if
36 * {@link Reflector#isReflectable(Class)}returns <code>true</code>.
37 *
38 * @param clazz
39 * the container's type
40 * @return the type of the elements that are container by the given object
41 * @throws ReflectionException
42 * if <code>container</code> is null or <br>
43 * the type of the elements that are container could not be
44 * determined
45 */
46 public Class getContainedType(Class clazz) throws ReflectionException;
47
48 /**
49 * Exposes an iterator over the contents of the container. Note that in many
50 * cases, an Iterator may only be used once and is then considered invalid.
51 * If you need to loop through the contents of the iterator multiple times,
52 * you will have to copy the contents of the iterator to some other
53 * structure, such as a java.util.List.
54 *
55 * @param container
56 * the container to iterate over
57 * @return an Iterator over the elements in the container
58 * @throws ReflectionException
59 * if <code>container</code> is <code>null</code> or <br>
60 * the Iterator could not be created for some reason
61 */
62 public Iterator getIterator(Object container) throws ReflectionException;
63
64 }