Source Code Cross Referenced for HostPort.java in  » 6.0-JDK-Modules » j2me » gov » nist » core » 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.core 
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.core;
028:
029:        /**
030:         * Holds the hostname:port.
031:         *
032:         *@version  JAIN-SIP-1.1
033:         *
034:         *
035:         *<a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
036:         *
037:         */
038:        public final class HostPort {
039:
040:            // host / ipv4/ ipv6/
041:            /** Host field.  */
042:            protected Host host;
043:
044:            /** Port field. */
045:            protected Integer port;
046:
047:            /** Default constructor. */
048:            public HostPort() {
049:
050:                host = null;
051:                port = null; // marker for not set.
052:            }
053:
054:            /**
055:             * Encodes this hostport into its string representation.
056:             * Note that this could be different from the string that has
057:             * been parsed if something has been edited.
058:             * @return host and port encoded string
059:             */
060:            public String encode() {
061:                StringBuffer retval = new StringBuffer();
062:                if (host != null)
063:                    retval.append(host.encode());
064:                if (port != null)
065:                    retval.append(':').append(port.toString());
066:                return retval.toString();
067:            }
068:
069:            /**
070:             * Returns true if the two objects are equals, false otherwise.
071:             * @param other Object to set
072:             * @return boolean
073:             */
074:            public boolean equals(Object other) {
075:                if (!this .getClass().equals(other.getClass())) {
076:                    return false;
077:                }
078:                HostPort that = (HostPort) other;
079:                if ((this .port == null && that.port != null)
080:                        || (this .port != null && that.port == null))
081:                    return false;
082:                else if (this .port == that.port && this .host.equals(that.host))
083:                    return true;
084:                else
085:                    return this .host.equals(that.host)
086:                            && this .port.equals(that.port);
087:            }
088:
089:            /**
090:             * Gets the Host field.
091:             * @return host field
092:             */
093:            public Host getHost() {
094:                return host;
095:            }
096:
097:            /**
098:             * Gets the port field.
099:             * @return int
100:             */
101:            public int getPort() {
102:                if (port == null) {
103:                    return -1;
104:                } else {
105:                    return port.intValue();
106:                }
107:            }
108:
109:            /**
110:             * Returns boolean value indicating if Header has port
111:             * @return boolean value indicating if Header has port
112:             */
113:            public boolean hasPort() {
114:                return port != null;
115:            }
116:
117:            /** Removes the  port. */
118:            public void removePort() {
119:                port = null;
120:            }
121:
122:            /**
123:             * Sets the host member.
124:             * @param h Host to set
125:             */
126:            public void setHost(Host h) {
127:                host = h;
128:            }
129:
130:            /**
131:             * Sets the port member.
132:             * @param p int to set
133:             * @throws IllegalArgumentException in case of illegal port value
134:             */
135:            public void setPort(int p) throws IllegalArgumentException {
136:                if (p > 65535 || p < 0) {
137:                    throw new IllegalArgumentException("Illegal port value "
138:                            + p);
139:                }
140:                port = new Integer(p);
141:            }
142:
143:            /**
144:             * Makes a copy of the current instance.
145:             * @return copy of current object
146:             */
147:            public Object clone() {
148:                HostPort retval = new HostPort();
149:                if (this .host != null)
150:                    retval.host = (Host) this .host.clone();
151:                if (this .port != null)
152:                    retval.port = new Integer(this.port.intValue());
153:                return retval;
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.