1 32 33 package com.jeantessier.dependencyfinder; 34 35 import com.jeantessier.classreader.*; 36 37 public class VerboseListenerBase extends LoadListenerBase { 38 private String ratioIndicator = ""; 39 40 protected String getRatioIndicator() { 41 return ratioIndicator; 42 } 43 44 private void setRatioIndicator(String ratioIndicator) { 45 this.ratioIndicator = ratioIndicator; 46 } 47 48 private int computeCurrentRatio() { 49 return getCurrentGroup().getCount() * 100 / getCurrentGroup().getSize(); 50 } 51 52 public void beginFile(LoadEvent event) { 53 int previousRatio = computeCurrentRatio(); 54 55 super.beginFile(event); 56 57 if (getCurrentGroup().getSize() > 0) { 58 int newRatio = computeCurrentRatio(); 59 60 if (previousRatio != newRatio) { 61 StringBuffer buffer = new StringBuffer (4); 62 63 if (newRatio < 10) { 64 buffer.append(" "); 65 } 66 if (newRatio < 100) { 67 buffer.append(" "); 68 } 69 buffer.append(newRatio).append("%"); 70 71 setRatioIndicator(buffer.toString()); 72 } else { 73 setRatioIndicator(""); 74 } 75 } 76 } 77 } 78 | Popular Tags |