1 28 29 package com.idaremedia.antx.tests; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.Task; 33 34 import com.idaremedia.antx.ErrorSnapshot; 35 import com.idaremedia.antx.helpers.Strings; 36 import com.idaremedia.antx.helpers.Tk; 37 38 54 55 public class FakeErrorTask extends Task 56 { 57 public FakeErrorTask() 58 { 59 } 60 61 public void setErrId(String refid) 62 { 63 m_errId = refid; 64 } 65 66 public String getErrId() 67 { 68 return m_errId; 69 } 70 71 public void setMsg(String msg) 72 { 73 m_msg = msg; 74 } 75 76 public final void setMessage(String msg) 77 { 78 setMsg(msg); 79 } 80 81 public String getMsg() 82 { 83 return m_msg; 84 } 85 86 public void setSnapshot(boolean isErrSnapshot) 87 { 88 m_isThrownX = !isErrSnapshot; 89 } 90 91 public boolean isThrown() 92 { 93 return m_isThrownX; 94 } 95 96 public boolean isSnapshot() 97 { 98 return !m_isThrownX; 99 } 100 101 public void setProperties(String nameList) 102 { 103 m_propertiesNameList = nameList; 104 } 105 106 public String getProperties() 107 { 108 return m_propertiesNameList; 109 } 110 111 public void execute() 112 { 113 if (m_isThrownX) { 114 BuildException X = new BuildException(getMsg(),getLocation()); 115 getProject().addReference(getErrId(),X); 116 } else { 117 ErrorSnapshot X = new ErrorSnapshot(this); 118 X.setName(getErrId()); 119 X.setComment(getMsg()); 120 if (getProperties()!=null) { 121 String lc = Tk.lowercaseFrom(getProperties()); 122 if (Strings.ALL.equals(lc)) { 123 X.captureAllProperties(); 124 } else if (Strings.USER.equals(lc)) { 125 X.captureUserProperties(); 126 } else { 127 X.captureProperties(getProperties()); 128 } 129 } 130 getProject().addReference(getErrId(),X); 131 } 132 } 133 134 private String m_errId = "the.err"; 135 private boolean m_isThrownX = true; 136 private String m_msg = "Aarrrghh"; 137 private String m_propertiesNameList; 138 } 139 140 141 | Popular Tags |