Source Code Cross Referenced for RequestLine.java in  » 6.0-JDK-Modules » j2me » gov » nist » siplite » header » 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.header 
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:        /*
026:         */
027:        package gov.nist.siplite.header;
028:
029:        import gov.nist.core.*;
030:        import gov.nist.siplite.address.*;
031:
032:        /**
033:         * RequestLine of SIP Request.
034:         *
035:         */
036:        public class RequestLine extends GenericObject {
037:
038:            /**
039:             * Uri field. Note that this can be a SIP URI or a generic URI
040:             * like tel URI.
041:             */
042:            protected URI uri;
043:
044:            /**
045:             * Method field.
046:             */
047:            protected String method;
048:
049:            /**
050:             * SipVersion field
051:             */
052:            protected String sipVersion;
053:
054:            /** Class handle. */
055:            public static Class clazz;
056:
057:            static {
058:                clazz = new RequestLine().getClass();
059:            }
060:
061:            /**
062:             * Default constructor.
063:             */
064:            public RequestLine() {
065:                sipVersion = "SIP/2.0";
066:            }
067:
068:            /**
069:             * Set the SIP version.
070:             * @param sipVersion -- the SIP version to set.
071:             */
072:            public void setSIPVersion(String sipVersion) {
073:                this .sipVersion = sipVersion;
074:            }
075:
076:            /**
077:             * Encodes the request line as a String.
078:             *
079:             * @return requestLine encoded as a string.
080:             */
081:            public String encode() {
082:                StringBuffer encoding = new StringBuffer();
083:                if (method != null) {
084:                    encoding.append(method);
085:                    encoding.append(Separators.SP);
086:                }
087:                if (uri != null) {
088:                    encoding.append(uri.encode());
089:                    encoding.append(Separators.SP);
090:                }
091:                encoding.append(sipVersion + Separators.NEWLINE);
092:                return encoding.toString();
093:            }
094:
095:            /**
096:             * Gets the Request-URI.
097:             * @return the request URI
098:             */
099:            public URI getUri() {
100:                return uri;
101:            }
102:
103:            /**
104:             * Constructor given the request URI and the method.
105:             * @param requestURI the request URI
106:             * @param method the operation to perform
107:             */
108:            public RequestLine(URI requestURI, String method) {
109:                this .uri = requestURI;
110:                this .method = method;
111:                this .sipVersion = "SIP/2.0";
112:            }
113:
114:            /**
115:             * Get the Method
116:             *
117:             * @return method string.
118:             */
119:            public String getMethod() {
120:                return method;
121:            }
122:
123:            /**
124:             * Get the SIP version.
125:             *
126:             * @return String
127:             */
128:            public String getSipVersion() {
129:                return sipVersion;
130:            }
131:
132:            /**
133:             * Set the uri member.
134:             * @param uri URI to set.
135:             */
136:            public void setUri(URI uri) {
137:                this .uri = uri;
138:            }
139:
140:            /**
141:             * Set the method member
142:             *
143:             * @param method String to set
144:             */
145:            public void setMethod(String method) {
146:                this .method = method;
147:            }
148:
149:            /**
150:             * Set the sipVersion member
151:             *
152:             * @param s String to set
153:             */
154:            public void setSipVersion(String s) {
155:                sipVersion = s;
156:            }
157:
158:            /**
159:             * Get the major verrsion number.
160:             *
161:             * @return String major version number
162:             */
163:            public String getVersionMajor() {
164:                if (sipVersion == null)
165:                    return null;
166:                String major = null;
167:                boolean slash = false;
168:                for (int i = 0; i < sipVersion.length(); i++) {
169:                    if (sipVersion.charAt(i) == '.')
170:                        break;
171:                    if (slash) {
172:                        if (major == null)
173:                            major = "" + sipVersion.charAt(i);
174:                        else
175:                            major += sipVersion.charAt(i);
176:                    }
177:                    if (sipVersion.charAt(i) == '/')
178:                        slash = true;
179:                }
180:                return major;
181:            }
182:
183:            /**
184:             * Get the minor version number.
185:             *
186:             * @return String minor version number
187:             *
188:             */
189:            public String getVersionMinor() {
190:                if (sipVersion == null)
191:                    return null;
192:                String minor = null;
193:                boolean dot = false;
194:                for (int i = 0; i < sipVersion.length(); i++) {
195:                    if (dot) {
196:                        if (minor == null)
197:                            minor = "" + sipVersion.charAt(i);
198:                        else
199:                            minor += sipVersion.charAt(i);
200:                    }
201:                    if (sipVersion.charAt(i) == '.')
202:                        dot = true;
203:                }
204:                return minor;
205:            }
206:
207:            /**
208:             * Compare for equality.
209:             *
210:             * @param other object to compare with. We assume that all fields
211:             * are set.
212:             * @return true if the object matches
213:             */
214:            public boolean equals(Object other) {
215:                boolean retval;
216:                if (!other.getClass().equals(this .getClass())) {
217:                    return false;
218:                }
219:                RequestLine that = (RequestLine) other;
220:                try {
221:                    retval = this .method.equals(that.method)
222:                            && this .uri.equals(that.uri)
223:                            && this .sipVersion.equals(that.sipVersion);
224:                } catch (NullPointerException ex) {
225:                    retval = false;
226:                }
227:                return retval;
228:
229:            }
230:
231:            /**
232:             * Clone this request.
233:             * @return copt of the current object
234:             */
235:            public Object clone() {
236:                RequestLine retval = new RequestLine();
237:                if (this .uri != null)
238:                    retval.uri = (URI) this .uri.clone();
239:                if (this .method != null)
240:                    retval.method = new String(this .method);
241:                if (this .sipVersion != null)
242:                    retval.sipVersion = new String(this .sipVersion);
243:                return (Object) retval;
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.