##### Coverage Report - org.apache.maven.shared.io.location.URLLocation

Classes in this File | Line Coverage | Branch Coverage | Complexity
URLLocation |
100% | 13/13
100% | 2/2
| 2.0;2

1 |  |
     package org.apache.maven.shared.io.location;
2 |  |
3 |  |
     import java.io.File;
4 |  |
     import java.io.IOException;
5 |  |
     import java.net.URL;
6 |  |
7 |  |
     import org.codehaus.plexus.util.FileUtils;
8 |  |
9 |  |
     public class URLLocation
10 |  |
         extends FileLocation
11 |  |
     {
12 |  |
13 |  |
         private final URL url;
14 |  |
15 |  |
         private final String tempFilePrefix;
16 |  |
17 |  |
         private final String tempFileSuffix;
18 |  |
19 |  |
         private final boolean tempFileDeleteOnExit;
20 |  |
21 |  |
         public URLLocation( URL url, String specification, String tempFilePrefix, String tempFileSuffix,
22 |  |
                             boolean tempFileDeleteOnExit )
23 |  |
         {
24 | 5 |
             super( specification );
25 |  |
26 | 5 |
             this.url = url;
27 | 5 |
             this.tempFilePrefix = tempFilePrefix;
28 | 5 |
             this.tempFileSuffix = tempFileSuffix;
29 | 5 |
             this.tempFileDeleteOnExit = tempFileDeleteOnExit;
30 | 5 |
         }
31 |  |
32 |  |
         protected void initFile()
33 |  |
             throws IOException
34 |  |
         {
35 |  |
             // TODO: Log this in the debug log-level...
36 | 4 |
             if ( unsafeGetFile() == null )
37 |  |
             {
38 | 3 |
                 File tempFile = File.createTempFile( tempFilePrefix, tempFileSuffix );
39 |  |
40 | 3 |
                 if ( tempFileDeleteOnExit )
41 |  |
                 {
42 | 3 |
                     tempFile.deleteOnExit();
43 |  |
                 }
44 |  |
45 | 3 |
                 FileUtils.copyURLToFile( url, tempFile );
46 |  |
47 | 3 |
                 setFile( tempFile );
48 |  |
             }
49 | 4 |
         }
50 |  |
51 |  |
     }