001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.tools.ant.util.depend;
019:
020: import java.io.File;
021: import java.io.IOException;
022: import java.util.Enumeration;
023: import org.apache.tools.ant.types.Path;
024:
025: /**
026: * A dependency analyzer analyzes dependencies between Java classes to
027: * determine the minimal set of classes which are required by a set of
028: * "root" classes. Different implementations of this interface can
029: * use different strategies and libraries to determine the required set. For
030: * example, some analyzers will use class files while others might use
031: * source files. Analyzer specific configuration is catered for through a
032: * generic configure method
033: *
034: */
035: public interface DependencyAnalyzer {
036: /**
037: * Add a source path to the source path used by this analyzer. The
038: * elements in the given path contain the source files for the classes
039: * being analyzed. Not all analyzers will use this information.
040: *
041: * @param sourcePath The Path instance specifying the source path
042: * elements.
043: */
044: void addSourcePath(Path sourcePath);
045:
046: /**
047: * Add a classpath to the classpath being used by the analyzer. The
048: * classpath contains the binary classfiles for the classes being
049: * analyzed The elements may either be the directories or jar files.Not
050: * all analyzers will use this information.
051: *
052: * @param classpath the Path instance specifying the classpath elements
053: */
054: void addClassPath(Path classpath);
055:
056: /**
057: * Add a root class. The root classes are used to drive the
058: * determination of dependency information. The analyzer will start at
059: * the root classes and add dependencies from there.
060: *
061: * @param classname the name of the class in Java dot notation.
062: */
063: void addRootClass(String classname);
064:
065: /**
066: * Get the list of files in the file system upon which the root classes
067: * depend. The files will be either the classfiles or jar files upon
068: * which the root classes depend.
069: *
070: * @return an enumeration of File instances.
071: */
072: Enumeration getFileDependencies();
073:
074: /**
075: * Get the list of classes upon which root classes depend. This is a
076: * list of Java classnames in dot notation.
077: *
078: * @return an enumeration of Strings, each being the name of a Java
079: * class in dot notation.
080: */
081: Enumeration getClassDependencies();
082:
083: /**
084: * Reset the dependency list. This will reset the determined
085: * dependencies and the also list of root classes.
086: */
087: void reset();
088:
089: /**
090: * Configure an aspect of the analyzer. The set of aspects that are
091: * supported is specific to each analyzer instance.
092: *
093: * @param name the name of the aspect being configured
094: * @param info the configuration information.
095: */
096: void config(String name, Object info);
097:
098: /**
099: * Set the closure flag. If this flag is true the analyzer will traverse
100: * all class relationships until it has collected the entire set of
101: * direct and indirect dependencies
102: *
103: * @param closure true if dependencies should be traversed to determine
104: * indirect dependencies.
105: */
106: void setClosure(boolean closure);
107:
108: /**
109: * Get the file that contains the class definition
110: *
111: * @param classname the name of the required class
112: * @return the file instance, zip or class, containing the
113: * class or null if the class could not be found.
114: * @exception IOException if the files in the classpath cannot be read.
115: */
116: File getClassContainer(String classname) throws IOException;
117:
118: /**
119: * Get the file that contains the class source.
120: *
121: * @param classname the name of the required class
122: * @return the file instance, zip or java, containing the
123: * source or null if the source for the class could not be found.
124: * @exception IOException if the files in the sourcepath cannot be read.
125: */
126: File getSourceContainer(String classname) throws IOException;
127: }
|