Source Code Cross Referenced for UriParser.java in  » Database-ORM » MMBase » org » mmbase » util » 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 » Database ORM » MMBase » org.mmbase.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:
03:        This software is OSI Certified Open Source Software.
04:        OSI Certified is a certification mark of the Open Source Initiative.
05:
06:        The license (Mozilla version 1.0) can be read at the MMBase site.
07:        See http://www.MMBase.org/license
08:
09:         */
10:
11:        package org.mmbase.util;
12:
13:        import org.mmbase.util.logging.Logger;
14:        import org.mmbase.util.logging.Logging;
15:
16:        /**
17:         * For an important part stolen from jakarta vfs (only one function).
18:         * @javadoc
19:         *
20:         * @author Michiel Meeuwissen
21:         * @since MMBase-1.7
22:         * @version $Id: UriParser.java,v 1.3 2004/09/30 17:19:50 pierre Exp $
23:         */
24:        public class UriParser {
25:
26:            private static final Logger log = Logging
27:                    .getLoggerInstance(UriParser.class);
28:
29:            final static char separatorChar = java.io.File.separator.charAt(0); // '\' for windows '/' for other oses.
30:
31:            /**
32:             * Converts an absolute path into a relative path.
33:             *
34:             * @param basePath The base path.
35:             * @param path The path to convert.
36:             */
37:            static public String makeRelative(final String basePath,
38:                    final String path) {
39:                if (log.isDebugEnabled()) {
40:                    log
41:                            .debug("converting " + path + " relative to "
42:                                    + basePath);
43:                }
44:                // Calculate the common prefix
45:                final int basePathLen = basePath.length();
46:                final int pathLen = path.length();
47:
48:                // Deal with root
49:                if (basePathLen == 1 && pathLen == 1) {
50:                    return ".";
51:                } else if (basePathLen == 1) {
52:                    return path.substring(1);
53:                }
54:
55:                final int maxlen = Math.min(basePathLen, pathLen);
56:                int pos = 0;
57:                for (; pos < maxlen && basePath.charAt(pos) == path.charAt(pos); pos++) {
58:                }
59:
60:                if (pos == basePathLen && pos == pathLen) {
61:                    // Same names
62:                    return ".";
63:                } else if (pos == basePathLen && pos < pathLen
64:                        && path.charAt(pos) == separatorChar) {
65:                    // A descendent of the base path
66:                    return path.substring(pos + 1);
67:                }
68:
69:                // Strip the common prefix off the path
70:                final StringBuffer buffer = new StringBuffer();
71:                if (pathLen > 1
72:                        && (pos < pathLen || basePath.charAt(pos) != separatorChar)) {
73:                    // Not a direct ancestor, need to back up
74:                    pos = basePath.lastIndexOf(separatorChar, pos);
75:                    buffer.append(path.substring(pos));
76:                }
77:
78:                // Prepend a '../' for each element in the base path past the common
79:                // prefix
80:                buffer.insert(0, "..");
81:                pos = basePath.indexOf(separatorChar, pos + 1);
82:                while (pos != -1) {
83:                    buffer.insert(0, "../");
84:                    pos = basePath.indexOf(separatorChar, pos + 1);
85:                }
86:                if (log.isDebugEnabled()) {
87:                    log.debug("is: " + buffer);
88:                }
89:
90:                return buffer.toString();
91:            }
92:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.