|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jlayercheck.util.XMLConfiguration
public class XMLConfiguration
Contains a configuration that describes the architecture of the project. It consists of modules that contain packages. Modules can use other modules, but only in a strict directional order, no dependency loops.
An important function is getModelTree(DependencyVisitor)
that
creates a tree of all modules, packages and classes and their dependencies.
Field Summary | |
---|---|
protected List<ClassSource> |
classSources
Contains the sources defined in the configuration file. |
protected Set<String> |
entryClasses
Contains classnames of classes that are used as program entries for the orphaned classes search. |
protected Set<String> |
excludeList
Contains the packages that are excluded from the analysis (like java.**). |
protected static Logger |
logger
|
protected Map<String,Set<String>> |
moduleDependencies
Contains the dependencies that belong to one module. |
protected Map<String,Set<String>> |
modulePackages
Contains the packages that belong to one module. |
Constructor Summary | |
---|---|
XMLConfiguration()
|
Method Summary | |
---|---|
void |
addClassSource(ClassSource source)
Adds a new ClassSource. |
protected void |
addDependencyToModule(String moduleName,
String dependencyName)
|
void |
addEntryClass(String entryClass)
Adds a new entry class. |
void |
addModuleDependency(String moduleName,
TreeSet<String> name)
Adds dependencies from a module to other modules. |
protected void |
addPackageToExcludeList(String packageName)
|
protected void |
addPackageToModule(String moduleName,
String packageName)
|
protected String |
convertToRegularExpression(String wildcardstring)
Used internally to convert a string from the wildcard format used in the configuration file into a regular expression. |
TreeNode |
createIncomingModel(ClassNode node,
ModelTree treemodel,
DependenciesTreeModel modelToUpdate)
Creates a dependency tree model for the given node of the given ModelTree. |
TreeNode |
createModel(ClassNode node,
ModelTree treemodel,
DependenciesTreeModel modelToUpdate)
Creates a dependency tree model for the given node of the given ModelTree. |
void |
cumulateDependencyViolations(ModelTree mt)
Recalculates the violations state of all nodes of the tree that contain children (e.g. |
Map<String,URL> |
getAllClassSources()
Returns a map containing all java class names and an URL that points to the source file. |
List<ClassSource> |
getClassSources()
Returns the list of sources for the class and java files. |
Set<String> |
getEntryClasses()
Returns a Set of classes that are named as entry classes in the configuration file. |
Set<String> |
getExcludeList()
Returns all package entries that are specified to exclude in the configuration file. |
String |
getMatchingModule(String classname)
Returns the matching module for the given classname or null. |
ModelTree |
getModelTree(DependencyVisitor dv)
Builds a model that contains all dependency information that was retrieved from the class files. |
Map<String,Set<String>> |
getModuleDependencies()
Returns the dependencies of all modules. |
Map<String,Set<String>> |
getModulePackages()
Returns the packages contained in every module. |
Set<String> |
getOrphanedClasses(Map<String,Map<String,Set<Integer>>> dependencies)
Calculates the orphaned classes based on the entry points of the configuration file and the dependency data from the DependencyVisitor. |
Map<String,String> |
getPackageModules()
Returns a map that contains the mapping from packages to modules. |
Map<String,Map<String,ClassDependency>> |
getUnallowedDependencies(Map<String,Map<String,Set<Integer>>> dependencies)
Returns a map containing the dependencies (from class, to class) that are not allowed by the rules. |
Set<String> |
getUnspecifiedPackages(Map<String,Map<String,Set<Integer>>> dependencies)
Returns a list of packages that are not assigned to a module in the given configuration. |
protected Set<String> |
getUnvisitedDependendClasses(Set<String> visitedClasses,
Map<String,Map<String,Set<Integer>>> dependencies,
Map<String,URL> allClassSources)
Returns all classnames that are directly referenced by the visited classes but not yet contained. |
boolean |
isExcluded(String classname)
Returns true if the given class is excluded from the analysis. |
boolean |
isUnallowedDependency(ModuleNode sourceModule,
ModuleNode destModule)
Returns true if the module sourceModule may access destModule. |
boolean |
isUnallowedDependency(String fromClass,
String toClass)
Returns true if the dependency from fromClass to toClass is not allowed, otherwise false. |
boolean |
isUnallowedModuleDependency(String fromModule,
String toModule)
Returns true if the dependency from fromModule to toModule is not allowed, otherwise false. |
void |
updateModelTree(ModelTree mt,
File classFile)
Updates the given modeltree by replacing all information of the given classFile with new information. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static Logger logger
protected Map<String,Set<String>> modulePackages
protected Map<String,Set<String>> moduleDependencies
protected List<ClassSource> classSources
protected Set<String> excludeList
protected Set<String> entryClasses
Constructor Detail |
---|
public XMLConfiguration()
Method Detail |
---|
protected void addPackageToExcludeList(String packageName)
protected void addDependencyToModule(String moduleName, String dependencyName)
protected void addPackageToModule(String moduleName, String packageName)
public Map<String,Set<String>> getModuleDependencies()
public Map<String,Set<String>> getModulePackages()
public String getMatchingModule(String classname) throws OverlappingModulesDefinitionException
Returns the matching module for the given classname or null. If more than one module matches, an exception is thrown, because it is a configuration error.
The input must be a classname, not a package name. The last part is expected to be the name of the class.
OverlappingModulesDefinitionException
public Map<String,String> getPackageModules()
public List<ClassSource> getClassSources()
public Map<String,URL> getAllClassSources()
public Set<String> getExcludeList()
public boolean isExcluded(String classname)
dependency
-
protected String convertToRegularExpression(String wildcardstring)
wildcardstring
-
public Set<String> getEntryClasses()
public Set<String> getOrphanedClasses(Map<String,Map<String,Set<Integer>>> dependencies) throws OrphanedSearchException
dv
- the dependency data to use
OrphanedSearchException
protected Set<String> getUnvisitedDependendClasses(Set<String> visitedClasses, Map<String,Map<String,Set<Integer>>> dependencies, Map<String,URL> allClassSources) throws OrphanedSearchException
visitedClasses
- dv
- the dependencies to useallClassSources
- a map containing all classnames for which java source files are available
OrphanedSearchException
public Map<String,Map<String,ClassDependency>> getUnallowedDependencies(Map<String,Map<String,Set<Integer>>> dependencies) throws OverlappingModulesDefinitionException
xcp
- the configuration to use
OverlappingModulesDefinitionException
public boolean isUnallowedDependency(String fromClass, String toClass) throws OverlappingModulesDefinitionException
fromClass
- toClass
-
OverlappingModulesDefinitionException
public boolean isUnallowedModuleDependency(String fromModule, String toModule)
fromModule
- toModule
-
public Set<String> getUnspecifiedPackages(Map<String,Map<String,Set<Integer>>> dependencies) throws OverlappingModulesDefinitionException
xcp
-
OverlappingModulesDefinitionException
public ModelTree getModelTree(DependencyVisitor dv) throws OverlappingModulesDefinitionException
dv
-
OverlappingModulesDefinitionException
public void updateModelTree(ModelTree mt, File classFile) throws OverlappingModulesDefinitionException, FileNotFoundException, IOException
mt
- dv
- classFile
-
OverlappingModulesDefinitionException
IOException
FileNotFoundException
public boolean isUnallowedDependency(ModuleNode sourceModule, ModuleNode destModule)
sourceModule
- destModule
-
public void cumulateDependencyViolations(ModelTree mt)
ModelTree
- the tree that should be recalculatedpublic TreeNode createModel(ClassNode node, ModelTree treemodel, DependenciesTreeModel modelToUpdate)
node
- treemodel
- xmlconf
- the configuration used to determine which dependencies are allowed
public TreeNode createIncomingModel(ClassNode node, ModelTree treemodel, DependenciesTreeModel modelToUpdate)
node
- treemodel
- xmlconf
- the configuration used to determine which dependencies are allowed
public void addEntryClass(String entryClass)
entryClass
- public void addModuleDependency(String moduleName, TreeSet<String> name)
moduleName
- name
- public void addClassSource(ClassSource source)
source
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |