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: | 101 |  | Methods: | 10
| NCLOC: | 56 |  | 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
PathPointer.java | 100% | 82.6% | 60% | 79.5% |

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/15
7 |  |
      */
8 |  |
     package org.asyrinx.brownie.core.io;
9 |  |
10 |  |
     import java.io.File;
11 |  |
     import java.util.ArrayList;
12 |  |
     import java.util.Iterator;
13 |  |
     import java.util.List;
14 |  |
15 |  |
     import org.asyrinx.brownie.core.lang.StringUtils;
16 |  |
17 |  |
     /**
18 |  |
      * 相対パス、絶対パスなどに限らずパス名が指す位置を表すクラスです。
19 |  |
      *
20 |  |
      * @author akima
21 |  |
      * @see org.asyrinx.brownie.core.io.FileNameUtils
22 |  |
      */
23 |  |
     public class PathPointer {
24 |  |
25 |  |
         /**
26 |  |
          *
27 |  |
          */
28 | 0 |
         public PathPointer() {
29 | 0 |
             super();
30 |  |
         }
31 |  |
32 |  |
         /**
33 |  |
          *
34 |  |
          */
35 | 12 |
         public PathPointer(String path) {
36 | 12 |
             super();
37 | 12 |
             setPath(path);
38 |  |
         }
39 |  |
40 |  |
         /**
41 |  |
          *
42 |  |
          */
43 | 0 |
         public PathPointer(File file) {
44 | 0 |
             this(file.getPath());
45 |  |
         }
46 |  |
47 |  |
         private final List dirList = new ArrayList();
48 |  |
49 |  |
         private String separator = FileConstants.FILE_SPARATOR_SLASH;
50 |  |
51 |  |
         /**
52 |  |
          * @return
53 |  |
          */
54 | 17 |
         public String getPath() {
55 | 17 |
             return StringUtils.join(this.dirList.iterator(), this.separator);
56 |  |
         }
57 |  |
58 |  |
         /**
59 |  |
          * @param string
60 |  |
          */
61 | 13 |
         public void setPath(String path) {
62 | 13 |
             dirList.clear();
63 | 13 |
             path = FileNameUtils.deleteSeparatorTail(path);
64 | 13 |
             this.separator = FileNameUtils.getFileSeparator(path);
65 | 13 |
             StringUtils.tokenize(dirList, path, this.separator);
66 |  |
         }
67 |  |
68 | 0 |
         public File toFile() {
69 | 0 |
             return new File(getPath());
70 |  |
         }
71 |  |
72 | 14 |
         public void moveTo(String relativePath) {
73 | 14 |
             changeImpl(relativePath);
74 |  |
         }
75 |  |
76 | 5 |
         public void goUp() {
77 | 5 |
             changeImpl(FileConstants.DIRECTORY_PARENT);
78 |  |
         }
79 |  |
80 | 0 |
         public void goDown(String directoryName) {
81 | 0 |
             changeImpl(directoryName);
82 |  |
         }
83 |  |
84 | 19 |
         protected void changeImpl(String relativePath) {
85 | 19 |
             final String path = FileNameUtils.toFileSeparatorSlash(FileNameUtils
86 |  |
                     .deleteSeparatorHead(relativePath));
87 | 19 |
             final List pathList = StringUtils.tokenize(path,
88 |  |
                     FileConstants.FILE_SPARATOR_SLASH);
89 | 19 |
             final Iterator iterator = pathList.iterator();
90 | 19 |
             while (iterator.hasNext()) {
91 | 40 |
                 final String dir = (String) iterator.next();
92 | 40 |
                 if (dir.equals(FileConstants.DIRECTORY_CURRENT))
93 | 3 |
                     continue;
94 | 37 |
                 if (dir.equals(FileConstants.DIRECTORY_PARENT))
95 | 11 |
                     this.dirList.remove(this.dirList.size() - 1);
96 |  |
                 else
97 | 26 |
                     this.dirList.add(dir);
98 |  |
             }
99 |  |
         }
100 |  |
101 |  |
     }