1 9 package com.vladium.emma.ant; 10 11 import java.io.File ; 12 13 import com.vladium.emma.IAppConstants; 14 import com.vladium.util.IProperties; 15 16 import org.apache.tools.ant.BuildException; 17 import org.apache.tools.ant.Location; 18 import org.apache.tools.ant.Task; 19 20 24 public 25 abstract class SuppressableTask extends Task 26 { 27 29 30 public void init () throws BuildException 31 { 32 super.init (); 33 34 m_verbosityCfg = new VerbosityCfg (); 35 m_genericCfg = new GenericCfg (this); 36 } 37 38 41 public final void setEnabled (final boolean enabled) 42 { 43 m_enabled = enabled; 44 } 45 46 public final boolean isEnabled () 47 { 48 return m_enabled; 49 } 50 51 53 public void setVerbosity (final VerbosityCfg.VerbosityAttribute verbosity) 54 { 55 m_verbosityCfg.setVerbosity (verbosity); 56 } 57 58 60 public void setVerbosityfilter (final String filter) 61 { 62 m_verbosityCfg.setVerbosityfilter (filter); 63 } 64 65 67 public final void setProperties (final File file) 68 { 69 m_genericCfg.setProperties (file); 70 } 71 72 74 public final PropertyElement createProperty () 75 { 76 return m_genericCfg.createProperty (); 77 } 78 79 80 public static BuildException newBuildException (final String msg, final Location location) 81 { 82 final String prefixedMsg = ((msg == null) || (msg.length () == 0)) 83 ? msg 84 : IAppConstants.APP_THROWABLE_BUILD_ID + " " + msg; 85 86 return new BuildException (prefixedMsg, location); 87 } 88 89 public static BuildException newBuildException (final String msg, final Throwable cause, final Location location) 90 { 91 final String prefixedMsg = ((msg == null) || (msg.length () == 0)) 92 ? msg 93 : IAppConstants.APP_THROWABLE_BUILD_ID + " " + msg; 94 95 return new BuildException (prefixedMsg, cause, location); 96 } 97 98 100 101 protected SuppressableTask () 102 { 103 m_enabled = true; } 105 106 protected IProperties getTaskSettings () 107 { 108 110 113 final IProperties fileSettings = m_genericCfg.getFileSettings (); 114 final IProperties genericSettings = m_genericCfg.getGenericSettings (); 115 final IProperties verbositySettings = m_verbosityCfg.getSettings (); 116 117 return IProperties.Factory.combine (verbositySettings, 118 IProperties.Factory.combine (genericSettings, 119 fileSettings)); 120 } 121 122 124 126 127 private VerbosityCfg m_verbosityCfg; 128 private GenericCfg m_genericCfg; 129 private boolean m_enabled; 130 131 } | Popular Tags |