net.sf.fikin.pojostate.select
Class MethodsIterator

java.lang.Object
  extended by net.sf.fikin.pojostate.select.MethodsIterator

public class MethodsIterator
extends java.lang.Object

This class is used to build iterators over class and interface definitions.

It purpose is to allow for deep-hierarchy traversal over method's definition by discovering all interfaces defining it and all classes implementing it.

Traversal over method's overloading is configurable.

Traversal over interfaces or classes only is configurable.

Order of interfaces or classes first is configurable. created on Jul 19, 2005

Since:
Version:
$Revision: 1.2 $
Author:
fiykov

Field Summary
protected static java.lang.Class[] voidParams
           
 
Constructor Summary
MethodsIterator()
           
 
Method Summary
 java.util.Enumeration getClassIterator(java.lang.Class objectOwnClazz, java.lang.reflect.Method method, java.lang.ClassLoader loader)
          create an enumeration over all classes which implement or define the given method.
 boolean isIncludeClasses()
          are interfaces only to be iterated over (when set to false) or classes are to be included too by default it is true
 boolean isIncludeInterfaces()
          are only classes to be iterated over (when set to false) or interfaces to be included too by default it is true
 boolean isIncludeObjectClass()
          is the object's own class to be included in the iteration.
 boolean isInclueSuperDefinitions()
          is iteration to include also super definitions of overloaded methods by default true
 boolean isInterfacesFirst()
          are interfaces first to be iterated by default true
 void setIncludeClasses(boolean includeClasses)
          set to false if only interfaces are to be iterated over by default it is true
 void setIncludeInterfaces(boolean includeInterfaces)
          set to false if only classes are to be iterated over i.e. no interfaces.
 void setIncludeObjectClass(boolean includeObjectClass)
          set this to true if object's own class is to be iterated over too.
 void setInclueSuperDefinitions(boolean inclueSuperDefinitions)
          set to true if iteration to include also super definitions of overloaded methods by default true
 void setInterfacesFirst(boolean interfacesFirst)
          set to true is interfaces are to be iterated over first.
protected  boolean traverseClasses(java.util.Vector res, java.lang.Class clazz, java.lang.reflect.Method method)
          traverse over class hierarchy and add what is found to the vector method overloading defined by isInclueSuperDefinitions() is taken into account
protected  boolean traverseInterfaces(java.util.Vector res, java.lang.Class clazz, java.lang.reflect.Method method)
          traverse over interfaces hierarchy and add what is found to the vector method overloading defined by isInclueSuperDefinitions() is taken into account
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

voidParams

protected static final java.lang.Class[] voidParams
Constructor Detail

MethodsIterator

public MethodsIterator()
Method Detail

setInterfacesFirst

public void setInterfacesFirst(boolean interfacesFirst)
set to true is interfaces are to be iterated over first. if set to false first iterated over will be classes and then interfaces by default it is true.

Parameters:
interfacesFirst - The interfacesFirst to set.

isInterfacesFirst

public boolean isInterfacesFirst()
are interfaces first to be iterated by default true

Returns:
Returns the interfacesFirst flag.

setIncludeObjectClass

public void setIncludeObjectClass(boolean includeObjectClass)
set this to true if object's own class is to be iterated over too. this may make sense when the method under question is in fact inherited from the super class. by default true.

Parameters:
includeObjectClass - The includeObjectClass to set.

isIncludeObjectClass

public boolean isIncludeObjectClass()
is the object's own class to be included in the iteration. by default true. this make sense when the object's class inherits the method from its super class rather than implementing it.

Returns:
Returns the includeObjectClass.

setInclueSuperDefinitions

public void setInclueSuperDefinitions(boolean inclueSuperDefinitions)
set to true if iteration to include also super definitions of overloaded methods by default true

Parameters:
inclueSuperDefinitions - The inclueSuperDefinitions to set.

isInclueSuperDefinitions

public boolean isInclueSuperDefinitions()
is iteration to include also super definitions of overloaded methods by default true

Returns:
Returns the inclueSuperDefinitions.

setIncludeClasses

public void setIncludeClasses(boolean includeClasses)
set to false if only interfaces are to be iterated over by default it is true

Parameters:
includeClasses - The includeClasses to set.

isIncludeClasses

public boolean isIncludeClasses()
are interfaces only to be iterated over (when set to false) or classes are to be included too by default it is true

Returns:
Returns the includeClasses.

setIncludeInterfaces

public void setIncludeInterfaces(boolean includeInterfaces)
set to false if only classes are to be iterated over i.e. no interfaces. by default it is true

Parameters:
includeInterfaces - The includeInterfaces to set.

isIncludeInterfaces

public boolean isIncludeInterfaces()
are only classes to be iterated over (when set to false) or interfaces to be included too by default it is true

Returns:
Returns the includeInterfaces.

getClassIterator

public java.util.Enumeration getClassIterator(java.lang.Class objectOwnClazz,
                                              java.lang.reflect.Method method,
                                              java.lang.ClassLoader loader)
                                       throws java.lang.SecurityException
create an enumeration over all classes which implement or define the given method. iteration will include interfaces defining this method as well as all classes implementing it. isInterfacesFirst() defines if interfaces are to be first in the list or last. isIncludeObjectClass() defines if object's own class will be included too if the class itself does not implement the method.

Parameters:
objectOwnClazz - is object's own class
method - is the method in particular to be examined
loader - to be used
Returns:
enumeration over all classes implementing or dining this method
Throws:
java.lang.SecurityException

traverseInterfaces

protected boolean traverseInterfaces(java.util.Vector res,
                                     java.lang.Class clazz,
                                     java.lang.reflect.Method method)
                              throws java.lang.SecurityException
traverse over interfaces hierarchy and add what is found to the vector method overloading defined by isInclueSuperDefinitions() is taken into account

Parameters:
res -
clazz -
method -
Throws:
java.lang.SecurityException

traverseClasses

protected boolean traverseClasses(java.util.Vector res,
                                  java.lang.Class clazz,
                                  java.lang.reflect.Method method)
                           throws java.lang.SecurityException
traverse over class hierarchy and add what is found to the vector method overloading defined by isInclueSuperDefinitions() is taken into account

Parameters:
res -
clazz -
method -
Throws:
java.lang.SecurityException


Copyright © 2005 Nikolay Fiykov. All Rights Reserved.