1 32 33 package com.jeantessier.dependencyfinder.cli; 34 35 import java.io.*; 36 37 import com.jeantessier.classreader.*; 38 import com.jeantessier.dependency.*; 39 import com.jeantessier.dependencyfinder.*; 40 import com.jeantessier.metrics.*; 41 42 public class VerboseListener extends VerboseListenerBase implements DependencyListener, MetricsListener { 43 private PrintWriter writer = new NullPrintWriter(); 44 45 public PrintWriter getWriter() { 46 return writer; 47 } 48 49 public void setWriter(OutputStream stream) { 50 setWriter(new PrintWriter(stream)); 51 } 52 53 public void setWriter(Writer writer) { 54 setWriter(new PrintWriter(writer)); 55 } 56 57 public void setWriter(PrintWriter writer) { 58 this.writer = writer; 59 } 60 61 public void close() { 62 getWriter().close(); 63 } 64 65 public void print(String s) { 66 getWriter().println(s); 67 } 68 69 public void beginSession(LoadEvent event) { 70 super.beginSession(event); 71 72 getWriter().print("Searching for classes ..."); 73 getWriter().println(); 74 getWriter().flush(); 75 } 76 77 public void beginGroup(LoadEvent event) { 78 super.beginGroup(event); 79 80 getWriter().print("Searching "); 81 getWriter().print(event.getGroupName()); 82 83 switch (getCurrentGroup().getSize()) { 84 case -1: 85 break; 86 87 case 0: 88 case 1: 89 getWriter().print(" ("); 90 getWriter().print(getCurrentGroup().getSize()); 91 getWriter().print(" file)"); 92 break; 93 94 default: 95 getWriter().print(" ("); 96 getWriter().print(getCurrentGroup().getSize()); 97 getWriter().print(" files)"); 98 break; 99 } 100 101 getWriter().print(" ..."); 102 getWriter().println(); 103 getWriter().flush(); 104 } 105 106 public void endClassfile(LoadEvent event) { 107 super.endClassfile(event); 108 109 getWriter().print("Loading "); 110 getWriter().print(event.getClassfile()); 111 getWriter().print(" ..."); 112 getWriter().println(); 113 getWriter().flush(); 114 } 115 116 public void endFile(LoadEvent event) { 117 super.endFile(event); 118 119 if (!getVisitedFiles().contains(event.getFilename())) { 120 getWriter().print("Skipping "); 121 getWriter().print(event.getFilename()); 122 getWriter().print(" ..."); 123 getWriter().println(); 124 getWriter().flush(); 125 } 126 } 127 128 public void beginSession(DependencyEvent event) { 129 } 131 132 public void beginClass(DependencyEvent event) { 133 getWriter().print("Getting dependencies from "); 134 getWriter().print(event.getClassName()); 135 getWriter().print(" ..."); 136 getWriter().println(); 137 getWriter().flush(); 138 } 139 140 public void dependency(DependencyEvent event) { 141 } 143 144 public void endClass(DependencyEvent event) { 145 } 147 148 public void endSession(DependencyEvent event) { 149 } 151 152 public void beginSession(MetricsEvent event) { 153 } 155 156 public void beginClass(MetricsEvent event) { 157 getWriter().print("Computing metrics for "); 158 getWriter().print(event.getClassfile()); 159 getWriter().print(" ..."); 160 getWriter().println(); 161 getWriter().flush(); 162 } 163 164 public void beginMethod(MetricsEvent event) { 165 } 167 168 public void endMethod(MetricsEvent event) { 169 } 171 172 public void endClass(MetricsEvent event) { 173 } 175 176 public void endSession(MetricsEvent event) { 177 } 179 } 180 | Popular Tags |