1 28 29 package com.idaremedia.antx.apis; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.ProjectComponent; 33 34 43 44 public final class Responses 45 { 46 51 public static final ProblemHandler DEATH= 52 new ProblemHandler() { 53 public void problem(Object nugget, int nl) { 54 throw new BuildError(String.valueOf(nugget)); 55 } 56 }; 57 58 59 60 65 public static final ProblemHandler ERROR= 66 new ProblemHandler() { 67 public void problem(Object nugget, int nl) { 68 throw new BuildException(String.valueOf(nugget)); 69 } 70 }; 71 72 73 74 79 public static final ProblemHandler SILENCE= 80 new ProblemHandler() { 81 public void problem(Object nugget, int nl) { 82 } 84 }; 85 86 87 88 96 public static final class LitmusResult implements ProblemHandler { 97 99 public boolean hadProblem; 100 101 102 public String what=""; 103 104 105 public LitmusResult() { 106 } 107 108 109 public void problem(Object nugget, int nl) { 110 this.hadProblem = true; 111 this.what = Tk.stringFrom(nugget,null); 112 } 113 114 public void reset() { 115 hadProblem = false; 116 what = ""; 117 } 118 } 119 120 121 122 128 public static class LogUsing implements ProblemHandler { 129 132 public LogUsing(ProjectComponent pc) { 133 logSpi = new LogEnabled.ForComponent(pc); 134 } 135 138 public LogUsing(LogEnabled impl) { 139 if (impl==null) { 140 throw new IllegalArgumentException (); 141 } 142 logSpi = impl; 143 } 144 145 public void problem(Object nugget, int nl) { 146 logSpi.log(Tk.stringFrom(nugget,null),nl); 147 } 148 final LogEnabled logSpi; 149 } 150 151 152 153 160 public static class LogAndRemember extends LogUsing { 161 163 public boolean hadProblem; 164 165 166 public String what=""; 167 168 171 public LogAndRemember(ProjectComponent pc) { 172 super(pc); 173 } 174 178 public LogAndRemember(LogEnabled impl) { 179 super(impl); 180 } 181 184 public void problem(Object nugget, int nl) { 185 this.hadProblem = true; 186 this.what = Tk.stringFrom(nugget,null); 187 logSpi.log(this.what,nl); 188 } 189 190 public void reset() { 191 hadProblem = false; 192 what = ""; 193 } 194 } 195 196 197 198 private Responses() 199 {} 200 } 201 202 203 | Popular Tags |