net.sf.morph.reflect
Interface ContainerReflector

All Superinterfaces:
net.sf.composite.Component, Reflector
All Known Subinterfaces:
GrowableContainerReflector, IndexedContainerReflector, MutableIndexedContainerReflector
All Known Implementing Classes:
ArrayReflector, BaseContainerReflector, CollectionReflector, EnumerationReflector, IteratorReflector, ListReflector, MapReflector, ObjectReflector, ResetableIteratorWrapperReflector, ResultSetReflector, ServletRequestReflector, SetReflector, SimpleDelegatingReflector, SortedSetReflector, StringTokenizerReflector, StubbornDelegatingReflector

public interface ContainerReflector
extends Reflector

Exposes information available in '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:
Nov 26, 2004
Author:
Matt Sgarlata

Method Summary
 java.lang.Class getContainedType(java.lang.Class clazz)
          Returns the type of the elements that are contained in objects of the given class.
 java.util.Iterator getIterator(java.lang.Object container)
          Exposes an iterator over the contents of the container.
 
Methods inherited from interface net.sf.morph.reflect.Reflector
getReflectableClasses, getWrapper
 

Method Detail

getContainedType

java.lang.Class getContainedType(java.lang.Class clazz)
                                 throws ReflectionException
Returns the type of the elements that are contained in objects of the given class. For example, if indexedClass represents an array of ints,Integer.TYPE should be returned. This method should only be called if Reflector#isReflectable(Class)returns true.

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

getIterator

java.util.Iterator getIterator(java.lang.Object container)
                               throws ReflectionException
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.

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


Copyright © 2004-2008.