Source Code Cross Referenced for CookieSetting.java in  » Web-Services » restlet-1.0.8 » org » restlet » data » 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 » Web Services » restlet 1.0.8 » org.restlet.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 Noelios Consulting.
003:         * 
004:         * The contents of this file are subject to the terms of the Common Development
005:         * and Distribution License (the "License"). You may not use this file except in
006:         * compliance with the License.
007:         * 
008:         * You can obtain a copy of the license at
009:         * http://www.opensource.org/licenses/cddl1.txt See the License for the specific
010:         * language governing permissions and limitations under the License.
011:         * 
012:         * When distributing Covered Code, include this CDDL HEADER in each file and
013:         * include the License file at http://www.opensource.org/licenses/cddl1.txt If
014:         * applicable, add the following below this CDDL HEADER, with the fields
015:         * enclosed by brackets "[]" replaced with your own identifying information:
016:         * Portions Copyright [yyyy] [name of copyright owner]
017:         */
018:
019:        package org.restlet.data;
020:
021:        import org.restlet.util.Engine;
022:
023:        /**
024:         * Cookie setting provided by a server.
025:         * 
026:         * @author Jerome Louvel (contact@noelios.com)
027:         */
028:        public final class CookieSetting extends Cookie {
029:            /** The user's comment. */
030:            private String comment;
031:
032:            /**
033:             * The maximum age in seconds. Use 0 to discard an existing cookie.
034:             */
035:            private int maxAge;
036:
037:            /** Indicates if cookie should only be transmitted by secure means. */
038:            private boolean secure;
039:
040:            /**
041:             * Default constructor.
042:             */
043:            public CookieSetting() {
044:                this (0, null, null, null, null);
045:            }
046:
047:            /**
048:             * Preferred constructor.
049:             * 
050:             * @param version
051:             *            The cookie's version.
052:             * @param name
053:             *            The cookie's name.
054:             * @param value
055:             *            The cookie's value.
056:             */
057:            public CookieSetting(int version, String name, String value) {
058:                this (version, name, value, null, null);
059:            }
060:
061:            /**
062:             * Preferred constructor.
063:             * 
064:             * @param version
065:             *            The cookie's version.
066:             * @param name
067:             *            The cookie's name.
068:             * @param value
069:             *            The cookie's value.
070:             * @param path
071:             *            The cookie's path.
072:             * @param domain
073:             *            The cookie's domain name.
074:             */
075:            public CookieSetting(int version, String name, String value,
076:                    String path, String domain) {
077:                super (version, name, value, path, domain);
078:                this .comment = null;
079:                this .maxAge = -1;
080:                this .secure = false;
081:            }
082:
083:            /**
084:             * Preferred constructor.
085:             * 
086:             * @param name
087:             *            The cookie's name.
088:             * @param value
089:             *            The cookie's value.
090:             */
091:            public CookieSetting(String name, String value) {
092:                this (0, name, value, null, null);
093:            }
094:
095:            /** {@inheritDoc} */
096:            @Override
097:            public boolean equals(Object obj) {
098:                boolean result = (obj == this );
099:
100:                // if obj == this no need to go further
101:                if (!result) {
102:                    // test for equality at Cookie level i.e. name and value.
103:                    if (super .equals(obj)) {
104:                        // if obj isn't a cookie setting or is null don't evaluate
105:                        // further
106:                        if ((obj instanceof  CookieSetting) && obj != null) {
107:                            CookieSetting that = (CookieSetting) obj;
108:                            result = (this .maxAge == that.maxAge)
109:                                    && (this .secure == that.secure);
110:
111:                            if (result) // if "maxAge" and "secure" properties are equal
112:                            // test comments
113:                            {
114:                                if (!(this .comment == null)) // compare comments
115:                                // taking care of nulls
116:                                {
117:                                    result = (this .comment.equals(that.comment));
118:                                } else {
119:                                    result = (that.comment == null);
120:                                }
121:                            }
122:                        }
123:                    }
124:                }
125:
126:                return result;
127:            }
128:
129:            /**
130:             * Returns the comment for the user.
131:             * 
132:             * @return The comment for the user.
133:             */
134:            public String getComment() {
135:                return this .comment;
136:            }
137:
138:            /**
139:             * Returns the description of this REST element.
140:             * 
141:             * @return The description of this REST element.
142:             */
143:            public String getDescription() {
144:                return "Cookie setting";
145:            }
146:
147:            /**
148:             * Returns the maximum age in seconds.<br/> Use 0 to immediately discard an
149:             * existing cookie.<br/> Use -1 to discard the cookie at the end of the
150:             * session (default).
151:             * 
152:             * @return The maximum age in seconds.
153:             */
154:            public int getMaxAge() {
155:                return this .maxAge;
156:            }
157:
158:            /** {@inheritDoc} */
159:            @Override
160:            public int hashCode() {
161:                return Engine.hashCode(super .hashCode(), getComment(),
162:                        getMaxAge(), isSecure());
163:            }
164:
165:            /**
166:             * Indicates if cookie should only be transmitted by secure means.
167:             * 
168:             * @return True if cookie should only be transmitted by secure means.
169:             */
170:            public boolean isSecure() {
171:                return this .secure;
172:            }
173:
174:            /**
175:             * Sets the comment for the user.
176:             * 
177:             * @param comment
178:             *            The comment for the user.
179:             */
180:            public void setComment(String comment) {
181:                this .comment = comment;
182:            }
183:
184:            /**
185:             * Sets the maximum age in seconds.<br/> Use 0 to immediately discard an
186:             * existing cookie.<br/> Use -1 to discard the cookie at the end of the
187:             * session (default).
188:             * 
189:             * @param maxAge
190:             *            The maximum age in seconds.
191:             */
192:            public void setMaxAge(int maxAge) {
193:                this .maxAge = maxAge;
194:            }
195:
196:            /**
197:             * Indicates if cookie should only be transmitted by secure means.
198:             * 
199:             * @param secure
200:             *            True if cookie should only be transmitted by secure means.
201:             */
202:            public void setSecure(boolean secure) {
203:                this.secure = secure;
204:            }
205:
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.