Source Code Cross Referenced for SipCommHop.java in  » Net » openfire » org » jivesoftware » openfire » sip » tester » stack » 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 » Net » openfire » org.jivesoftware.openfire.sip.tester.stack 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * $RCSfile$
003:         * $Revision: $
004:         * $Date: $
005:         *
006:         * Copyright (C) 2007 Jive Software. All rights reserved.
007:         *
008:         * This software is published under the terms of the GNU Public License (GPL),
009:         * a copy of which is included in this distribution.
010:         */package org.jivesoftware.openfire.sip.tester.stack;
011:
012:        import org.jivesoftware.openfire.sip.tester.Log;
013:
014:        import java.util.StringTokenizer;
015:
016:        /**
017:         * Routing algorithms return a list of hops to which the request is routed.
018:         *
019:         * @author M. Ranganathan <mranga@nist.gov> <br/> <a href=" {@docRoot}
020:         *         /uncopyright.html">This code is in the public domain.</a> IPv6
021:         *         Support added by Emil Ivov (emil_ivov (at) yahoo (dot) com)<br/>
022:         *         Network Research Team (http://www-r2.u-strasbg.fr))<br/> Louis
023:         *         Pasteur University - Strasbourg - France<br/>
024:         * @version JAIN-SIP-1.1
025:         */
026:        public class SipCommHop implements  javax.sip.address.Hop {
027:
028:            protected String host;
029:            protected int port;
030:            protected String transport;
031:            protected boolean explicitRoute; // this is generated from a ROUTE
032:            protected boolean defaultRoute; // This is generated from the proxy addr
033:            protected boolean uriRoute; // This is extracted from the requestURI.
034:
035:            /**
036:             * Debugging println.
037:             */
038:            public String toString() {
039:                return host + ":" + port + "/" + transport;
040:            }
041:
042:            /**
043:             * Create new hop given host, port and transport.
044:             *
045:             * @param hostName   hostname
046:             * @param portNumber port
047:             * @param trans      transport
048:             */
049:            public SipCommHop(String hostName, int portNumber, String trans) {
050:                host = hostName;
051:                port = portNumber;
052:                transport = trans;
053:            }
054:
055:            /**
056:             * Creates new Hop
057:             *
058:             * @param hop is a hop string in the form of host:port/Transport
059:             * @throws IllegalArgumentException exception if string is not properly formatted or null.
060:             */
061:            public SipCommHop(String hop) throws IllegalArgumentException {
062:                if (hop == null) {
063:                    Log.debug("SipCommHop", "Null arg: " + hop);
064:                    throw new IllegalArgumentException("Null arg!");
065:                }
066:                StringTokenizer stringTokenizer = new StringTokenizer(hop + "/");
067:                String hostPort = stringTokenizer.nextToken("/").trim();
068:                transport = stringTokenizer.nextToken().trim();
069:
070:                if (transport == null) {
071:                    transport = "UDP";
072:                } else if (transport == "") {
073:                    transport = "UDP";
074:                }
075:                if (transport.compareToIgnoreCase("UDP") != 0
076:                        && transport.compareToIgnoreCase("TCP") != 0) {
077:                    throw new IllegalArgumentException(hop);
078:                }
079:                String portString = null;
080:                // IPv6 hostport
081:                if (hostPort.charAt(0) == '[') {
082:                    int rightSqBrackIndex = hostPort.indexOf(']');
083:                    if (rightSqBrackIndex == -1) {
084:                        throw new IllegalArgumentException(
085:                                "Bad IPv6 reference spec");
086:                    }
087:                    host = hostPort.substring(0, rightSqBrackIndex + 1);
088:                    int portColon = hostPort.indexOf(':', rightSqBrackIndex);
089:                    if (portColon != -1) {
090:                        try {
091:                            portString = hostPort.substring(portColon + 1)
092:                                    .trim();
093:                        } catch (IndexOutOfBoundsException exc) {
094:                            // Do nothing - handled later
095:                        }
096:                    }
097:                }
098:                // IPv6 address and no port
099:                else if (hostPort.indexOf(':') != hostPort.lastIndexOf(":")) {
100:                    host = '[' + hostPort + ']';
101:                } else { // no square brackets and a single or zero colons => IPv4
102:                    // hostPort
103:                    int portColon = hostPort.indexOf(':');
104:                    if (portColon == -1) {
105:                        host = hostPort;
106:                    } else {
107:                        host = hostPort.substring(0, portColon).trim();
108:                        try {
109:                            portString = hostPort.substring(portColon + 1)
110:                                    .trim();
111:                        } catch (IndexOutOfBoundsException exc) {
112:                            // Do nothing - handled later
113:                        }
114:                    }
115:                }
116:                if (host == null || host.equals("")) {
117:                    throw new IllegalArgumentException("no host!");
118:                }
119:                if (portString == null || portString.equals("")) {
120:                    port = 5060;
121:                } else {
122:                    try {
123:                        port = Integer.parseInt(portString);
124:                    } catch (NumberFormatException ex) {
125:                        throw new IllegalArgumentException("Bad port spec");
126:                    }
127:                }
128:            }
129:
130:            /**
131:             * Retruns the host string.
132:             *
133:             * @return host String
134:             * @uml.property name="host"
135:             */
136:            public String getHost() {
137:                return host;
138:            }
139:
140:            /**
141:             * Returns the port.
142:             *
143:             * @return port integer.
144:             * @uml.property name="port"
145:             */
146:            public int getPort() {
147:                return port;
148:            }
149:
150:            /**
151:             * returns the transport string.
152:             *
153:             * @uml.property name="transport"
154:             */
155:            public String getTransport() {
156:                return transport;
157:            }
158:
159:            /**
160:             * Return true if this is an explicit route (ie. extrcted from a ROUTE
161:             * Header)
162:             *
163:             * @uml.property name="explicitRoute"
164:             */
165:            public boolean isExplicitRoute() {
166:                return explicitRoute;
167:            }
168:
169:            /**
170:             * Return true if this is a default route (ie. next hop proxy address)
171:             *
172:             * @uml.property name="defaultRoute"
173:             */
174:            public boolean isDefaultRoute() {
175:                return defaultRoute;
176:            }
177:
178:            /**
179:             * Return true if this is uriRoute
180:             */
181:            public boolean isURIRoute() {
182:                return uriRoute;
183:            }
184:
185:            /**
186:             * Set the URIRoute flag.
187:             */
188:            public void setURIRouteFlag() {
189:                uriRoute = true;
190:            }
191:
192:            /**
193:             * Set the defaultRouteFlag.
194:             */
195:            public void setDefaultRouteFlag() {
196:                defaultRoute = true;
197:            }
198:
199:            /**
200:             * Set the explicitRoute flag.
201:             */
202:            public void setExplicitRouteFlag() {
203:                explicitRoute = true;
204:            }
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.