KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > modules > actions > portlets > designer > FormatPath


1 /*
2  * Copyright 2000-2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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 JavaDoc normalizeDirectoryPath(String JavaDoc path)
39     {
40         if (path == null)
41         {
42             return path;
43         }
44         // convert all backslashes with normalized forward
45
String JavaDoc resultPath = path.replace('\\', '/');
46         if (!resultPath.endsWith("/"))
47         {
48             return resultPath.concat("/");
49         }
50         return resultPath;
51     }
52
53 }
Popular Tags