1 28 29 package com.idaremedia.antx.init; 30 31 import java.io.IOException ; 32 import java.io.OutputStream ; 33 import java.util.Properties ; 34 35 import org.apache.tools.ant.BuildException; 36 import org.apache.tools.ant.Project; 37 38 import com.idaremedia.antx.AntX; 39 import com.idaremedia.antx.apis.TestScriptComponent; 40 import com.idaremedia.antx.starters.EchoThingTask; 41 42 58 59 public final class EchoBundleTask extends EchoThingTask 60 implements TestScriptComponent 61 { 62 65 public EchoBundleTask() 66 { 67 super(AntX.print); 68 } 69 70 71 72 75 public EchoBundleTask(String iam) 76 { 77 super(iam); 78 } 79 80 81 82 85 public void setBundleId(String refId) 86 { 87 setThingRefId(refId); 88 } 89 90 91 92 96 public final String getBundleRefId() 97 { 98 return getThingRefId(); 99 } 100 101 102 103 108 public final UISMBundle getReferencedBundle() 109 throws BuildException 110 { 111 return (UISMBundle)getReferencedThing 112 (UISMBundle.class,"task.uism.bad.refid"); 113 } 114 115 116 117 122 protected void verifyCanExecute_(String calr) 123 { 124 super.verifyCanExecute_(calr); 125 getReferencedBundle(); } 127 128 129 130 135 protected void echoThing() throws BuildException 136 { 137 OutputStream os = getOutputStream(); 138 Properties msgs = getReferencedBundle().newProperties(null); 139 140 try { 141 msgs.store(os,getMsg()); 142 143 if (tryAntLog(os)) { 144 log(getAntLogString(os),getMsgLevel().getNativeIndex()); 145 } 146 147 } catch(IOException ioX) { 148 String ermsg = uistrs().get("task.echo.unable"); 149 log(ermsg,Project.MSG_ERR); 150 throw new BuildException(ermsg,getLocation()); 151 152 } finally { 153 try { os.close(); } catch(Exception X){} 154 os=null; 155 msgs.clear(); 156 msgs=null; 157 } 158 } 159 } 160 161 162 | Popular Tags |