Source Code Cross Referenced for CookieData.java in  » ERP-CRM-Financial » sakai » edu » indiana » lib » twinpeaks » util » 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 » ERP CRM Financial » sakai » edu.indiana.lib.twinpeaks.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         *
003:         * Copyright (c) 2003, 2004 The Regents of the University of Michigan, Trustees of Indiana University,
004:         *                  Board of Trustees of the Leland Stanford, Jr., University, and The MIT Corporation
005:         *
006:         * Licensed under the Educational Community License Version 1.0 (the "License");
007:         * By obtaining, using and/or copying this Original Work, you agree that you have read,
008:         * understand, and will comply with the terms and conditions of the Educational Community License.
009:         * You may obtain a copy of the License at:
010:         *
011:         *      http://cvs.sakaiproject.org/licenses/license_1_0.html
012:         *
013:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
014:         * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
015:         * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
016:         * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
017:         * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
018:         *
019:         **********************************************************************************/package edu.indiana.lib.twinpeaks.util;
020:
021:        import java.io.*;
022:        import java.net.*;
023:        import java.util.*;
024:
025:        /**
026:         * Represent a single cookie
027:         */
028:        public class CookieData {
029:
030:            private static org.apache.commons.logging.Log _log = LogUtils
031:                    .getLog(CookieData.class);
032:            /**
033:             * Null (unset) cookie age
034:             */
035:            public static final int NULL_AGE = -1;
036:            /**
037:             * Expired cookie
038:             */
039:            public static final int EXPIRED_AGE = 0;
040:
041:            private String key;
042:            private String value;
043:
044:            private String path;
045:            private String domain;
046:            private String version;
047:
048:            private String expires;
049:            private int maxAge;
050:            private boolean secure;
051:
052:            private CookieData() {
053:            }
054:
055:            /**
056:             * Constructor
057:             * @param url URL associated with this cookie
058:             * @param key Cookie name
059:             * @param value Cookie value
060:             */
061:            public CookieData(URL url, String key, String value) {
062:                int slash = url.getFile().lastIndexOf("/");
063:                /*
064:                 * Save cookie name and content
065:                 */
066:                this .key = key;
067:                this .value = value;
068:                /*
069:                 * Domain defaults to hostname, path to the "directory" portion of
070:                 * the request, minus all text from the rightmost "/" character to
071:                 * the end of the string...
072:                 */
073:                this .path = slash < 1 ? "" : url.getFile().substring(0, slash);
074:                this .domain = url.getHost();
075:
076:                this .version = null;
077:                this .expires = null;
078:                this .maxAge = NULL_AGE;
079:
080:                this .secure = false;
081:            }
082:
083:            /**
084:             * Get cookie name
085:             * @return The cooke name
086:             */
087:            public String getName() {
088:                return this .key;
089:            }
090:
091:            /**
092:             * Get cookie value (the cookie "text")
093:             * @return The value
094:             */
095:            public String getValue() {
096:                return this .value;
097:            }
098:
099:            /**
100:             * Save the path
101:             */
102:            public void setPath(String path) {
103:                this .path = path;
104:            }
105:
106:            /**
107:             * Get the path
108:             * @return The cooke path attribute value (null if none)
109:             */
110:            public String getPath() {
111:                return this .path;
112:            }
113:
114:            /**
115:             * Save the expiration date
116:             */
117:            public void setExpires(String expires) {
118:                this .expires = expires;
119:            }
120:
121:            /**
122:             * Get the expiration date
123:             * @return The expires attribute value (null if none)
124:             */
125:            public String getExpires() {
126:                return this .expires;
127:            }
128:
129:            /**
130:             * Save the domain
131:             */
132:            public void setDomain(String domain) {
133:                this .domain = domain;
134:            }
135:
136:            /**
137:             * Get the domain
138:             * @return The domain attribute value (null if none)
139:             */
140:            public String getDomain() {
141:                return this .domain;
142:            }
143:
144:            /**
145:             * Save the version
146:             */
147:            public void setVersion(String version) {
148:                this .version = version;
149:            }
150:
151:            /**
152:             * Get the cookie version
153:             * @return The version (null if none)
154:             */
155:            public String getVersion() {
156:                return this .version;
157:            }
158:
159:            /**
160:             * Set the maximum age for this cookie
161:             */
162:            public void setMaxAge(String maxAge) {
163:                try {
164:                    this .maxAge = Integer.parseInt(maxAge);
165:                } catch (NumberFormatException ignore) {
166:                }
167:            }
168:
169:            /**
170:             * Get the maximum age for this cookie
171:             */
172:            public int getMaxAge() {
173:                return this .maxAge;
174:            }
175:
176:            /**
177:             * Save security setting (true if cookie to be sent only via HTTPS)
178:             */
179:            public void setSecure(boolean secure) {
180:                this .secure = secure;
181:            }
182:
183:            public boolean getSecure() {
184:                return this .secure;
185:            }
186:
187:            /**
188:             * Equal strings?
189:             * @param a String one
190:             * @param b Stringtwo
191:             * @return true if both are null, or String "equals" is true
192:             */
193:            private boolean stringEquals(String a, String b) {
194:                if ((a == null) && (b == null)) {
195:                    return true;
196:                }
197:
198:                if ((a == null) || (b == null)) {
199:                    return false;
200:                }
201:
202:                return a.equals(b);
203:            }
204:
205:            /**
206:             * Equal cookies?
207:             * @param cookie for comparison
208:             * @return true if cookie name, path, and domain are all equal
209:             */
210:            public boolean equals(CookieData cookie) {
211:                if (!key.equals(cookie.getName())) {
212:                    return false;
213:                }
214:
215:                return stringEquals(path, cookie.getPath())
216:                        && stringEquals(domain, cookie.getDomain());
217:            }
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.