Clover coverage report - brownies library - 1.0-beta-1 Coverage timestamp: 月 8 16 2004 17:14:42 GMT+09:00 FRAMES NO FRAMES |
file stats: | LOC: | 73 |  | Methods: | 4
| NCLOC: | 42 |  | Classes: | 1
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover
Source file | Conditionals | Statements | Methods | TOTAL
FileNameResolver.java | 0% | 0% | 0% | 0% |

1 |  |
     /*
2 |  |
      * Joey and its relative products are published under the terms
3 |  |
      * of the Apache Software License.
4 |  |
      */
5 |  |
     /*
6 |  |
      * Created on 2003/12/27
7 |  |
      */
8 |  |
     package org.asyrinx.brownie.servlet;
9 |  |
10 |  |
     import java.io.File;
11 |  |
12 |  |
     import javax.servlet.ServletContext;
13 |  |
14 |  |
     import org.apache.commons.lang.StringUtils;
15 |  |
     import org.asyrinx.brownie.core.io.FileNameUtils;
16 |  |
17 |  |
     /**
18 |  |
      * @author akima
19 |  |
      */
20 |  |
     public class FileNameResolver {
21 |  |
22 |  |
         /**
23 |  |
          *
24 |  |
          */
25 | 0 |
         public FileNameResolver(ServletContext servletContext) {
26 | 0 |
             super();
27 | 0 |
             this.servletContext = servletContext;
28 | 0 |
             this.contextRootPath = servletContext.getRealPath("/");
29 |  |
         }
30 |  |
31 |  |
         protected final ServletContext servletContext;
32 |  |
33 |  |
         protected final String contextRootPath;
34 |  |
35 | 0 |
         public String toRealPath(String path) {
36 | 0 |
             if (this.servletContext == null)
37 | 0 |
                 throw new ServletContextRuntimeException(
38 |  |
                         "servletContext is null!! ");
39 | 0 |
             if (StringUtils.isEmpty(path))
40 | 0 |
                 return this.contextRootPath;
41 | 0 |
             final File origPathFile = new File(path);
42 | 0 |
             if (origPathFile.exists()) {
43 | 0 |
                 this.servletContext.log(this.getClass().getName() + ": '" + path
44 |  |
                         + "' exists.");
45 | 0 |
                 return path;
46 |  |
             }
47 | 0 |
             if (origPathFile.isAbsolute()) {
48 | 0 |
                 this.servletContext.log(this.getClass().getName() + ": '" + path
49 |  |
                         + "' is an absolute path, but doesn't exist.");
50 | 0 |
                 return path;
51 |  |
             }
52 | 0 |
             final String realPath = FileNameUtils.toAbsolutePath(
53 |  |
                     this.contextRootPath, path);
54 | 0 |
             this.servletContext.log(this.getClass().getName() + ": '" + path
55 |  |
                     + "' ----> '" + realPath + "'");
56 | 0 |
             return realPath;
57 |  |
         }
58 |  |
59 |  |
         /**
60 |  |
          * @return
61 |  |
          */
62 | 0 |
         public String getContextRootPath() {
63 | 0 |
             return contextRootPath;
64 |  |
         }
65 |  |
66 |  |
         /**
67 |  |
          * @return
68 |  |
          */
69 | 0 |
         public ServletContext getServletContext() {
70 | 0 |
             return servletContext;
71 |  |
         }
72 |  |
73 |  |
     }