1 28 29 package com.idaremedia.antx.helpers; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.Project; 33 34 import com.idaremedia.antx.apis.Nameable; 35 36 50 51 public class InnerNameValuePair implements Nameable, Cloneable 52 { 53 56 public InnerNameValuePair() 57 { 58 } 59 60 61 64 public InnerNameValuePair(String name, String value) 65 { 66 setNV(name,value); 67 } 68 69 70 71 75 public Object clone() 76 { 77 try { 78 return super.clone(); 79 } catch(CloneNotSupportedException clnX) { 80 throw new Error (); 81 } 82 } 83 84 85 86 90 public void setName(String s) 91 { 92 m_name = s; 93 } 94 95 96 97 101 public String getName() 102 { 103 return m_name; 104 } 105 106 107 108 112 public void setValue(String s) 113 { 114 m_value = s; 115 } 116 117 118 119 123 public void addText(String text) 124 { 125 m_value += text; 126 } 127 128 129 130 133 public String getValue() 134 { 135 return m_value; 136 } 137 138 139 140 145 public String getValue(final Project P) 146 { 147 String s = getValue(); 148 if (P!=null) { 149 s = Tk.resolveString(P,s); 150 } 151 return s; 152 } 153 154 155 156 163 public String getValue(final Project P, boolean altForm) 164 { 165 String s = getValue(); 166 if (P!=null) { 167 s = Tk.resolveString(P,s,altForm); 168 } 169 return s; 170 } 171 172 173 174 178 public void setNull() 179 { 180 m_name = null; 181 m_value = null; 182 } 183 184 185 186 190 public void setNV(String name, String value) 191 { 192 m_name = name; 193 m_value = value; 194 } 195 196 197 198 204 public String toString() 205 { 206 return ""+getName()+"="+getValue(); 207 } 208 209 210 211 216 public String toString(final Project P) 217 { 218 String s = getValue(); 219 if (P!=null) { 220 s = Tk.resolveString(P,s); 221 } 222 return ""+getName()+"="+s; 223 } 224 225 226 227 232 public void verifyNamed() 233 { 234 if (m_name==null || m_name.length()==0) { 235 throw new BuildException("A non-empty name is required."); 236 } 237 } 238 239 private String m_name="", m_value=""; 240 } 241 242 243 | Popular Tags |