1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.modules.actions.portlets.designer;
17
18 /***
19 * Utility for formatting paths
20 *
21 * @author <a href="mailto:jlim@gluecode.com">Jonas Lim</a>
22 * @version $Id: FormatPath.java,v 1.1 2004/03/10 22:53:59 taylor Exp $
23 */
24 public class FormatPath
25 {
26
27 public FormatPath()
28 {
29 }
30
31 /***
32 * Given a directory path with Windows or Unix file separators,
33 * normalize to use Unix style separators and always
34 * append a final separator for the directory.
35 * @param path
36 * @return
37 */
38 public static String normalizeDirectoryPath(String path)
39 {
40 if (path == null)
41 {
42 return path;
43 }
44
45 String resultPath = path.replace('//', '/');
46 if (!resultPath.endsWith("/"))
47 {
48 return resultPath.concat("/");
49 }
50 return resultPath;
51 }
52
53 }