Source Code Cross Referenced for ComponentPath.java in  » Content-Management-System » contelligent » de » finix » contelligent » client » base » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » contelligent » de.finix.contelligent.client.base 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2006 C:1 Financial Services GmbH
003:         *
004:         * This software is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License Version 2.1, as published by the Free Software Foundation.
007:         *
008:         * This software is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011:         * Lesser General Public License for more details.
012:         *
013:         * You should have received a copy of the GNU Lesser General Public
014:         * License along with this library; if not, write to the Free Software
015:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016:         */
017:
018:        package de.finix.contelligent.client.base;
019:
020:        /**
021:         * Helper class for component path conversions. Logically belongs to
022:         * {@link ContelligentComponent}, but has been encapsulated here. <br>
023:         * This class is used to implement component path related helper methods like
024:         * converting a server component path (with trailing slash) to a client
025:         * component path (w/o. trailing slash) or extracting the component name and the
026:         * component dir from a given component path...
027:         */
028:        final public class ComponentPath {
029:
030:            public final static char SEPARATOR = '/';
031:
032:            /**
033:             * Extract path in client fashion.
034:             * 
035:             * @param path
036:             *            the full qulified path
037:             * @return component's dir in server fashion, <code>null</code> path is
038:             *         <code>null</code> or root path if path is empty or root path.
039:             */
040:            public static String toComponentPath(String path) {
041:                return ComponentPath.toClientComponentPath(path);
042:            }
043:
044:            /**
045:             * Extract path in client fashion.
046:             * 
047:             * @param path
048:             *            the full qulified path
049:             * @return component's dir in server fashion, <code>null</code> path is
050:             *         <code>null</code> or root path if path is empty or root path.
051:             */
052:            public static String toClientComponentPath(String path) {
053:
054:                if (path == null) {
055:                    return null;
056:                } else if (path.equals("")
057:                        || path.equals(String.valueOf(ComponentPath.SEPARATOR))) {
058:                    return String.valueOf(ComponentPath.SEPARATOR);
059:                } else {
060:                    // strip off following separator
061:                    int lastCharPos = path.length() - 1;
062:                    if (path.charAt(lastCharPos) == ComponentPath.SEPARATOR) {
063:                        return path.substring(0, lastCharPos);
064:                    } else {
065:                        return path;
066:                    }
067:                }
068:            }
069:
070:            /**
071:             * Extract path in server fashion.
072:             * 
073:             * @param path
074:             *            the full qulified path
075:             * @return component's dir in server fashion, <code>null</code> path is
076:             *         <code>null</code> or root path if path is empty or root path.
077:             */
078:            public static String toServerComponentPath(String path) {
079:
080:                String clientComponentPath = ComponentPath
081:                        .toClientComponentPath(path);
082:
083:                if (clientComponentPath == null) {
084:                    return null;
085:                } else if (clientComponentPath.equals(String
086:                        .valueOf(ComponentPath.SEPARATOR))) {
087:                    return clientComponentPath;
088:                } else {
089:                    return (clientComponentPath + ComponentPath.SEPARATOR);
090:                }
091:            }
092:
093:            /**
094:             * Extract dir in client fashion.
095:             * 
096:             * @param path
097:             *            the full qulified path
098:             * @return component's dir in server fashion, <code>null</code> path is
099:             *         <code>null</code> or root path if path is empty or root path.
100:             */
101:            public static String getComponentDir(String path) {
102:                return ComponentPath.getClientComponentDir(path);
103:            }
104:
105:            /**
106:             * Extract dir in client fashion.
107:             * 
108:             * @param path
109:             *            the full qulified path
110:             * @return component's dir in server fashion, <code>null</code> path is
111:             *         <code>null</code> or root path if path is empty or root path.
112:             */
113:            public static String getClientComponentDir(String path) {
114:
115:                if (path == null) {
116:                    return null;
117:                } else if (path.equals("")
118:                        || path.equals(String.valueOf(ComponentPath.SEPARATOR))) {
119:                    return String.valueOf(ComponentPath.SEPARATOR);
120:                } else {
121:                    // first make it a client path to handle the case that a server path
122:                    // is passed
123:                    // e.g. "/path/thisIsTheComponent/" transforms to
124:                    // "/path/thisIsTheComponent"
125:                    path = ComponentPath.toComponentPath(path);
126:                    int lastSep = path.lastIndexOf(ComponentPath.SEPARATOR);
127:                    if (lastSep == -1 || lastSep == 0) {
128:                        return String.valueOf(ComponentPath.SEPARATOR);
129:                    } else {
130:                        return path.substring(0, lastSep);
131:                    }
132:                }
133:            }
134:
135:            /**
136:             * Extract dir in server fashion.
137:             * 
138:             * @param path
139:             *            the full qulified path
140:             * @return component's dir in server fashion, <code>null</code> path is<code>null</code>
141:             *         or root path if path is empty or root path.
142:             */
143:            public static String getServerComponentDir(String path) {
144:
145:                String clientComponentDir = ComponentPath
146:                        .getClientComponentDir(path);
147:
148:                if (clientComponentDir == null) {
149:                    return null;
150:                } else if (clientComponentDir.equals(String
151:                        .valueOf(ComponentPath.SEPARATOR))) {
152:                    return clientComponentDir;
153:                } else {
154:                    return (clientComponentDir + ComponentPath.SEPARATOR);
155:                }
156:            }
157:
158:            /**
159:             * Extract the component's name.
160:             * 
161:             * @param path
162:             *            the full qulified path
163:             * @return component's name or <code>null</code> if path contains no
164:             *         component
165:             */
166:            public static String getComponentName(String path) {
167:
168:                // empty or root path
169:                if (path == null || path.equals("")
170:                        || path.equals(String.valueOf(ComponentPath.SEPARATOR))) {
171:                    return null;
172:                } else {
173:                    // first make it a client path to handle the case that a server path
174:                    // is passed
175:                    // e.g. "/path/thisIsTheComponent/" transforms to
176:                    // "/path/thisIsTheComponent"
177:                    path = ComponentPath.toComponentPath(path);
178:                    int lastSep = path.lastIndexOf(ComponentPath.SEPARATOR);
179:                    if (lastSep == -1) {
180:                        // as there is no separator the path is the component itself
181:                        return path;
182:                    } else {
183:                        return path.substring(lastSep + 1);
184:                    }
185:                }
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.