1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*
* Copyright 2002,2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.util.depend;
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import org.apache.tools.ant.types.Path;
/**
* A dependency analyzer analyzes dependencies between Java classes to
* determine the minimal set of classes which are required by a set of
* "root" classes. Different implementations of this interface can
* use different strategies and libraries to determine the required set. For
* example, some analyzers will use class files while others might use
* source files. Analyzer specific configuration is catered for through a
* generic configure method
*
*/
public interface DependencyAnalyzer {
/**
* Add a source path to the source path used by this analyzer. The
* elements in the given path contain the source files for the classes
* being analyzed. Not all analyzers will use this information.
*
* @param sourcePath The Path instance specifying the source path
* elements.
*/
void addSourcePath(Path sourcePath);
/**
* Add a classpath to the classpath being used by the analyzer. The
* classpath contains the binary classfiles for the classes being
* analyzed The elements may either be the directories or jar files.Not
* all analyzers will use this information.
*
* @param classpath the Path instance specifying the classpath elements
*/
void addClassPath(Path classpath);
/**
* Add a root class. The root classes are used to drive the
* determination of dependency information. The analyzer will start at
* the root classes and add dependencies from there.
*
* @param classname the name of the class in Java dot notation.
*/
void addRootClass(String classname);
/**
* Get the list of files in the file system upon which the root classes
* depend. The files will be either the classfiles or jar files upon
* which the root classes depend.
*
* @return an enumeration of File instances.
*/
Enumeration getFileDependencies();
/**
* Get the list of classes upon which root classes depend. This is a
* list of Java classnames in dot notation.
*
* @return an enumeration of Strings, each being the name of a Java
* class in dot notation.
*/
Enumeration getClassDependencies();
/**
* Reset the dependency list. This will reset the determined
* dependencies and the also list of root classes.
*/
void reset();
/**
* Configure an aspect of the analyzer. The set of aspects that are
* supported is specific to each analyzer instance.
*
* @param name the name of the aspect being configured
* @param info the configuration information.
*/
void config(String name, Object info);
/**
* Set the closure flag. If this flag is true the analyzer will traverse
* all class relationships until it has collected the entire set of
* direct and indirect dependencies
*
* @param closure true if dependencies should be traversed to determine
* indirect dependencies.
*/
void setClosure(boolean closure);
/**
* Get the file that contains the class definition
*
* @param classname the name of the required class
* @return the file instance, zip or class, containing the
* class or null if the class could not be found.
* @exception IOException if the files in the classpath cannot be read.
*/
File getClassContainer(String classname) throws IOException;
/**
* Get the file that contains the class source.
*
* @param classname the name of the required class
* @return the file instance, zip or java, containing the
* source or null if the source for the class could not be found.
* @exception IOException if the files in the sourcepath cannot be read.
*/
File getSourceContainer(String classname) throws IOException;
}
|