1 /*
2 * $Id: PathUtil.java,v 1.1 2007/10/30 13:46:41 oeuillot Exp $
3 */
4 package org.rcfaces.core.internal.util;
5
6 import org.apache.commons.logging.Log;
7 import org.apache.commons.logging.LogFactory;
8
9 /**
10 *
11 * @author Olivier Oeuillot (latest modification by $Author: oeuillot $)
12 * @version $Revision: 1.1 $ $Date: 2007/10/30 13:46:41 $
13 */
14 public class PathUtil {
15
16 private static final String REVISION = "$Revision: 1.1 $";
17
18 private static final Log LOG = LogFactory.getLog(PathUtil.class);
19
20 public static String normalizePath(String path) {
21
22 IPath p = new Path(path);
23
24 return p.toString();
25 /*
26 * boolean modified = false;
27 *
28 * StringTokenizer st = new StringTokenizer(path, "/", true);
29 *
30 * List l = new ArrayList((st.countTokens() / 2) + 1); boolean sep =
31 * true; for (; st.hasMoreTokens();) { String segment = st.nextToken();
32 * if (segment.equals("/")) { if (sep) { sep = false; continue; }
33 * modified = true; continue; } sep = true; l.add(segment); }
34 *
35 * for (int i = 0; i < l.size();) { String segment = (String) l.get(i);
36 *
37 * if (segment.equals("..")) { modified = true;
38 *
39 * l.remove(i); if (i < 1) { continue; }
40 *
41 * i--; l.remove(i); continue; }
42 *
43 * if (segment.equals(".")) { modified = true;
44 *
45 * l.remove(i); continue; }
46 *
47 * i++; }
48 *
49 * if (modified == false) { return path; }
50 *
51 * StringAppender sa = new StringAppender(path.length()); for (Iterator
52 * it = l.iterator(); it.hasNext();) { sa.append('/');
53 * sa.append((String) it.next()); }
54 *
55 * return sa.toString();
56 */
57 }
58 }