1 28 29 package com.idaremedia.antx.condition; 30 31 import java.io.File ; 32 33 import org.apache.tools.ant.BuildException; 34 import org.apache.tools.ant.Project; 35 import org.apache.tools.ant.taskdefs.Available; 36 import org.apache.tools.ant.taskdefs.condition.Condition; 37 import org.apache.tools.ant.types.Path; 38 39 import com.idaremedia.antx.AssertableProjectComponent; 40 import com.idaremedia.antx.helpers.Strings; 41 42 54 55 public final class IsDirectory extends AssertableProjectComponent 56 implements Condition, URIable 57 { 58 61 public IsDirectory() 62 { 63 m_impl = new Available(); 64 } 65 66 67 72 public IsDirectory(String location) 73 { 74 this(); 75 setLocation(location); 76 } 77 78 79 83 public void setProject(Project p) 84 { 85 super.setProject(p); 86 m_impl.setProject(p); 87 } 88 89 90 94 public void setLocation(String location) 95 { 96 require_(location!=null,"setname- nonzro location"); 97 m_impl.setFile(new File (location)); 98 } 99 100 101 105 public void setFilepath(Path filepath) 106 { 107 require_(filepath!=null,"setFilepath- nonzro path"); 108 m_impl.setFilepath(filepath); 109 } 110 111 112 116 public void setTrueProperty(String property) 117 { 118 require_(property!=null,"setTrueProp- nonzro name"); 119 m_updateProperty = property; } 121 122 123 127 public final String getTrueProperty() 128 { 129 return m_updateProperty; 130 } 131 132 133 134 138 public void xsetFromURI(String fragment) 139 { 140 setLocation(fragment); 141 } 142 143 144 145 149 public boolean eval() throws BuildException 150 { 151 verifyInProject_("eval"); 152 153 boolean istrue = m_impl.eval(); 154 155 if (istrue && m_updateProperty!=null) { 156 log("IsDirectory was true; setting true-property '"+m_updateProperty+ 157 "' property", Project.MSG_DEBUG); 158 getProject().setNewProperty(m_updateProperty,Strings.TRUE); 159 } 160 161 return istrue; 162 } 163 164 165 private Available m_impl; 166 private String m_updateProperty; 167 } 168 169 170 | Popular Tags |