Source Code Cross Referenced for UserInfo.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:        import gov.nist.siplite.parser.*;
031:
032:        /**
033:         * User information part of a URL.
034:         *
035:         * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
036:         */
037:        public final class UserInfo {
038:
039:            /**
040:             *  user field
041:             */
042:            private String user;
043:
044:            /**
045:             *  password field
046:             */
047:            private String password;
048:
049:            /**
050:             *  userType field
051:             */
052:            protected int userType;
053:
054:            /**
055:             *  Constant field
056:             */
057:            public final static int TELEPHONE_SUBSCRIBER = 1;
058:
059:            /**
060:             *  constant field
061:             */
062:            public final static int USER = 2;
063:
064:            /**
065:             *  Default constructor
066:             */
067:            public UserInfo() {
068:                super ();
069:            }
070:
071:            /**
072:             * Compare for equality.
073:             * @param obj Object to set
074:             * @return true if the two headers are equals, false otherwise.
075:             */
076:            public boolean equals(Object obj) {
077:                if (!getClass().getName().equals(obj.getClass().getName())) {
078:                    return false;
079:                }
080:                UserInfo other = (UserInfo) obj;
081:                if (this .userType != other.userType) {
082:                    return false;
083:                }
084:                String u1 = this .user;
085:                String u2 = other.user;
086:                if (u1 == null)
087:                    u1 = "";
088:                if (u2 == null)
089:                    u2 = "";
090:                if (!u1.toLowerCase().equals(u2.toLowerCase())) {
091:                    return false;
092:                }
093:                u1 = this .password;
094:                u2 = other.password;
095:                if (u1 == null)
096:                    u1 = "";
097:                if (u2 == null)
098:                    u2 = "";
099:                if (!u1.equals(u2)) {
100:                    return false;
101:                }
102:                return (true);
103:            }
104:
105:            /**
106:             * Encode the user information as a string.
107:             * @return String
108:             */
109:            public String encode() {
110:                if (password != null) {
111:                    return new StringBuffer().append(user).append(
112:                            Separators.COLON).append(password).toString();
113:                } else {
114:                    return user;
115:                }
116:            }
117:
118:            /**
119:             *  Clear the password field.
120:             */
121:            public void clearPassword() {
122:                this .password = null;
123:            }
124:
125:            /**
126:             * Gets the user type (which can be set to TELEPHONE_SUBSCRIBER or USER).
127:             * @return the type of user.
128:             */
129:            public int getUserType() {
130:                return userType;
131:            }
132:
133:            /**
134:             * Get the user field.
135:             * @return String
136:             */
137:            public String getUser() {
138:                return user;
139:            }
140:
141:            /**
142:             * Get the password field.
143:             * @return String
144:             */
145:            public String getPassword() {
146:                return password;
147:            }
148:
149:            /**
150:             * Set the user member.
151:             * @param user String to set
152:             * @throws IllegalArgumentException if user name contains invalid
153:             * characters
154:             */
155:            public void setUser(String user) throws IllegalArgumentException {
156:                if (false == Lexer.isValidUserName(user)) {
157:                    throw new IllegalArgumentException("User name '" + user
158:                            + "' contains " + "illegal characters");
159:                }
160:                this .user = user;
161:                // add this (taken form sip_messageParser)
162:                // otherwise comparison of two SipUrl will fail because this
163:                // parameter is not set (whereas it is set in sip_messageParser).
164:                if (user != null
165:                        && (user.indexOf(Separators.POUND) >= 0 || user
166:                                .indexOf(Separators.SEMICOLON) >= 0)) {
167:                    setUserType(UserInfo.TELEPHONE_SUBSCRIBER);
168:                } else {
169:                    setUserType(UserInfo.USER);
170:                }
171:            }
172:
173:            /**
174:             * Set the password member.
175:             * @param p String to set
176:             * @throws IllegalArgumentException if user name contains invalid
177:             * characters
178:             */
179:            public void setPassword(String p) throws IllegalArgumentException {
180:                // IMPL_NOTE: check for the password validity
181:                password = p;
182:            }
183:
184:            /**
185:             * Set the user type (to TELEPHONE_SUBSCRIBER or USER).
186:             * @param type int to set
187:             * @throws IllegalArgumentException if type is not in range.
188:             */
189:            public void setUserType(int type) throws IllegalArgumentException {
190:                if (type != TELEPHONE_SUBSCRIBER && type != USER) {
191:                    throw new IllegalArgumentException("Parameter not in range");
192:                }
193:                userType = type;
194:            }
195:
196:            /**
197:             * Copies the current instance.
198:             * @return a copy of the current instance
199:             */
200:            public Object clone() {
201:                UserInfo retval = new UserInfo();
202:                try {
203:                    retval.setUser(user);
204:                    retval.setPassword(password);
205:                } catch (IllegalArgumentException e) {
206:                    // intentionally ignored
207:                    // it shoild be impossible to get here due to this.user
208:                    // and this.password are verified values
209:                }
210:
211:                return retval;
212:            }
213:
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.