/usr/share/doc/libcobertura-java/api/src-html/net/sourceforge/cobertura/util/FileFinder.html is in libcobertura-java-doc 1.9.4.1+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | <HTML>
<BODY BGCOLOR="white">
<PRE>
<FONT color="green">001</FONT> /*<a name="line.1"></a>
<FONT color="green">002</FONT> * Cobertura - http://cobertura.sourceforge.net/<a name="line.2"></a>
<FONT color="green">003</FONT> *<a name="line.3"></a>
<FONT color="green">004</FONT> * Copyright (C) 2005 Jeremy Thomerson<a name="line.4"></a>
<FONT color="green">005</FONT> * Copyright (C) 2005 Grzegorz Lukasik<a name="line.5"></a>
<FONT color="green">006</FONT> * Copyright (C) 2009 Charlie Squires<a name="line.6"></a>
<FONT color="green">007</FONT> * Copyright (C) 2009 John Lewis<a name="line.7"></a>
<FONT color="green">008</FONT> *<a name="line.8"></a>
<FONT color="green">009</FONT> * Cobertura is free software; you can redistribute it and/or modify<a name="line.9"></a>
<FONT color="green">010</FONT> * it under the terms of the GNU General Public License as published<a name="line.10"></a>
<FONT color="green">011</FONT> * by the Free Software Foundation; either version 2 of the License,<a name="line.11"></a>
<FONT color="green">012</FONT> * or (at your option) any later version.<a name="line.12"></a>
<FONT color="green">013</FONT> *<a name="line.13"></a>
<FONT color="green">014</FONT> * Cobertura is distributed in the hope that it will be useful, but<a name="line.14"></a>
<FONT color="green">015</FONT> * WITHOUT ANY WARRANTY; without even the implied warranty of<a name="line.15"></a>
<FONT color="green">016</FONT> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU<a name="line.16"></a>
<FONT color="green">017</FONT> * General Public License for more details.<a name="line.17"></a>
<FONT color="green">018</FONT> *<a name="line.18"></a>
<FONT color="green">019</FONT> * You should have received a copy of the GNU General Public License<a name="line.19"></a>
<FONT color="green">020</FONT> * along with Cobertura; if not, write to the Free Software<a name="line.20"></a>
<FONT color="green">021</FONT> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307<a name="line.21"></a>
<FONT color="green">022</FONT> * USA<a name="line.22"></a>
<FONT color="green">023</FONT> */<a name="line.23"></a>
<FONT color="green">024</FONT> package net.sourceforge.cobertura.util;<a name="line.24"></a>
<FONT color="green">025</FONT> <a name="line.25"></a>
<FONT color="green">026</FONT> import java.io.File;<a name="line.26"></a>
<FONT color="green">027</FONT> import java.io.FileInputStream;<a name="line.27"></a>
<FONT color="green">028</FONT> import java.io.FilenameFilter;<a name="line.28"></a>
<FONT color="green">029</FONT> import java.io.IOException;<a name="line.29"></a>
<FONT color="green">030</FONT> import java.util.ArrayList;<a name="line.30"></a>
<FONT color="green">031</FONT> import java.util.Enumeration;<a name="line.31"></a>
<FONT color="green">032</FONT> import java.util.HashMap;<a name="line.32"></a>
<FONT color="green">033</FONT> import java.util.HashSet;<a name="line.33"></a>
<FONT color="green">034</FONT> import java.util.Iterator;<a name="line.34"></a>
<FONT color="green">035</FONT> import java.util.List;<a name="line.35"></a>
<FONT color="green">036</FONT> import java.util.Map;<a name="line.36"></a>
<FONT color="green">037</FONT> import java.util.Set;<a name="line.37"></a>
<FONT color="green">038</FONT> import java.util.jar.JarEntry;<a name="line.38"></a>
<FONT color="green">039</FONT> import java.util.jar.JarFile;<a name="line.39"></a>
<FONT color="green">040</FONT> <a name="line.40"></a>
<FONT color="green">041</FONT> import org.apache.log4j.Logger;<a name="line.41"></a>
<FONT color="green">042</FONT> <a name="line.42"></a>
<FONT color="green">043</FONT> <a name="line.43"></a>
<FONT color="green">044</FONT> /**<a name="line.44"></a>
<FONT color="green">045</FONT> * Maps source file names to existing files. After adding description<a name="line.45"></a>
<FONT color="green">046</FONT> * of places files can be found in, it can be used to localize <a name="line.46"></a>
<FONT color="green">047</FONT> * the files. <a name="line.47"></a>
<FONT color="green">048</FONT> * <a name="line.48"></a>
<FONT color="green">049</FONT> * <p><a name="line.49"></a>
<FONT color="green">050</FONT> * FileFinder supports two types of source files locations:<a name="line.50"></a>
<FONT color="green">051</FONT> * <ul><a name="line.51"></a>
<FONT color="green">052</FONT> * <li>source root directory, defines the directory under <a name="line.52"></a>
<FONT color="green">053</FONT> * which source files are located,</li><a name="line.53"></a>
<FONT color="green">054</FONT> * <li>pair (base directory, file path relative to base directory).</li><a name="line.54"></a>
<FONT color="green">055</FONT> * </ul><a name="line.55"></a>
<FONT color="green">056</FONT> * The difference between these two is that in case of the first you add all<a name="line.56"></a>
<FONT color="green">057</FONT> * source files under the specified root directory, and in the second you add<a name="line.57"></a>
<FONT color="green">058</FONT> * exactly one file. In both cases file to be found has to be located under <a name="line.58"></a>
<FONT color="green">059</FONT> * subdirectory that maps to package definition provided with the source file name. <a name="line.59"></a>
<FONT color="green">060</FONT> * <a name="line.60"></a>
<FONT color="green">061</FONT> * @author Jeremy Thomerson<a name="line.61"></a>
<FONT color="green">062</FONT> */<a name="line.62"></a>
<FONT color="green">063</FONT> public class FileFinder {<a name="line.63"></a>
<FONT color="green">064</FONT> <a name="line.64"></a>
<FONT color="green">065</FONT> private static Logger LOGGER = Logger.getLogger(FileFinder.class);<a name="line.65"></a>
<FONT color="green">066</FONT> <a name="line.66"></a>
<FONT color="green">067</FONT> // Contains Strings with directory paths<a name="line.67"></a>
<FONT color="green">068</FONT> private Set sourceDirectories = new HashSet();<a name="line.68"></a>
<FONT color="green">069</FONT> <a name="line.69"></a>
<FONT color="green">070</FONT> // Contains pairs (String directoryRoot, Set fileNamesRelativeToRoot)<a name="line.70"></a>
<FONT color="green">071</FONT> private Map sourceFilesMap = new HashMap();<a name="line.71"></a>
<FONT color="green">072</FONT> <a name="line.72"></a>
<FONT color="green">073</FONT> /**<a name="line.73"></a>
<FONT color="green">074</FONT> * Adds directory that is a root of sources. A source file<a name="line.74"></a>
<FONT color="green">075</FONT> * that is under this directory will be found if relative<a name="line.75"></a>
<FONT color="green">076</FONT> * path to the file from root matches package name.<a name="line.76"></a>
<FONT color="green">077</FONT> * <p><a name="line.77"></a>
<FONT color="green">078</FONT> * Example:<a name="line.78"></a>
<FONT color="green">079</FONT> * <pre><a name="line.79"></a>
<FONT color="green">080</FONT> * fileFinder.addSourceDirectory( "C:/MyProject/src/main");<a name="line.80"></a>
<FONT color="green">081</FONT> * fileFinder.addSourceDirectory( "C:/MyProject/src/test");<a name="line.81"></a>
<FONT color="green">082</FONT> * </pre><a name="line.82"></a>
<FONT color="green">083</FONT> * In path both / and \ can be used.<a name="line.83"></a>
<FONT color="green">084</FONT> * </p> <a name="line.84"></a>
<FONT color="green">085</FONT> * <a name="line.85"></a>
<FONT color="green">086</FONT> * @param directory The root of source files <a name="line.86"></a>
<FONT color="green">087</FONT> * @throws NullPointerException if <code>directory</code> is <code>null</code><a name="line.87"></a>
<FONT color="green">088</FONT> */<a name="line.88"></a>
<FONT color="green">089</FONT> public void addSourceDirectory( String directory) {<a name="line.89"></a>
<FONT color="green">090</FONT> if( LOGGER.isDebugEnabled())<a name="line.90"></a>
<FONT color="green">091</FONT> LOGGER.debug( "Adding sourceDirectory=[" + directory + "]");<a name="line.91"></a>
<FONT color="green">092</FONT> <a name="line.92"></a>
<FONT color="green">093</FONT> // Change \ to / in case of Windows users<a name="line.93"></a>
<FONT color="green">094</FONT> directory = getCorrectedPath(directory);<a name="line.94"></a>
<FONT color="green">095</FONT> sourceDirectories.add(directory);<a name="line.95"></a>
<FONT color="green">096</FONT> }<a name="line.96"></a>
<FONT color="green">097</FONT> <a name="line.97"></a>
<FONT color="green">098</FONT> /**<a name="line.98"></a>
<FONT color="green">099</FONT> * Adds file by specifying root directory and relative path to the<a name="line.99"></a>
<FONT color="green">100</FONT> * file in it. Adds exactly one file, relative path should match<a name="line.100"></a>
<FONT color="green">101</FONT> * package that the source file is in, otherwise it will be not<a name="line.101"></a>
<FONT color="green">102</FONT> * found later.<a name="line.102"></a>
<FONT color="green">103</FONT> * <p><a name="line.103"></a>
<FONT color="green">104</FONT> * Example:<a name="line.104"></a>
<FONT color="green">105</FONT> * <pre><a name="line.105"></a>
<FONT color="green">106</FONT> * fileFinder.addSourceFile( "C:/MyProject/src/main", "com/app/MyClass.java");<a name="line.106"></a>
<FONT color="green">107</FONT> * fileFinder.addSourceFile( "C:/MyProject/src/test", "com/app/MyClassTest.java");<a name="line.107"></a>
<FONT color="green">108</FONT> * </pre><a name="line.108"></a>
<FONT color="green">109</FONT> * In paths both / and \ can be used.<a name="line.109"></a>
<FONT color="green">110</FONT> * </p><a name="line.110"></a>
<FONT color="green">111</FONT> * <a name="line.111"></a>
<FONT color="green">112</FONT> * @param baseDir sources root directory<a name="line.112"></a>
<FONT color="green">113</FONT> * @param file path to source file relative to <code>baseDir</code><a name="line.113"></a>
<FONT color="green">114</FONT> * @throws NullPointerException if either <code>baseDir</code> or <code>file</code> is <code>null</code><a name="line.114"></a>
<FONT color="green">115</FONT> */<a name="line.115"></a>
<FONT color="green">116</FONT> public void addSourceFile( String baseDir, String file) {<a name="line.116"></a>
<FONT color="green">117</FONT> if( LOGGER.isDebugEnabled())<a name="line.117"></a>
<FONT color="green">118</FONT> LOGGER.debug( "Adding sourceFile baseDir=[" + baseDir + "] file=[" + file + "]");<a name="line.118"></a>
<FONT color="green">119</FONT> <a name="line.119"></a>
<FONT color="green">120</FONT> if( baseDir==null || file==null)<a name="line.120"></a>
<FONT color="green">121</FONT> throw new NullPointerException();<a name="line.121"></a>
<FONT color="green">122</FONT> <a name="line.122"></a>
<FONT color="green">123</FONT> // Change \ to / in case of Windows users<a name="line.123"></a>
<FONT color="green">124</FONT> file = getCorrectedPath( file);<a name="line.124"></a>
<FONT color="green">125</FONT> baseDir = getCorrectedPath( baseDir);<a name="line.125"></a>
<FONT color="green">126</FONT> <a name="line.126"></a>
<FONT color="green">127</FONT> // Add file to sourceFilesMap<a name="line.127"></a>
<FONT color="green">128</FONT> Set container = (Set) sourceFilesMap.get(baseDir);<a name="line.128"></a>
<FONT color="green">129</FONT> if( container==null) {<a name="line.129"></a>
<FONT color="green">130</FONT> container = new HashSet();<a name="line.130"></a>
<FONT color="green">131</FONT> sourceFilesMap.put( baseDir, container);<a name="line.131"></a>
<FONT color="green">132</FONT> }<a name="line.132"></a>
<FONT color="green">133</FONT> container.add( file);<a name="line.133"></a>
<FONT color="green">134</FONT> }<a name="line.134"></a>
<FONT color="green">135</FONT> <a name="line.135"></a>
<FONT color="green">136</FONT> /**<a name="line.136"></a>
<FONT color="green">137</FONT> * Maps source file name to existing file.<a name="line.137"></a>
<FONT color="green">138</FONT> * When mapping file name first values that were added with<a name="line.138"></a>
<FONT color="green">139</FONT> * {@link #addSourceDirectory} and later added with {@link #addSourceFile} are checked.<a name="line.139"></a>
<FONT color="green">140</FONT> * <a name="line.140"></a>
<FONT color="green">141</FONT> * @param fileName source file to be mapped<a name="line.141"></a>
<FONT color="green">142</FONT> * @return existing file that maps to passed sourceFile <a name="line.142"></a>
<FONT color="green">143</FONT> * @throws IOException if cannot map source file to existing file<a name="line.143"></a>
<FONT color="green">144</FONT> * @throws NullPointerException if fileName is null<a name="line.144"></a>
<FONT color="green">145</FONT> */<a name="line.145"></a>
<FONT color="green">146</FONT> public File getFileForSource(String fileName) throws IOException {<a name="line.146"></a>
<FONT color="green">147</FONT> // Correct file name<a name="line.147"></a>
<FONT color="green">148</FONT> if( LOGGER.isDebugEnabled())<a name="line.148"></a>
<FONT color="green">149</FONT> LOGGER.debug( "Searching for file, name=[" + fileName + "]");<a name="line.149"></a>
<FONT color="green">150</FONT> fileName = getCorrectedPath( fileName);<a name="line.150"></a>
<FONT color="green">151</FONT> <a name="line.151"></a>
<FONT color="green">152</FONT> // Check inside sourceDirectories<a name="line.152"></a>
<FONT color="green">153</FONT> for( Iterator it=sourceDirectories.iterator(); it.hasNext();) {<a name="line.153"></a>
<FONT color="green">154</FONT> String directory = (String)it.next();<a name="line.154"></a>
<FONT color="green">155</FONT> File file = new File( directory, fileName);<a name="line.155"></a>
<FONT color="green">156</FONT> if( file.isFile()) {<a name="line.156"></a>
<FONT color="green">157</FONT> LOGGER.debug( "Found inside sourceDirectories");<a name="line.157"></a>
<FONT color="green">158</FONT> return file;<a name="line.158"></a>
<FONT color="green">159</FONT> }<a name="line.159"></a>
<FONT color="green">160</FONT> }<a name="line.160"></a>
<FONT color="green">161</FONT> <a name="line.161"></a>
<FONT color="green">162</FONT> // Check inside sourceFilesMap<a name="line.162"></a>
<FONT color="green">163</FONT> for( Iterator it=sourceFilesMap.keySet().iterator(); it.hasNext();) {<a name="line.163"></a>
<FONT color="green">164</FONT> String directory = (String)it.next();<a name="line.164"></a>
<FONT color="green">165</FONT> Set container = (Set) sourceFilesMap.get(directory);<a name="line.165"></a>
<FONT color="green">166</FONT> if( !container.contains( fileName))<a name="line.166"></a>
<FONT color="green">167</FONT> continue;<a name="line.167"></a>
<FONT color="green">168</FONT> File file = new File( directory, fileName);<a name="line.168"></a>
<FONT color="green">169</FONT> if( file.isFile()) {<a name="line.169"></a>
<FONT color="green">170</FONT> LOGGER.debug( "Found inside sourceFilesMap");<a name="line.170"></a>
<FONT color="green">171</FONT> return file;<a name="line.171"></a>
<FONT color="green">172</FONT> }<a name="line.172"></a>
<FONT color="green">173</FONT> }<a name="line.173"></a>
<FONT color="green">174</FONT> <a name="line.174"></a>
<FONT color="green">175</FONT> // Have not found? Throw an error.<a name="line.175"></a>
<FONT color="green">176</FONT> LOGGER.debug( "File not found");<a name="line.176"></a>
<FONT color="green">177</FONT> throw new IOException( "Cannot find source file, name=["+fileName+"]");<a name="line.177"></a>
<FONT color="green">178</FONT> }<a name="line.178"></a>
<FONT color="green">179</FONT> <a name="line.179"></a>
<FONT color="green">180</FONT> /**<a name="line.180"></a>
<FONT color="green">181</FONT> * Maps source file name to existing file or source archive.<a name="line.181"></a>
<FONT color="green">182</FONT> * When mapping file name first values that were added with<a name="line.182"></a>
<FONT color="green">183</FONT> * {@link #addSourceDirectory} and later added with {@link #addSourceFile} are checked.<a name="line.183"></a>
<FONT color="green">184</FONT> * <a name="line.184"></a>
<FONT color="green">185</FONT> * @param fileName source file to be mapped<a name="line.185"></a>
<FONT color="green">186</FONT> * @return Source that maps to passed sourceFile or null if it can't be found<a name="line.186"></a>
<FONT color="green">187</FONT> * @throws NullPointerException if fileName is null<a name="line.187"></a>
<FONT color="green">188</FONT> */<a name="line.188"></a>
<FONT color="green">189</FONT> public Source getSource(String fileName) {<a name="line.189"></a>
<FONT color="green">190</FONT> File file = null;<a name="line.190"></a>
<FONT color="green">191</FONT> try<a name="line.191"></a>
<FONT color="green">192</FONT> {<a name="line.192"></a>
<FONT color="green">193</FONT> file = getFileForSource(fileName);<a name="line.193"></a>
<FONT color="green">194</FONT> return new Source(new FileInputStream(file), file);<a name="line.194"></a>
<FONT color="green">195</FONT> }<a name="line.195"></a>
<FONT color="green">196</FONT> catch (IOException e)<a name="line.196"></a>
<FONT color="green">197</FONT> {<a name="line.197"></a>
<FONT color="green">198</FONT> //Source file wasn't found. Try searching archives.<a name="line.198"></a>
<FONT color="green">199</FONT> return searchJarsForSource(fileName);<a name="line.199"></a>
<FONT color="green">200</FONT> }<a name="line.200"></a>
<FONT color="green">201</FONT> <a name="line.201"></a>
<FONT color="green">202</FONT> }<a name="line.202"></a>
<FONT color="green">203</FONT> <a name="line.203"></a>
<FONT color="green">204</FONT> /**<a name="line.204"></a>
<FONT color="green">205</FONT> * Gets a BufferedReader for a file within a jar.<a name="line.205"></a>
<FONT color="green">206</FONT> * <a name="line.206"></a>
<FONT color="green">207</FONT> * @param fileName source file to get an input stream for<a name="line.207"></a>
<FONT color="green">208</FONT> * @return Source for existing file inside a jar that maps to passed sourceFile <a name="line.208"></a>
<FONT color="green">209</FONT> * or null if cannot map source file to existing file<a name="line.209"></a>
<FONT color="green">210</FONT> */<a name="line.210"></a>
<FONT color="green">211</FONT> private Source searchJarsForSource(String fileName) {<a name="line.211"></a>
<FONT color="green">212</FONT> //Check inside jars in sourceDirectories<a name="line.212"></a>
<FONT color="green">213</FONT> for( Iterator it=sourceDirectories.iterator(); it.hasNext();) {<a name="line.213"></a>
<FONT color="green">214</FONT> String directory = (String)it.next();<a name="line.214"></a>
<FONT color="green">215</FONT> File file = new File(directory);<a name="line.215"></a>
<FONT color="green">216</FONT> //Get a list of jars and zips in the directory<a name="line.216"></a>
<FONT color="green">217</FONT> String[] jars = file.list(new JarZipFilter());<a name="line.217"></a>
<FONT color="green">218</FONT> if(jars != null) {<a name="line.218"></a>
<FONT color="green">219</FONT> for(String jar : jars) {<a name="line.219"></a>
<FONT color="green">220</FONT> try<a name="line.220"></a>
<FONT color="green">221</FONT> {<a name="line.221"></a>
<FONT color="green">222</FONT> LOGGER.debug("Looking for: " + fileName + " in "+ jar);<a name="line.222"></a>
<FONT color="green">223</FONT> JarFile jf = new JarFile(directory + "/" + jar);<a name="line.223"></a>
<FONT color="green">224</FONT> <a name="line.224"></a>
<FONT color="green">225</FONT> //Get a list of files in the jar<a name="line.225"></a>
<FONT color="green">226</FONT> Enumeration<JarEntry> files = jf.entries();<a name="line.226"></a>
<FONT color="green">227</FONT> //See if the jar has the class we need<a name="line.227"></a>
<FONT color="green">228</FONT> while(files.hasMoreElements()) {<a name="line.228"></a>
<FONT color="green">229</FONT> JarEntry entry = files.nextElement();<a name="line.229"></a>
<FONT color="green">230</FONT> if(entry.getName().equals(fileName)) {<a name="line.230"></a>
<FONT color="green">231</FONT> return new Source(jf.getInputStream(entry), jf);<a name="line.231"></a>
<FONT color="green">232</FONT> }<a name="line.232"></a>
<FONT color="green">233</FONT> }<a name="line.233"></a>
<FONT color="green">234</FONT> }<a name="line.234"></a>
<FONT color="green">235</FONT> catch (Throwable t)<a name="line.235"></a>
<FONT color="green">236</FONT> {<a name="line.236"></a>
<FONT color="green">237</FONT> LOGGER.warn("Error while reading " + jar, t);<a name="line.237"></a>
<FONT color="green">238</FONT> }<a name="line.238"></a>
<FONT color="green">239</FONT> }<a name="line.239"></a>
<FONT color="green">240</FONT> }<a name="line.240"></a>
<FONT color="green">241</FONT> }<a name="line.241"></a>
<FONT color="green">242</FONT> return null;<a name="line.242"></a>
<FONT color="green">243</FONT> }<a name="line.243"></a>
<FONT color="green">244</FONT> <a name="line.244"></a>
<FONT color="green">245</FONT> /**<a name="line.245"></a>
<FONT color="green">246</FONT> * Returns a list with string for all source directories.<a name="line.246"></a>
<FONT color="green">247</FONT> * Example: <code>[C:/MyProject/src/main,C:/MyProject/src/test]</code><a name="line.247"></a>
<FONT color="green">248</FONT> * <a name="line.248"></a>
<FONT color="green">249</FONT> * @return list with Strings for all source roots, or empty list if no source roots were specified <a name="line.249"></a>
<FONT color="green">250</FONT> */<a name="line.250"></a>
<FONT color="green">251</FONT> public List getSourceDirectoryList() {<a name="line.251"></a>
<FONT color="green">252</FONT> // Get names from sourceDirectories<a name="line.252"></a>
<FONT color="green">253</FONT> List result = new ArrayList();<a name="line.253"></a>
<FONT color="green">254</FONT> for( Iterator it=sourceDirectories.iterator(); it.hasNext();) {<a name="line.254"></a>
<FONT color="green">255</FONT> result.add( it.next());<a name="line.255"></a>
<FONT color="green">256</FONT> }<a name="line.256"></a>
<FONT color="green">257</FONT> <a name="line.257"></a>
<FONT color="green">258</FONT> // Get names from sourceFilesMap<a name="line.258"></a>
<FONT color="green">259</FONT> for( Iterator it=sourceFilesMap.keySet().iterator(); it.hasNext();) {<a name="line.259"></a>
<FONT color="green">260</FONT> result.add(it.next());<a name="line.260"></a>
<FONT color="green">261</FONT> }<a name="line.261"></a>
<FONT color="green">262</FONT> <a name="line.262"></a>
<FONT color="green">263</FONT> // Return combined names<a name="line.263"></a>
<FONT color="green">264</FONT> return result;<a name="line.264"></a>
<FONT color="green">265</FONT> }<a name="line.265"></a>
<FONT color="green">266</FONT> <a name="line.266"></a>
<FONT color="green">267</FONT> private String getCorrectedPath(String path) {<a name="line.267"></a>
<FONT color="green">268</FONT> return path.replace('\\', '/');<a name="line.268"></a>
<FONT color="green">269</FONT> }<a name="line.269"></a>
<FONT color="green">270</FONT> <a name="line.270"></a>
<FONT color="green">271</FONT> /**<a name="line.271"></a>
<FONT color="green">272</FONT> * Returns string representation of FileFinder.<a name="line.272"></a>
<FONT color="green">273</FONT> */<a name="line.273"></a>
<FONT color="green">274</FONT> public String toString() {<a name="line.274"></a>
<FONT color="green">275</FONT> return "FileFinder, source directories: " + getSourceDirectoryList().toString();<a name="line.275"></a>
<FONT color="green">276</FONT> }<a name="line.276"></a>
<FONT color="green">277</FONT> <a name="line.277"></a>
<FONT color="green">278</FONT> /**<a name="line.278"></a>
<FONT color="green">279</FONT> * A filter that accepts files that end in .jar or .zip<a name="line.279"></a>
<FONT color="green">280</FONT> */<a name="line.280"></a>
<FONT color="green">281</FONT> private class JarZipFilter implements FilenameFilter {<a name="line.281"></a>
<FONT color="green">282</FONT> public boolean accept(File dir, String name) {<a name="line.282"></a>
<FONT color="green">283</FONT> return(name.endsWith(".jar") || name.endsWith(".zip"));<a name="line.283"></a>
<FONT color="green">284</FONT> }<a name="line.284"></a>
<FONT color="green">285</FONT> }<a name="line.285"></a>
<FONT color="green">286</FONT> }<a name="line.286"></a>
</PRE>
</BODY>
</HTML>
|