net.sf.morph.wrap
Interface Container

All Superinterfaces:
Wrapper
All Known Subinterfaces:
DecoratedGrowableContainer, DecoratedIndexedContainer, DecoratedMutableIndexedContainer, GrowableContainer, IndexedContainer, MutableIndexedContainer

public interface Container
extends Wrapper

A wrapper around 'container-like' structures. A 'container-like' structure contains a certain number of objects, each of which has a particular type. Examples of 'container-like' objects include arrays and java.util.Collections.

Since:
Jan 16, 2005
Author:
Matt Sgarlata

Method Summary
 java.lang.Class getContainedType()
          Returns the type of the elements that are contained in this container.
 java.util.Iterator getIterator()
          Exposes an iterator over the contents of the container.
 
Methods inherited from interface net.sf.morph.wrap.Wrapper
getWrappedObject
 

Method Detail

getContainedType

java.lang.Class getContainedType()
                                 throws WrapperException
Returns the type of the elements that are contained in this container. For example, if this container wraps an array of ints, Integer.TYPE should be returned.

Parameters:
clazz - the container's type
Returns:
the type of the elements that are container by the given object
Throws:
WrapperException - if container is null or
the type of the elements that are container could not be determined

getIterator

java.util.Iterator getIterator()
                               throws WrapperException
Exposes an iterator over the contents of the container. Note that in many cases, an Iterator may only be used once and is then considered invalid. If you need to loop through the contents of the iterator multiple times, you will have to copy the contents of the iterator to some other structure, such as a java.util.List.

Returns:
an Iterator over the elements in the container
Throws:
WrapperException - if container is null or
the Iterator could not be created for some reason


Copyright © 2004-2008.