1 28 29 package com.idaremedia.antx; 30 31 import org.apache.tools.ant.Project; 32 import org.apache.tools.ant.ProjectComponent; 33 34 import com.idaremedia.apis.UIStringManager; 35 36 import com.idaremedia.antx.apis.ProjectDependent; 37 import com.idaremedia.antx.helpers.Tk; 38 39 48 49 public abstract class AssertableProjectComponent extends ProjectComponent 50 implements ProjectDependent 51 { 52 55 protected AssertableProjectComponent() 56 { 57 super(); 58 Iam_=""; 59 } 60 61 62 66 protected AssertableProjectComponent(String iam) 67 { 68 super(); 69 Iam_= Tk.cvlabelFrom(iam); 70 } 71 72 73 76 protected final String cvlabel_() 77 { 78 return Iam_; 79 } 80 81 82 87 public final UIStringManager uistrs() 88 { 89 return AntX.uistrs(); 90 } 91 92 93 99 protected final void require_(boolean c, String msg) 100 { 101 if (!c) { 102 String ermsg = uistrs().get("cv.require",Iam_,msg); 103 log(ermsg, Project.MSG_ERR); 104 throw new IllegalArgumentException (ermsg); 105 } 106 } 107 108 109 116 protected final void ensure_(boolean c, String msg) 117 { 118 if (!c) { 119 String ermsg = uistrs().get("cv.ensure",Iam_,msg); 120 log(ermsg, Project.MSG_ERR); 121 throw new IllegalStateException (ermsg); 122 } 123 } 124 125 126 133 protected final void verify_(boolean c, String msg) 134 { 135 if (!c) { 136 String ermsg = uistrs().get("cv.verify",Iam_,msg); 137 log(ermsg, Project.MSG_ERR); 138 throw new IllegalStateException (ermsg); 139 } 140 } 141 142 143 149 protected final void unexpected_(Throwable t, String msg) 150 { 151 String ermsg = uistrs().get("cv.unexpected",Iam_,msg,t); 152 log(ermsg, Project.MSG_WARN); 153 } 154 155 156 160 protected final void verifyInProject_(String calr) 161 { 162 if (getProject()==null) { 163 String ermsg = uistrs().get("cv.verifyInP",Iam_,calr); 164 log(ermsg, Project.MSG_ERR); 165 throw new IllegalStateException (ermsg); 166 } 167 } 168 169 170 private final String Iam_; 171 } 172 173 174 | Popular Tags |