Source Code Cross Referenced for CSID.java in  » Portal » Open-Portal » soif » 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 » Portal » Open Portal » soif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *	CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003:         *	NETSCAPE COMMUNICATIONS CORPORATION
004:         *
005:         *	Copyright (c) 1996 Netscape Communications Corporation.
006:         *	All Rights Reserved.
007:         *	Use of this Source Code is subject to the terms of the applicable
008:         *	license agreement from Netscape Communications Corporation.
009:         */
010:
011:        package soif;
012:
013:        import util.AltSTokenizer;
014:        import util.ReportError;
015:
016:        import java.applet.Applet;
017:
018:        /**
019:         Encapsulate Compass Server ID.
020:         *
021:         */
022:        public class CSID {
023:            private int compass;
024:            private String host;
025:            private String port;
026:            private String name;
027:
028:            private final static int XCAT = 100;
029:            /**
030:             * Compass.
031:             */
032:            public final static int XCOMPASS = XCAT + 1;
033:            /**
034:             * Secure compass.
035:             */
036:            public final static int XCOMPASSS = XCAT + 2;
037:
038:            /**
039:             * Constructor.
040:             * @param compass only x-catalog or x-catalogs are valid
041:             * @param host blank not valid
042:             * @param port port number, if blank, defaults to 80
043:             * @param name target
044:             */
045:            public CSID(int compass, String host, String port, String name) {
046:                if (host == null) {
047:                    ReportError.reportError(ReportError.USER, "CSID", "CSID",
048:                            Messages.CSIDBADHOSTPARAM);
049:                } else if (host.length() == 0) {
050:                    ReportError.reportError(ReportError.USER, "CSID", "CSID",
051:                            Messages.CSIDBADHOSTPARAM);
052:                }
053:
054:                if (port == null) {
055:                    ReportError.reportError(ReportError.USER, "CSID", "CSID",
056:                            Messages.CSIDBADPORTPARAM);
057:                } else if (port.length() == 0) {
058:                    port = "80";
059:                }
060:
061:                if (name == null) {
062:                    ReportError.reportError(ReportError.USER, "CSID", "CSID",
063:                            Messages.CSIDBADNAMEPARAM);
064:                } else if (name.length() == 0) {
065:                    ReportError.reportError(ReportError.USER, "CSID", "CSID",
066:                            Messages.CSIDBADNAMEPARAM);
067:                }
068:
069:                this .compass = compass;
070:                this .host = host;
071:                this .port = port;
072:                this .name = name;
073:
074:            }
075:
076:            /**
077:             * Constructor.
078:             * @param urlStr send url string, examined to determine protocol
079:             * @param host blank not valid
080:             * @param port port number, if blank, defaults to 80
081:             * @param name target
082:             */
083:            public CSID(String urlStr, String host, String port, String name) {
084:                this (XCAT, host, port, name);
085:                setCompass(urlStr);
086:            }
087:
088:            /**
089:             * Constructor.  Parse a string version, protected so
090:             * we don't have to write a smart parse.
091:             * <b>Untested!</b>
092:             * @param s CSID in string form
093:             */
094:            public CSID(String csids) {
095:                String s;
096:
097:                AltSTokenizer ast = new AltSTokenizer(csids, ":/");
098:
099:                s = ast.nextToken();
100:                this .compass = stringToCompass(s);
101:                this .host = ast.nextToken();
102:                this .port = ast.nextToken();
103:                ast.nextChar();
104:                this .name = ast.nextToken("");
105:            }
106:
107:            /**
108:             * Set the compass type based on the URL.
109:             * @param urlStr send url string, examined to determine protocol
110:             */
111:            private void setCompass(String urlStr) {
112:
113:                if (urlStr.substring(0, 6).compareTo((String) "https:") == 0) {
114:                    int ndx;
115:
116:                    this .compass = XCOMPASSS;
117:                    ndx = urlStr.indexOf("/http:");
118:                    if (ndx > 0) {
119:                        this .compass = XCOMPASS;
120:                    }
121:                } else if (urlStr.substring(0, 5).compareTo((String) "http:") == 0) {
122:                    this .compass = XCOMPASS;
123:                }
124:            }
125:
126:            /**
127:             * Translate constant to string.
128:             * @param i constant
129:             */
130:            public static String compassToString(int i) {
131:                switch (i) {
132:                case XCOMPASS:
133:                    return "x-catalog";
134:                case XCOMPASSS:
135:                    return "x-catalogs";
136:                default:
137:                    return "Unknown Compass";
138:                }
139:            }
140:
141:            /**
142:             * Translate string to constant.
143:             * @param s string
144:             */
145:            public static int stringToCompass(String s) {
146:                if (s.compareTo((String) "x-catalog") == 0) {
147:                    return XCOMPASS;
148:                }
149:
150:                if (s.compareTo((String) "x-catalogs") == 0) {
151:                    return XCOMPASSS;
152:                }
153:
154:                return XCAT;
155:            }
156:
157:            /**
158:             * Is the instance valid?
159:             */
160:            public boolean isValid() {
161:                if ((compass != XCOMPASS) && (compass != XCOMPASSS)) {
162:                    return false;
163:                }
164:
165:                if (host == null) {
166:                    return false;
167:                }
168:                if (port == null) {
169:                    return false;
170:                }
171:                if (name == null) {
172:                    return false;
173:                }
174:
175:                if (host.length() == 0) {
176:                    return false;
177:                }
178:                if (port.length() == 0) {
179:                    return false;
180:                }
181:                if (name.length() == 0) {
182:                    return false;
183:                }
184:
185:                return true;
186:            }
187:
188:            /**
189:             * Get the compass.
190:             */
191:            public int getCompass() {
192:                return compass;
193:            }
194:
195:            /**
196:             * Get the host.
197:             */
198:            public String getHost() {
199:                return host;
200:            }
201:
202:            /**
203:             * Get the port.
204:             */
205:            public String getPort() {
206:                return port;
207:            }
208:
209:            /**
210:             * Get the name.
211:             */
212:            public String getName() {
213:                return name;
214:            }
215:
216:            /**
217:             * Secure?
218:             */
219:            public boolean isSecure() {
220:                return compass == XCOMPASSS;
221:            }
222:
223:            /**
224:             * Return valid CSID string.
225:             */
226:            public String toString() {
227:                return compassToString(compass) + "://" + host + ":" + port
228:                        + "/" + name;
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.