/* * ALMA - Atacama Large Millimiter Array * (c) European Southern Observatory, 2002 * Copyright by ESO (in the framework of the ALMA collaboration), * All rights reserved * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ package alma.acs.entityutil; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Enumeration; import alma.acs.util.StopWatch; import alma.entities.commonentity.EntityRefT; /** * Takes an entity object (binding class) and traverses the tree to find * references ({@link EntityRefT} nodes) to other entity objects. *
* Currently specific to XML binding classes produced by the Castor framework; * should be not too hard though to adapt to others (mainly enumeration stuff) *
* Assumes that it's a tree, not a graph * (therefore no checks whether a node has been visited already). * On a graph this could lead to an infinite loop. *
* Possible optimization would be to compute on demand a list of Class objects for
* which we know that they can't have EntityRefT children, and to
* subsequently stop the recursion there.
*
* @author hsommer Apr 24, 2003 2:05:43 PM
*/
public class EntityRefFinder
{
private boolean m_debug;
/**
*
*/
public EntityRefFinder()
{
this(false);
}
public EntityRefFinder(boolean debug)
{
super();
m_debug = debug;
}
public EntityRefT[] findEntityReferences(Object rootEntityObject)
throws EntityException
{
ArrayList