Source Code Cross Referenced for HttpHeaders.java in  » Ajax » GWT » com » google » gwt » dev » 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 » Ajax » GWT » com.google.gwt.dev.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.dev.util;
017:
018:        import java.text.DateFormat;
019:        import java.text.ParseException;
020:        import java.text.SimpleDateFormat;
021:        import java.util.Calendar;
022:        import java.util.Date;
023:        import java.util.Locale;
024:
025:        /**
026:         * Groups predefined magic HTTP header strings.
027:         */
028:        public final class HttpHeaders {
029:
030:            public static final long MS_SEC = 1000;
031:            public static final long MS_MIN = MS_SEC * 60;
032:            public static final long MS_HR = MS_MIN * 60;
033:            public static final long MS_DAY = MS_HR * 24;
034:
035:            public static final long SEC_MIN = 60;
036:            public static final long SEC_HR = SEC_MIN * 60;
037:            public static final long SEC_DAY = SEC_HR * 24;
038:            public static final long SEC_YR = SEC_DAY * 365;
039:
040:            public static final String CACHE_CONTROL = "Cache-Control";
041:            public static final String CACHE_CONTROL_MAXAGE = "max-age=";
042:            public static final String CACHE_CONTROL_MUST_REVALIDATE = "must-revalidate";
043:            public static final String CACHE_CONTROL_NO_CACHE = "no-cache";
044:            public static final String CACHE_CONTROL_PRIVATE = "private";
045:            public static final String CACHE_CONTROL_PUBLIC = "public";
046:
047:            public static final String CONTENT_ENCODING = "Content-Encoding";
048:            public static final String CONTENT_ENCODING_GZIP = "gzip";
049:            public static final String CONTENT_LENGTH = "Content-Length";
050:            public static final String CONTENT_TYPE = "Content-Type";
051:            public static final String CONTENT_TYPE_APPLICATION_XJAVASCRIPT_UTF8 = "application/x-javascript; charset=utf-8";
052:            public static final String CONTENT_TYPE_TEXT_CSS = "text/css";
053:            public static final String CONTENT_TYPE_TEXT_HTML = "text/html";
054:            public static final String CONTENT_TYPE_TEXT_HTML_UTF8 = "text/html; charset=utf-8";
055:            public static final String CONTENT_TYPE_TEXT_PLAIN = "text/plain";
056:
057:            public static final String DATE = "Date";
058:            public static final String ETAG = "ETag";
059:            public static final String EXPIRES = "Expires";
060:            public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
061:            public static final String IF_NONE_MATCH = "If-None-Match";
062:            public static final String LAST_MODIFIED = "Last-Modified";
063:
064:            /**
065:             * The Internet date format for HTTP.
066:             */
067:            private static DateFormat sHttpDateFormat = new SimpleDateFormat(
068:                    "EEE, d MMM yyyy HH:mm:ss", Locale.US);
069:
070:            /**
071:             * Converts an HTTP date string into a file-style date/time.
072:             */
073:            public static long fromInternetDateFormat(String timeStr) {
074:                Date dateGmt;
075:                try {
076:                    synchronized (sHttpDateFormat) {
077:                        dateGmt = sHttpDateFormat.parse(timeStr);
078:                    }
079:                } catch (ParseException e) {
080:                    return 0;
081:                }
082:                dateGmt = gmtToDate(dateGmt);
083:                return dateGmt.getTime();
084:            }
085:
086:            /**
087:             * Converts a file-style date/time into a string form that is compatible with
088:             * HTTP.
089:             */
090:            public static String toInternetDateFormat(long time) {
091:                Date date = dateToGMT(new Date(time));
092:                String dateGmt;
093:                synchronized (sHttpDateFormat) {
094:                    dateGmt = sHttpDateFormat.format(date) + " GMT";
095:                }
096:                return dateGmt;
097:            }
098:
099:            /**
100:             * Converts a local date to GMT.
101:             * 
102:             * @param date the date in the local time zone
103:             * @return the GMT version
104:             */
105:            private static Date dateToGMT(Date date) {
106:                Calendar cal = Calendar.getInstance();
107:                long tzMillis = cal.get(Calendar.ZONE_OFFSET)
108:                        + cal.get(Calendar.DST_OFFSET);
109:                return new Date(date.getTime() - tzMillis);
110:            }
111:
112:            /**
113:             * Converts a GMT into a local date.
114:             * 
115:             * @param date the date in GMT
116:             * @return the the local time zone version
117:             */
118:            private static Date gmtToDate(Date date) {
119:                Calendar cal = Calendar.getInstance();
120:                long tzMillis = cal.get(Calendar.ZONE_OFFSET)
121:                        + cal.get(Calendar.DST_OFFSET);
122:                return new Date(date.getTime() + tzMillis);
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.