Source Code Cross Referenced for Authority.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:        /*
026:         */
027:        package gov.nist.siplite.address;
028:
029:        import gov.nist.core.*;
030:
031:        /**
032:         * Authority part of a URI structure. Section 3.2.2 RFC2396
033:         *
034:         * @version JAIN-SIP-1.1
035:         *
036:         *
037:         * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
038:         *
039:         */
040:        public class Authority extends GenericObject {
041:
042:            /**
043:             * Host and port field.
044:             */
045:            protected HostPort hostPort;
046:
047:            /**
048:             * User information field.
049:             */
050:            protected UserInfo userInfo;
051:
052:            /**
053:             * Returns the host name in encoded form.
054:             * @return encoded string (does the same thing as toString)
055:             */
056:            public String encode() {
057:                StringBuffer retval = new StringBuffer();
058:
059:                if (userInfo != null) {
060:                    String user = userInfo.encode();
061:                    if (user != null) {
062:                        retval.append(user).append(Separators.AT);
063:                    }
064:                }
065:
066:                if (hostPort != null) {
067:                    retval.append(hostPort.encode());
068:                }
069:
070:                return retval.toString();
071:            }
072:
073:            /**
074:             * Returns true if the two Objects are equals , false otherwise.
075:             * @param other Object to test.
076:             * @return true if objects match
077:             */
078:            public boolean equals(Object other) {
079:                if (!other.getClass().getName().equals(
080:                        this .getClass().getName())) {
081:                    return false;
082:                }
083:                Authority otherAuth = (Authority) other;
084:                if (!this .hostPort.equals(otherAuth.hostPort)) {
085:                    return false;
086:                }
087:                if (this .userInfo != null && otherAuth.userInfo != null) {
088:                    if (!this .userInfo.equals(otherAuth.userInfo)) {
089:                        return false;
090:                    }
091:                }
092:                return true;
093:            }
094:
095:            /**
096:             * Gets the host and port member.
097:             * @return the host and port
098:             */
099:            public HostPort getHostPort() {
100:                return hostPort;
101:            }
102:
103:            /**
104:             * Gets the user information memnber.
105:             * @return the user information
106:             */
107:            public UserInfo getUserInfo() {
108:                return userInfo;
109:            }
110:
111:            /**
112:             * Gets the  password from the user informatio.
113:             * @return the password
114:             */
115:            public String getPassword() {
116:                if (userInfo == null) {
117:                    return null;
118:                } else {
119:                    return userInfo.getPassword();
120:                }
121:            }
122:
123:            /**
124:             * Gets the user name if it exists.
125:             * @return  user or null if not set.
126:             */
127:            public String getUser() {
128:                return (userInfo != null) ? userInfo.getUser() : null;
129:            }
130:
131:            /**
132:             * Gets the host name.
133:             * @return Host (null if not set)
134:             */
135:            public Host getHost() {
136:                if (hostPort == null)
137:                    return null;
138:                else
139:                    return hostPort.getHost();
140:            }
141:
142:            /**
143:             * Gets the port.
144:             * @return  port (-1) if port is not set.
145:             */
146:            public int getPort() {
147:                if (hostPort == null)
148:                    return -1;
149:                else
150:                    return hostPort.getPort();
151:            }
152:
153:            /**
154:             * Removes the port.
155:             */
156:            public void removePort() {
157:                if (hostPort != null) {
158:                    hostPort.removePort();
159:                }
160:            }
161:
162:            /**
163:             * Sets the password.
164:             * @param passwd String to set
165:             * @throws IllegalArgumentException if password contains invalid
166:             * characters
167:             */
168:            public void setPassword(String passwd)
169:                    throws IllegalArgumentException {
170:                if (userInfo == null)
171:                    userInfo = new UserInfo();
172:                userInfo.setPassword(passwd);
173:            }
174:
175:            /**
176:             * Sets the user name of the user information member.
177:             * @param user String to set
178:             * @throws IllegalArgumentException if user name contains invalid
179:             * characters
180:             */
181:            public void setUser(String user) throws IllegalArgumentException {
182:                if (userInfo == null) {
183:                    userInfo = new UserInfo();
184:                }
185:
186:                userInfo.setUser(user);
187:            }
188:
189:            /**
190:             * Sets the host.
191:             * @param host Host to set
192:             */
193:            public void setHost(Host host) {
194:                if (hostPort == null) {
195:                    hostPort = new HostPort();
196:                }
197:
198:                hostPort.setHost(host);
199:            }
200:
201:            /**
202:             * Sets the port.
203:             * @param port int to set
204:             */
205:            public void setPort(int port) {
206:                if (hostPort == null) {
207:                    hostPort = new HostPort();
208:                }
209:                hostPort.setPort(port);
210:            }
211:
212:            /**
213:             * Sets the host and port member.
214:             * @param h HostPort to set
215:             */
216:            public void setHostPort(HostPort h) {
217:                hostPort = h;
218:            }
219:
220:            /**
221:             * Sets the user information member.
222:             * @param u UserInfo to set
223:             */
224:            public void setUserInfo(UserInfo u) {
225:                userInfo = u;
226:            }
227:
228:            /**
229:             * Removes the user information.
230:             */
231:            public void removeUserInfo() {
232:                userInfo = null;
233:            }
234:
235:            /**
236:             * Copies the object contents
237:             * @return the copy of this object
238:             */
239:            public Object clone() {
240:                Authority retval = new Authority();
241:
242:                try {
243:                    retval.setUser(getUser());
244:                    retval.setPassword(getPassword());
245:                } catch (IllegalArgumentException e) {
246:                    // intentionally ignored
247:                    // it shoild be impossible to get here due to getUser()
248:                    // and getPassword() return verified values
249:                }
250:                retval.setHostPort(getHostPort());
251:
252:                return retval;
253:            }
254:
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.