Source Code Cross Referenced for URI.java in  » 6.0-JDK-Modules » j2me » gov » nist » siplite » address » 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 » 6.0 JDK Modules » j2me » gov.nist.siplite.address 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Portions Copyright  2000-2007 Sun Microsystems, Inc. All Rights
003:         * Reserved.  Use is subject to license terms.
004:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
005:         * 
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License version
008:         * 2 only, as published by the Free Software Foundation.
009:         * 
010:         * This program is distributed in the hope that it will be useful, but
011:         * WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * General Public License version 2 for more details (a copy is
014:         * included at /legal/license.txt).
015:         * 
016:         * You should have received a copy of the GNU General Public License
017:         * version 2 along with this work; if not, write to the Free Software
018:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
019:         * 02110-1301 USA
020:         * 
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
022:         * Clara, CA 95054 or visit www.sun.com if you need additional
023:         * information or have any questions.
024:         */
025:        package gov.nist.siplite.address;
026:
027:        import gov.nist.core.*;
028:        import gov.nist.siplite.SIPConstants;
029:
030:        /**
031:         * Implementation of the URI class.
032:         *
033:         *
034:         * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
035:         */
036:        public class URI extends GenericObject {
037:            /** POST Dial method label text. */
038:            public static final String POSTDIAL = SIPConstants.GENERAL_POSTDIAL;
039:            /** Phone context parameter label text. */
040:            public static final String PHONE_CONTEXT_TAG = SIPConstants.GENERAL_PHONE_CONTEXT_TAG;
041:            /** ISDN subaddress parameter label text. */
042:            public static final String ISUB = SIPConstants.GENERAL_ISUB;
043:            /** Provider parameter label text. */
044:            public static final String PROVIDER_TAG = SIPConstants.GENERAL_PROVIDER_TAG;
045:            /** User name parameter label text. */
046:            public static final String USER = SIPConstants.GENERAL_USER;
047:            /** Transport type parameter label text. */
048:            public static final String TRANSPORT = SIPConstants.GENERAL_TRANSPORT;
049:            /** Method name parameter label text. */
050:            public static final String METHOD = SIPConstants.GENERAL_METHOD;
051:            /** Time to live parameter label text. */
052:            public static final String TTL = SIPConstants.GENERAL_TTL;
053:            /** Mail address parameter label text. */
054:            public static final String MADDR = SIPConstants.GENERAL_MADDR;
055:            /** LR parameter label text. */
056:            public static final String LR = SIPConstants.GENERAL_LR;
057:
058:            /**
059:             * Imbedded URI.
060:             */
061:            protected String uriString;
062:            /** Current URI scheme. */
063:            protected String scheme;
064:
065:            /**
066:             * Constuctor.
067:             */
068:            protected URI() {
069:            }
070:
071:            /**
072:             * Constructor given the URI string.
073:             * @param uriString The imbedded URI string.
074:             * @throws URISyntaxException When there is a syntaz error in the
075:             * imbedded URI.
076:             */
077:            public URI(String uriString) throws ParseException {
078:                try {
079:                    this .uriString = uriString;
080:                    int colPos = uriString.indexOf(":");
081:
082:                    if (colPos == -1) { // no ":"
083:                        throw new ParseException(
084:                                "URI, no separator after scheme", 0);
085:                    }
086:
087:                    // Don't check the scheme's name, because according
088:                    // to the RFC 3261, p. 224 it may be almost any token,
089:                    // not only 'sip' and 'sips'.
090:
091:                    // rfc3261: when symbol '@' is present in URI, user part
092:                    // can't be empty
093:                    String uriCutScheme = uriString.substring(colPos + 1);
094:                    int symAtPos = uriCutScheme.indexOf("@");
095:
096:                    if (symAtPos == 0) { // first symbol is '@'
097:                        throw new ParseException("URI, no user part", 0);
098:                    }
099:                } catch (Throwable e) {
100:                    throw new ParseException("URI, Bad URI format", 0);
101:                }
102:            }
103:
104:            /**
105:             * Encode the URI.
106:             * @return The encoded URI
107:             */
108:            public String encode() {
109:                return uriString;
110:            }
111:
112:            /**
113:             * Encodes this URI.
114:             * @return The encoded URI
115:             */
116:            public String toString() {
117:                return this .encode();
118:            }
119:
120:            /**
121:             * Returns the URI part of the address (without parameters)
122:             * i.e. scheme:user@host:port.
123:             * @return URI part of the address
124:             */
125:            public String getPlainURI() {
126:                return encode();
127:            }
128:
129:            /**
130:             * Overrides the base clone method.
131:             * @return The Cloned strucutre,
132:             */
133:            public Object clone() {
134:                try {
135:                    return new URI(this .uriString);
136:                } catch (ParseException ex) {
137:                    throw new RuntimeException(ex.getMessage() + this .uriString);
138:                }
139:            }
140:
141:            /**
142:             * Returns the value of the "scheme" of
143:             * this URI, for example "sip", "sips" or "tel".
144:             *
145:             * @return the scheme paramter of the URI
146:             */
147:            public String getScheme() {
148:                return scheme;
149:            }
150:
151:            /**
152:             * Sets the value of the "scheme" of
153:             * this URI, for example "sip", "sips" or "tel".
154:             *
155:             * Ref. RFC 3261, p. 224:
156:             *     scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
157:             *
158:             * @param sch the scheme of this URI
159:             * @throws IllegalArgumentException if the scheme is invalid
160:             */
161:            public void setScheme(String sch) throws IllegalArgumentException {
162:                final String errMsg = "Invalid scheme format";
163:                char ch;
164:
165:                // Check if the scheme is valid
166:                if (sch == null || !StringTokenizer.isAlpha(sch.charAt(0))) {
167:                    throw new IllegalArgumentException(errMsg);
168:                }
169:
170:                for (int i = 1; i < sch.length(); i++) {
171:                    ch = sch.charAt(i);
172:
173:                    if (!StringTokenizer.isAlpha(ch)
174:                            && !StringTokenizer.isDigit(ch) && (ch != '+')
175:                            && (ch != '-') && (ch != '.')) {
176:                        throw new IllegalArgumentException(errMsg);
177:                    }
178:                }
179:
180:                scheme = sch;
181:            }
182:
183:            /**
184:             * This method determines if this is a URI with a scheme of
185:             * "sip" or "sips".
186:             *
187:             * @return true if the scheme is "sip" or "sips", false otherwise.
188:             */
189:            public boolean isSipURI() {
190:                return this  instanceof  SipURI;
191:
192:            }
193:
194:            /**
195:             * This method determines if this is a URI with a scheme of
196:             * "tel"
197:             *
198:             * @return true if the scheme is "tel", false otherwise.
199:             */
200:            public boolean isTelURL() {
201:                return this  instanceof  TelURL;
202:            }
203:
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.