Source Code Cross Referenced for CSeqHeader.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:
031:        /**
032:         * CSeqHeader SIP Header.
033:         *
034:         *
035:         * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
036:         *
037:         * @version JAIN-SIP-1.1
038:         *
039:         */
040:
041:        public class CSeqHeader extends ParameterLessHeader {
042:            /** Class handle. */
043:            public static Class clazz;
044:
045:            /** Sequence header. */
046:            public static final String NAME = Header.CSEQ;
047:
048:            static {
049:                clazz = new CSeqHeader().getClass();
050:            }
051:
052:            /**
053:             * seqno field
054:             */
055:            protected Integer seqno;
056:
057:            /**
058:             * method field
059:             */
060:            protected String method;
061:
062:            /**
063:             * Constructor.
064:             */
065:            public CSeqHeader() {
066:                super (CSEQ);
067:            }
068:
069:            /**
070:             * Constructor given the sequence number and method.
071:             *
072:             * @param seqno is the sequence number to assign.
073:             * @param method is the method string.
074:             */
075:            public CSeqHeader(int seqno, String method) {
076:                this ();
077:                this .seqno = new Integer(seqno);
078:                this .method = method;
079:            }
080:
081:            /**
082:             * Compare two cseq headers for equality.
083:             * @param other Object to compare against.
084:             * @return true if the two cseq headers are equals, false
085:             * otherwise.
086:             */
087:            public boolean equals(Object other) {
088:                if (!other.getClass().equals(this .getClass())) {
089:                    return false;
090:                }
091:                CSeqHeader that = (CSeqHeader) other;
092:                if (!this .seqno.equals(that.seqno)) {
093:                    return false;
094:                }
095:                if (!equalsIgnoreCase(this .method, that.method)) {
096:                    return false;
097:                }
098:                return true;
099:            }
100:
101:            /**
102:             * Return canonical header content. (encoded header except headerName:)
103:             *
104:             * @return encoded string.
105:             */
106:            public String encodeBody() {
107:                return seqno + Separators.SP + method.toUpperCase();
108:            }
109:
110:            /**
111:             * Get the method.
112:             * @return String the method.
113:             */
114:            public String getMethod() {
115:                return method.toUpperCase();
116:            }
117:
118:            /**
119:             * Sets the sequence number of this CSeqHeaderHeader. The sequence number
120:             * MUST be expressible as a 32-bit unsigned integer and MUST be less than
121:             * 2**31.
122:             *
123:             * @param sequenceNumber - the sequence number to set.
124:             * @throws InvalidArgumentException -- if the seq number is <= 0
125:             */
126:            public void setSequenceNumber(int sequenceNumber) {
127:                if (sequenceNumber < 0)
128:                    throw new IllegalArgumentException(
129:                            "the sequence number parameter is < 0");
130:                seqno = new Integer(sequenceNumber);
131:            }
132:
133:            /**
134:             * Set the method member
135:             *
136:             * @param meth -- String to set
137:             */
138:            public void setMethod(String meth) {
139:                if (meth == null)
140:                    throw new NullPointerException("parameter is null");
141:                method = meth;
142:            }
143:
144:            /**
145:             * Gets the sequence number of this CSeqHeaderHeader.
146:             *
147:             * @return sequence number of the CSeqHeaderHeader
148:             */
149:
150:            public int getSequenceNumber() {
151:                if (this .seqno == null)
152:                    return 0;
153:                else
154:                    return this .seqno.intValue();
155:            }
156:
157:            /**
158:             * Copies the current instance.
159:             * @return copy of current object
160:             */
161:            public Object clone() {
162:                CSeqHeader retval = new CSeqHeader();
163:
164:                if (this .seqno != null)
165:                    retval.seqno = new Integer(this .seqno.intValue());
166:                retval.method = this .method;
167:
168:                return retval;
169:            }
170:
171:            /**
172:             * Gets the header value.
173:             * @return the header value
174:             */
175:            public Object getValue() {
176:                return seqno + Separators.SP + method.toUpperCase();
177:            }
178:
179:            /**
180:             * Sets the header value field.
181:             * @param value is the value field to set.
182:             * @throws IllegalArgumentException if the value is invalid.
183:             */
184:            public void setHeaderValue(String value)
185:                    throws IllegalArgumentException {
186:                int newSeqNo;
187:                String newMethod;
188:
189:                value = value.trim();
190:
191:                // Check if the sequence number presents
192:                int delimIndex = value.indexOf(' ');
193:
194:                if (delimIndex == -1) {
195:                    // IMPL_NOTE: set some flag to indicate that
196:                    //       the Sequence Number is not set.
197:                    setMethod(value.trim());
198:                    return;
199:                }
200:
201:                try {
202:                    String strNum = value.substring(0, delimIndex).trim();
203:                    newSeqNo = Integer.parseInt(strNum);
204:                    setSequenceNumber(newSeqNo);
205:                } catch (IllegalArgumentException iae) {
206:                    throw iae;
207:                }
208:
209:                newMethod = value.substring(delimIndex, value.length()).trim();
210:                setMethod(newMethod);
211:            }
212:
213:            /**
214:             * Gets the parameters.
215:             * @return name value list
216:             */
217:            public NameValueList getParameters() {
218:                return null;
219:            }
220:
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.