projects
/
javainspect.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated pattern name to glob to be more specific. Updated copyright.
[javainspect.git]
/
src
/
main
/
java
/
eu
/
svjatoslav
/
inspector
/
java
/
structure
/
ClassGraph.java
diff --git
a/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
b/src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
index
c6b6cbf
..
51fa04a
100755
(executable)
--- a/
src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
+++ b/
src/main/java/eu/svjatoslav/inspector/java/structure/ClassGraph.java
@@
-1,6
+1,6
@@
/*
* JavaInspect - Utility to visualize java software
/*
* JavaInspect - Utility to visualize java software
- * Copyright (C) 2013-201
5
, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright (C) 2013-201
7
, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 3 of the GNU Lesser General Public License
@@
-23,6
+23,7
@@
import java.util.List;
import java.util.Map;
import static eu.svjatoslav.inspector.java.methods.JavaFile.UTF_8;
import java.util.Map;
import static eu.svjatoslav.inspector.java.methods.JavaFile.UTF_8;
+import static java.io.File.separator;
public class ClassGraph {
public class ClassGraph {
@@
-31,15
+32,17
@@
public class ClassGraph {
*/
private final Map<String, ClassDescriptor> fullyQualifiedNameToClassMap = new HashMap<String, ClassDescriptor>();
*/
private final Map<String, ClassDescriptor> fullyQualifiedNameToClassMap = new HashMap<String, ClassDescriptor>();
- private final List<String> blacklistClass
Pattern
s = new ArrayList<String>();
+ private final List<String> blacklistClass
Glob
s = new ArrayList<String>();
- private final List<String> whitelistClass
Patterns = new ArrayList<String
>();
+ private final List<String> whitelistClass
Globs = new ArrayList<
>();
- private String targetDirectory = CommonPathResolver.getDesktopDirectory()
- .getAbsolutePath() +
"/"
;
+ private String targetDirectory
Path
= CommonPathResolver.getDesktopDirectory()
+ .getAbsolutePath() +
separator
;
private boolean keepDotFile;
private boolean keepDotFile;
+ TargetImageType targetImageType = TargetImageType.SVG;
+
public ClassGraph() {
}
public ClassGraph() {
}
@@
-80,8
+83,12
@@
public class ClassGraph {
}
}
}
}
- public void blacklistClassPattern(final String pattern) {
- blacklistClassPatterns.add(pattern);
+ public void blacklistClassGlob(final String glob) {
+ blacklistClassGlobs.add(glob);
+ }
+
+ public void setTargetImageType(TargetImageType targetImageType) {
+ this.targetImageType = targetImageType;
}
/**
}
/**
@@
-92,10
+99,8
@@
public class ClassGraph {
public void generateGraph(final String resultFileName) {
public void generateGraph(final String resultFileName) {
- final String dotFilePath = targetDirectory + resultFileName + ".dot";
- final String imageFilePath = targetDirectory + resultFileName + ".svg";
-
- System.out.println("Dot file path:" + dotFilePath);
+ final String dotFilePath = targetDirectoryPath + resultFileName + ".dot";
+ final String imageFilePath = targetDirectoryPath + resultFileName + "." + targetImageType.fileExtension;
try {
// write DOT file to disk
try {
// write DOT file to disk
@@
-106,16
+111,18
@@
public class ClassGraph {
// execute GraphViz to visualize graph
try {
Runtime.getRuntime()
// execute GraphViz to visualize graph
try {
Runtime.getRuntime()
- .exec(new String[]{"dot", "-T
svg"
, dotFilePath, "-o",
+ .exec(new String[]{"dot", "-T
" + targetImageType.fileExtension
, dotFilePath, "-o",
imageFilePath}).waitFor();
} catch (final InterruptedException ignored) {
}
if (!keepDotFile)
// delete dot file
imageFilePath}).waitFor();
} catch (final InterruptedException ignored) {
}
if (!keepDotFile)
// delete dot file
- if (!new File(dotFilePath).delete()) throw new RuntimeException("Cannot delete file: " + dotFilePath);
+ if (!new File(dotFilePath).delete())
+ throw new RuntimeException("Cannot delete file: " + dotFilePath);
+
} catch (final IOException e) {
} catch (final IOException e) {
-
System.err.println(
e);
+
throw new RuntimeException("Unable to generate graph: " + e.getMessage(),
e);
}
}
}
}
@@
-176,12
+183,12
@@
public class ClassGraph {
}
protected boolean isClassShown(final String className) {
}
protected boolean isClassShown(final String className) {
- for (final String pattern : blacklistClass
Pattern
s)
+ for (final String pattern : blacklistClass
Glob
s)
if (WildCardMatcher.match(className, pattern))
return false;
if (WildCardMatcher.match(className, pattern))
return false;
- if (!whitelistClass
Pattern
s.isEmpty()) {
- for (final String pattern : whitelistClass
Pattern
s)
+ if (!whitelistClass
Glob
s.isEmpty()) {
+ for (final String pattern : whitelistClass
Glob
s)
if (WildCardMatcher.match(className, pattern))
return true;
return false;
if (WildCardMatcher.match(className, pattern))
return true;
return false;
@@
-196,18
+203,17
@@
public class ClassGraph {
return this;
}
return this;
}
- public ClassGraph setTargetDirectory(String directoryPath) {
- if (!directoryPath.endsWith(
"/"
))
- directoryPath +=
"/"
;
+ public ClassGraph setTargetDirectory
Path
(String directoryPath) {
+ if (!directoryPath.endsWith(
separator
))
+ directoryPath +=
separator
;
- targetDirectory = directoryPath;
+ targetDirectory
Path
= directoryPath;
return this;
}
return this;
}
- public ClassGraph whitelistClassPattern(final String pattern) {
- whitelistClassPatterns.add(pattern);
-
+ public ClassGraph whitelistClassGlob(final String glob) {
+ whitelistClassGlobs.add(glob);
return this;
}
return this;
}