Source Code Cross Referenced for Utility.java in  » Workflow-Engines » pegasus-2.1.0 » org » griphyn » cPlanner » common » 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 » Workflow Engines » pegasus 2.1.0 » org.griphyn.cPlanner.common 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * This file or a portion of this file is licensed under the terms of
003:         * the Globus Toolkit Public License, found at $PEGASUS_HOME/GTPL or
004:         * http://www.globus.org/toolkit/download/license.html.
005:         * This notice must appear in redistributions of this file
006:         * with or without modification.
007:         *
008:         * Redistributions of this Software, with or without modification, must reproduce
009:         * the GTPL in:
010:         * (1) the Software, or
011:         * (2) the Documentation or
012:         * some other similar material which is provided with the Software (if any).
013:         *
014:         * Copyright 1999-2004
015:         * University of Chicago and The University of Southern California.
016:         * All rights reserved.
017:         */package org.griphyn.cPlanner.common;
018:
019:        import java.net.URL;
020:
021:        import java.util.StringTokenizer;
022:
023:        /**
024:         * A utility class that contains a few common utility/helper functions used in
025:         * Pegasus. At present they are preliminary URL decomposition functions.
026:         *
027:         *
028:         * @author Karan Vahi
029:         * @author Gaurang Mehta
030:         * @version $Revision: 50 $
031:         */
032:        public class Utility {
033:
034:            /**
035:             * This returns the host name of the server, given a url prefix.
036:             *
037:             * @param urlPrefix  the urlPrefix of the server.
038:             * @return String
039:             */
040:            public static String getHostName(String urlPrefix) {
041:                StringTokenizer st = new StringTokenizer(urlPrefix);
042:                String hostName = new String();
043:                String token = new String();
044:                int count = 0;
045:
046:                while (st.hasMoreTokens()) {
047:                    token = st.nextToken("/");
048:                    count++;
049:                    if (count == 2) {
050:                        hostName = token.trim();
051:                        //System.out.println("host name " + hostName);
052:                        return hostName;
053:                    }
054:
055:                }
056:                return hostName;
057:
058:            }
059:
060:            /**
061:             * Prunes the url prefix to ensure that only the url prefix as wanted
062:             * by Pegasus goes through. This is due to the different manner in which
063:             * url prefix was used earlier.
064:             *
065:             * For e.g the function when passed a url
066:             * gsiftp://dataserver.phys.uwm.edu/~/griphyn_test/ligodemo_output/
067:             * returns url gsiftp://dataserver.phys.uwm.edu.
068:             *
069:             * @param url  the url prefix.
070:             * @return String
071:             */
072:            public static String pruneURLPrefix(String url) {
073:                String hostName = getHostName(url);
074:                url = url.substring(0,
075:                        url.lastIndexOf(hostName) + hostName.length()).trim();
076:
077:                return url;
078:
079:            }
080:
081:            /**
082:             * It returns the absolute path of the url. The absolute path is the
083:             * directory path in the URL. In the GVDS lingo, it refers to the mount
084:             * points too.
085:             *
086:             * @param url String
087:             * @return String
088:             */
089:            public static String getAbsolutePath(String url) {
090:                String hostName = null;
091:                URL u = null;
092:
093:                //try using the java url class to get mount point
094:                try {
095:                    u = new URL(url);
096:                } catch (Exception e) {
097:                    //the url seems to be malformed. could be the gsiftp trigger
098:                    u = null;
099:                    //use our own method to get the url
100:                    hostName = getHostName(url);
101:                }
102:                return (u == null) ?
103:                //try to do some inhouse magic
104:                url.substring(url.lastIndexOf(hostName) + hostName.length())
105:                        .trim()
106:                        :
107:                        //malformed execption caught. most probably due to
108:                        //invalid protocol/schema
109:                        u.getPath();
110:            }
111:
112:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.