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