Categories:
Audio (13)
Biotech (29)
Bytecode (35)
Database (77)
Framework (7)
Game (7)
General (512)
Graphics (53)
I/O (32)
IDE (2)
JAR Tools (86)
JavaBeans (16)
JDBC (89)
JDK (337)
JSP (20)
Logging (103)
Mail (54)
Messaging (8)
Network (71)
PDF (94)
Report (7)
Scripting (83)
Security (32)
Server (119)
Servlet (17)
SOAP (24)
Testing (50)
Web (19)
XML (301)
Other Resources:
JarAnalyzer Source Code Files
Apache Ant Source Code Files are inside the JarAnalyzer source package
like JarAnalyzer-src-1.2.zip.
Unzip the source package and go to the "src" sub-directory,
you will see source code files.
Here is the list of Java source code files of the JarAnalyzer 1.2 in \Users\fyicenter\JarAnalyzer\src:
✍: FYIcenter.com
⏎ com/kirkk/analyzer/textui/XMLUISummary.java
package com.kirkk.analyzer.textui; import java.io.*; import java.util.*; import com.kirkk.analyzer.framework.*; import com.kirkk.analyzer.*; /* * Modified version of XMLUISummary * http://www.kirkk.com/wiki/wiki.php/Main/JarAnalyzer * * This class takes the input directory and output file * from the command line or from System.in. It is also * usable directly from Java and can be called from * an ant task */ public class XMLUISummary implements Summary { private PrintWriter writer; public static void main(String args[]) throws Exception { new XMLUISummary().instanceMain(args); } public void instanceMain(String args[]) throws Exception { File scrDir = (args.length > 0) ? new File(args[0]) : null; File destFile = (args.length > 1) ? new File(args[1]) : null; if(scrDir == null) { System.out.print("Please enter input directory name: "); scrDir = getFile(); } if(destFile == null) { System.out.print("Please enter output file name: "); destFile = getFile(); } createSummary(scrDir, destFile); } public void createSummary(File srcDir, File destFile) throws Exception { Analyzer analyzer = new Analyzer(); Jar jarBundle[] = analyzer.analyze(srcDir); outputAll(jarBundle, destFile); } public void createSummary(File srcDir, File destFile, String packageFilter, String jarFilter) throws Exception { Analyzer analyzer = new Analyzer(); Configuration.initialize(packageFilter, jarFilter); Jar jarBundle[] = analyzer.analyze(srcDir); outputAll(jarBundle, destFile); } private File getFile() throws IOException { try { InputStreamReader streamReader = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(streamReader); String fileName = reader.readLine(); File file = new File(fileName); return file; } catch (IOException e) { throw e; } } private void outputAll(Jar[] jarBundle, File file) { try { FileWriter fileWriter = new FileWriter(file); writer = new PrintWriter(fileWriter); } catch (IOException e) { System.out.println("IOException - Redirecting to System.out"); System.out.println(e); OutputStreamWriter outputWriter = new OutputStreamWriter(System.out); writer = new PrintWriter(outputWriter); } this.printHeader(); this.output(jarBundle); this.printFooter(); writer.flush(); writer.close(); } private void printHeader() { writer.println("<?xml version=\"1.0\"?>"); writer.println("<JarAnalyzer>"); } private void printFooter() { writer.println("</JarAnalyzer>"); } private void output(Jar[] jarBundles) { writer.println(tab()+"<Jars>");writer.println(); for (int i = 0; i < jarBundles.length; i++) { String jar = jarBundles[i].getJarFileName().substring(jarBundles[i].getJarFileName().lastIndexOf("\\") + 1, jarBundles[i].getJarFileName().length()); writer.println(tab(2)+"<Jar name=\"" + jar + "\">"); writer.println(tab(3)+"<Summary>"); this.statistics(jarBundles[i]);writer.println(); this.metrics(jarBundles[i].calculateMetrics());writer.println(); this.jarPackages(jarBundles[i]);writer.println(); this.outgoingDependencies(jarBundles[i]); this.incomingDependencies(jarBundles[i]); this.cycles(jarBundles[i]); this.unresolveableDependencies(jarBundles[i]); writer.println(tab(3)+"</Summary>");writer.println(); writer.println(tab(2)+"</Jar>");writer.println(); } writer.println(tab()+"</Jars>"); } private void statistics(Jar jarBundle) { writer.println(tab(4)+"<Statistics>"); writer.println(tab(5)+"<ClassCount>" + jarBundle.getClassCount() + "</ClassCount>"); writer.println(tab(5)+"<AbstractClassCount>" + jarBundle.getAbstractClassCount() + "</AbstractClassCount>"); writer.println(tab(5)+"<PackageCount>" + jarBundle.getPackageCount() + "</PackageCount>"); //writer.println(tab(5)+"<Level>" + jarBundle.getLevel() + "</Level>"); writer.println(tab(4)+"</Statistics>"); } private void metrics(JarMetrics jarMetrics) { writer.println(tab(4)+"<Metrics>"); writer.println(tab(5)+"<Abstractness>" + jarMetrics.calculateAbstractness().toString() + "</Abstractness>"); writer.println(tab(5)+"<Efferent>" + jarMetrics.calculateEfferentCoupling() + "</Efferent>"); writer.println(tab(5)+"<Afferent>" + jarMetrics.calculateAfferentCoupling() + "</Afferent>"); writer.println(tab(5)+"<Instability>" + jarMetrics.calculateInstability().toString() + "</Instability>"); writer.println(tab(5)+"<Distance>" + jarMetrics.calculateDistance().toString() + "</Distance>"); writer.println(tab(4)+"</Metrics>"); } private void cycles(Jar jarBundle) { writer.println(tab(4) + "<Cycles>"); if (jarBundle.hasCycles()) { Iterator cyclicJars = jarBundle.getCyclicJars().iterator(); while (cyclicJars.hasNext()) { Jar cyclicBundle = (Jar) cyclicJars.next(); String jarName = cyclicBundle.getJarFileName(); writer.println(tab(5) + "<Cycle>" + jarName + "</Cycle>"); } } writer.println(tab(4) + "</Cycles>");writer.println(); } private void outgoingDependencies(Jar jarBundle) { writer.println(tab(4)+"<OutgoingDependencies>"); Iterator jarDependencies = jarBundle.getOutgoingDependencies().iterator(); while (jarDependencies.hasNext()) { Jar dependentBundle = (Jar) jarDependencies.next(); //String jar2 = dependentBundle.getJarFileName().substring(dependentBundle.getJarFileName().lastIndexOf("\\") + 1, // dependentBundle.getJarFileName().length()); String jar2= dependentBundle.getJarFileName(); writer.println(tab(5)+"<Jar>"+jar2+"</Jar>"); } writer.println(tab(4)+"</OutgoingDependencies>");writer.println(); } private void incomingDependencies(Jar jarBundle) { writer.println(tab(4)+"<IncomingDependencies>"); Iterator jarDependencies = jarBundle.getIncomingDependencies().iterator(); while (jarDependencies.hasNext()) { Jar dependentBundle = (Jar) jarDependencies.next(); //String jar2 = dependentBundle.getJarFileName().substring(dependentBundle.getJarFileName().lastIndexOf("\\") + 1, // dependentBundle.getJarFileName().length()); String jar2= dependentBundle.getJarFileName(); writer.println(tab(5)+"<Jar>"+jar2+"</Jar>"); } writer.println(tab(4)+"</IncomingDependencies>");writer.println(); } private void externalDependencies(Jar jarBundle) { Iterator allPackages = jarBundle.getAllExternallyReferencedPackages().iterator(); while (allPackages.hasNext()) { String javaPackage = (String) allPackages.next(); writer.println(tab(5)+"<Package>"+javaPackage+"</Package>"); } } private void unresolveableDependencies(Jar jarBundle) { writer.println(tab(4)+"<UnresolvedDependencies>"); Iterator unresolvedPackages = jarBundle.getAllUnidentifiableExternallyReferencedPackages().iterator(); while (unresolvedPackages.hasNext()) { String packageName = (String) unresolvedPackages.next(); writer.println(tab(5)+"<Package>"+packageName+"</Package>"); } writer.println(tab(4)+"</UnresolvedDependencies>"); } private void jarPackages(Jar jarBundle) { writer.println(tab(4)+"<Packages>"); Iterator allPackages = jarBundle.getAllContainedPackages().iterator(); while (allPackages.hasNext()) { JarPackage javaPackage = (JarPackage) allPackages.next(); writer.println(tab(5)+"<Package>" + javaPackage.getLongName() + "</Package>"); } writer.println(tab(4)+"</Packages>"); } private String tab() { return " "; } private String tab(int i) { String tab = tab(); for (int j = 0; j < i - 1; j++) { tab = tab + tab(); } return tab; } }
⏎ com/kirkk/analyzer/textui/XMLUISummary.java
Â
Â
⇒ jarscan - JAR File Scanner
⇠Download JarAnalyzer Source Package
⇑ JarAnalyzer by Kirk Knoernschild
⇑⇑ Java/JAR Tools
2021-07-01, 2487👍, 0💬
Popular Posts:
Apache Log4j Core Implementation provides the functional components of the logging system. Users are...
What Is activation.jar? I heard it's related to JAF (JavaBeans Activation Framework) 1.1? The if you...
The JGoodies Forms framework helps you lay out and implement elegant Swing panels consistently and q...
Saxon is an open source product available under the Mozilla Public License. It provides implementati...
How to download and install ojdbc11.jar for Oracle 21c? ojdbc11.jar for Oracle 21c is a Java JDBC Dr...