1 28 29 package com.idaremedia.antx; 30 31 import org.apache.tools.ant.Location; 32 import org.apache.tools.ant.Task; 33 34 import com.idaremedia.antx.apis.ProblemHandler; 35 import com.idaremedia.antx.apis.Requester; 36 import com.idaremedia.antx.apis.ScriptLocatable; 37 38 53 54 public class Problems implements FixtureCore, FixtureAdministrator 55 { 56 59 public static final String FXID= FixtureIds.PROBLEM_ADMINISTRATION; 60 61 62 63 66 public static final ProblemHandler IgnoringHandler= 67 new ProblemHandler() { 68 public void problem(Object nugget, int nl) { 69 } 71 }; 72 73 74 75 76 83 public static final Location getHelperLocation(Task impl, Requester calr) 84 { 85 Location l = impl.getLocation(); 86 if (l==Location.UNKNOWN_LOCATION) { 87 l = calr.getLocation(); 88 } 89 return l==null ? Location.UNKNOWN_LOCATION : l; 90 } 91 92 93 94 101 public static final Location getCallerLocation(Requester calr, ScriptLocatable impl) 102 { 103 Location l = calr.getLocation(); 104 if (l==Location.UNKNOWN_LOCATION) { 105 l = impl.getLocation(); 106 } 107 return l==null ? Location.UNKNOWN_LOCATION : l; 108 } 109 110 111 112 116 public static ProblemHandler getDefaultHandler() 117 { 118 return (ProblemHandler)FixtureOverlays.getContextInstance().nearest(FXID); 119 } 120 121 122 123 128 public static ProblemHandler getDefaultHandlerNoNull() 129 { 130 ProblemHandler ph = getDefaultHandler(); 131 return (ph!=null) ? ph : IgnoringHandler; 132 } 133 134 135 136 145 public static ProblemHandler installDefaultHandler(ProblemHandler ph, 146 ProblemHandler noInstallHandler) 147 { 148 if (ph==null) { 149 throw new IllegalArgumentException 150 (AntX.uistrs().get("problems.null.handlr")); 151 } 152 return (ProblemHandler)FixtureOverlays.installIfNot 153 (FXID, ph, noInstallHandler, "ProblemsHandler"); 154 } 155 156 157 158 166 public static void unwindDefaultHandler(ProblemHandler noUninstallHandler) 167 { 168 FixtureOverlays.uninstallIfIs(FXID,noUninstallHandler,"ProblemsHandler"); 169 } 170 171 172 173 180 static { 181 AntXFixture.setKillMethod 182 (FXID, 183 new String []{"problems","problemhandlers"}, 184 new KillMethodSkeleton(FXID, "ProblemsHandler")); 185 } 186 187 188 189 private Problems() 190 { } 191 } 192 193 194 | Popular Tags |