Source Code Cross Referenced for HttpEntityMessage.java in  » Web-Server » Jigsaw » org » w3c » www » http » 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 Server » Jigsaw » org.w3c.www.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // HttpEntityMessage.java
002:        // $Id: HttpEntityMessage.java,v 1.13 2000/08/16 21:37:59 ylafon Exp $  
003:        // (c) COPYRIGHT MIT and INRIA, 1997.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.www.http;
007:
008:        import org.w3c.www.mime.MimeParser;
009:        import org.w3c.www.mime.MimeType;
010:
011:        public class HttpEntityMessage extends HttpMessage {
012:
013:            // HTTP Entity message well-known headers
014:            public static int H_ALLOW = 19;
015:            public static int H_CONTENT_LENGTH = 20;
016:            public static int H_CONTENT_BASE = 21;
017:            public static int H_CONTENT_ENCODING = 22;
018:            public static int H_CONTENT_LANGUAGE = 23;
019:            public static int H_CONTENT_LOCATION = 24;
020:            public static int H_CONTENT_MD5 = 25;
021:            public static int H_CONTENT_RANGE = 26;
022:            public static int H_CONTENT_TYPE = 27;
023:            public static int H_ETAG = 28;
024:            public static int H_EXPIRES = 29;
025:            public static int H_LAST_MODIFIED = 30;
026:
027:            static {
028:                registerHeader("Allow", "org.w3c.www.http.HttpTokenList",
029:                        H_ALLOW);
030:                registerHeader("Content-Length",
031:                        "org.w3c.www.http.HttpInteger", H_CONTENT_LENGTH);
032:                registerHeader("Content-Base", "org.w3c.www.http.HttpString",
033:                        H_CONTENT_BASE);
034:                registerHeader("Content-Encoding",
035:                        "org.w3c.www.http.HttpTokenList", H_CONTENT_ENCODING);
036:                registerHeader("Content-Language",
037:                        "org.w3c.www.http.HttpTokenList", H_CONTENT_LANGUAGE);
038:                registerHeader("Content-Location",
039:                        "org.w3c.www.http.HttpString", H_CONTENT_LOCATION);
040:                registerHeader("Content-Md5", "org.w3c.www.http.HttpString",
041:                        H_CONTENT_MD5);
042:                registerHeader("Content-Range",
043:                        "org.w3c.www.http.HttpContentRange", H_CONTENT_RANGE);
044:                registerHeader("Content-Type", "org.w3c.www.http.HttpMimeType",
045:                        H_CONTENT_TYPE);
046:                registerHeader("Etag", "org.w3c.www.http.HttpEntityTag", H_ETAG);
047:                registerHeader("Expires", "org.w3c.www.http.HttpDate",
048:                        H_EXPIRES);
049:                registerHeader("Last-Modified", "org.w3c.www.http.HttpDate",
050:                        H_LAST_MODIFIED);
051:            }
052:
053:            /**
054:             * Get the message's entity allowed methods.
055:             * @return The list of allowed methods, encoded as a String array, or
056:             * <strong>null</strong> if undefined.
057:             */
058:
059:            public String[] getAllow() {
060:                HeaderValue value = getHeaderValue(H_ALLOW);
061:                return (value != null) ? (String[]) value.getValue() : null;
062:            }
063:
064:            /**
065:             * Set this message's entity allowed methods.
066:             * @param mth A list of allowed methods, encoded as a String array, or
067:             * <strong>null</strong> to reset the value.
068:             */
069:
070:            public void setAllow(String mth[]) {
071:                setHeaderValue(H_ALLOW, ((mth == null) ? null
072:                        : new HttpTokenList(mth)));
073:            }
074:
075:            /**
076:             * Get this message entity base.
077:             * @return A String encoding the content base, or <strong>null</strong>
078:             *    if undefined.
079:             */
080:
081:            public String getContentBase() {
082:                HeaderValue value = getHeaderValue(H_CONTENT_BASE);
083:                return (value != null) ? (String) value.getValue() : null;
084:            }
085:
086:            /**
087:             * Set this message entity content base.
088:             * @param base The base for the entity, encoded as a String, or
089:             * <strong>null</strong> to reset the value.
090:             */
091:
092:            public void setContentBase(String base) {
093:                setHeaderValue(H_CONTENT_BASE, ((base == null) ? null
094:                        : new HttpString(true, base)));
095:            }
096:
097:            /**
098:             * Get this message entity encoding.
099:             * @return A list of encoding tokens, encoded as a String array, or 
100:             *    <strong>null</strong> if undefined.
101:             */
102:
103:            public String[] getContentEncoding() {
104:                HeaderValue value = getHeaderValue(H_CONTENT_ENCODING);
105:                return (value != null) ? (String[]) value.getValue() : null;
106:            }
107:
108:            /**
109:             * Set this message entity content encoding.
110:             * @param encodings A list of encoding tokens, encoded as a String array
111:             * or <strong>null</strong> to reset the value.
112:             */
113:
114:            public void setContentEncoding(String encodings[]) {
115:                setHeaderValue(H_CONTENT_ENCODING, ((encodings == null) ? null
116:                        : new HttpTokenList(encodings)));
117:            }
118:
119:            /**
120:             * Add an encoding token to the given reply stream (ie the body).
121:             * @param name The name of the encoding to add.
122:             */
123:
124:            public void addContentEncoding(String name) {
125:                HttpTokenList l = (HttpTokenList) getHeaderValue(H_CONTENT_ENCODING);
126:                if (l == null) {
127:                    String sList[] = new String[1];
128:                    sList[0] = name.toLowerCase();
129:                    setHeaderValue(H_CONTENT_ENCODING, new HttpTokenList(sList));
130:                } else {
131:                    l.addToken(name, false);
132:                }
133:            }
134:
135:            /**
136:             * Get this message entity content language.
137:             * @return A list of languages token, encoded as a String arry, or
138:             *    <strong>null</strong> if undefined.
139:             */
140:
141:            public String[] getContentLanguage() {
142:                HeaderValue value = getHeaderValue(H_CONTENT_LANGUAGE);
143:                return (value != null) ? (String[]) value.getValue() : null;
144:            }
145:
146:            /**
147:             * Set this message entity content language.
148:             * @param languages The language tokens for this entity, encoded as
149:             *    a String array, or <strong>null</strong> to reset the value.
150:             */
151:
152:            public void setContentLanguage(String languages[]) {
153:                setHeaderValue(H_CONTENT_LANGUAGE, ((languages == null) ? null
154:                        : new HttpTokenList(languages)));
155:            }
156:
157:            /**
158:             * Get the content length of the message.
159:             * @return The content length for the message entity, or <strong>-1
160:             *    </strong> if undefined.
161:             */
162:
163:            public int getContentLength() {
164:                HeaderValue value = getHeaderValue(H_CONTENT_LENGTH);
165:                return (value != null) ? ((Integer) value.getValue())
166:                        .intValue() : -1;
167:            }
168:
169:            /**
170:             * Set this message entity content-length.
171:             * @param length The new content length for this message, or
172:             * <strong>-1</strong> to reset the value.
173:             */
174:
175:            public void setContentLength(int length) {
176:                if (length < 0)
177:                    setHeaderValue(H_CONTENT_LENGTH, null);
178:                else
179:                    setHeaderValue(H_CONTENT_LENGTH, new HttpInteger(true,
180:                            length));
181:            }
182:
183:            /**
184:             * Get the attached entity's content location.
185:             * @return A String encoded value of the content location, or <strong>
186:             *    null</strong> if undefined.
187:             */
188:
189:            public String getContentLocation() {
190:                HeaderValue value = getHeaderValue(H_CONTENT_LOCATION);
191:                return (value != null) ? (String) value.getValue() : null;
192:            }
193:
194:            /**
195:             * Set the entity's content location.
196:             * @param location The String encoding the content location for the 
197:             *    attached entity, or <strong>null</strong> to reset the value.
198:             */
199:
200:            public void setContentLocation(String location) {
201:                setHeaderValue(H_CONTENT_LOCATION, ((location == null) ? null
202:                        : new HttpString(true, location)));
203:            }
204:
205:            /**
206:             * Get the entity's content MD5 checksum.
207:             * @return A String giving the base64 encoded MD% checksun on the
208:             * entity body, or <strong>null</strong> if undefined.
209:             */
210:
211:            public String getContentMD5() {
212:                HeaderValue value = getHeaderValue(H_CONTENT_MD5);
213:                return (value != null) ? (String) value.getValue() : null;
214:            }
215:
216:            /**
217:             * Set the entity's content MD5 checksum.
218:             * @param md5 The new base64 encoded checksum for the entity body, or
219:             * <strong>null</strong> to reset the value.
220:             */
221:
222:            public void setContentMD5(String md5) {
223:                setHeaderValue(H_CONTENT_MD5, ((md5 == null) ? null
224:                        : new HttpString(true, md5)));
225:            }
226:
227:            /**
228:             * Get the range descriptor of the attached entity.
229:             * @return An HttpRange instance, describing the part of the full
230:             * entity body being transmited, or <strong>null</strong> if undefined.
231:             */
232:
233:            public HttpContentRange getContentRange() {
234:                HeaderValue value = getHeaderValue(H_CONTENT_RANGE);
235:                return (value != null) ? (HttpContentRange) value.getValue()
236:                        : null;
237:            }
238:
239:            /**
240:             * Is this entity only a partial entity ?
241:             * @return A boolean, indicating if a <code>Content-Range</code> header
242:             * was present.
243:             */
244:
245:            public boolean hasContentRange() {
246:                return hasHeader(H_CONTENT_RANGE);
247:            }
248:
249:            /**
250:             * Get the entity MIME type.
251:             * @return An HttpMimeType object describing the entity's type, or 
252:             * <strong>null</strong> if udefined.
253:             */
254:
255:            public MimeType getContentType() {
256:                HeaderValue value = getHeaderValue(H_CONTENT_TYPE);
257:                return (value != null) ? (MimeType) value.getValue() : null;
258:            }
259:
260:            /**
261:             * Set the entity MIME type.
262:             * @param type The entity MIME type, or <strong>null</strong> to unset
263:             * the entity's content type.
264:             */
265:
266:            public void setContentType(MimeType type) {
267:                setHeaderValue(H_CONTENT_TYPE, (type == null) ? null
268:                        : new HttpMimeType(true, type));
269:            }
270:
271:            /**
272:             * Get this entity tag.
273:             * @return An HttpEntityTag instance describing this entity tag.
274:             */
275:
276:            public HttpEntityTag getETag() {
277:                HeaderValue value = getHeaderValue(H_ETAG);
278:                return (value != null) ? (HttpEntityTag) value.getValue()
279:                        : null;
280:            }
281:
282:            /**
283:             * Set this entity tag.
284:             * @param tag The new entity tag, or <strong>null</strong> to reset the
285:             * value.
286:             */
287:
288:            public void setETag(HttpEntityTag tag) {
289:                setHeaderValue(H_ETAG, tag);
290:            }
291:
292:            /**
293:             * Get this message's entity expires date.
294:             * @return A long giving the date as the number of milliseconds since the
295:             * Java epoch, or <strong>-1</strong> if undefined.
296:             */
297:
298:            public long getExpires() {
299:                HeaderValue value = getHeaderValue(H_EXPIRES);
300:                return (value != null) ? ((Long) value.getValue()).longValue()
301:                        : -1;
302:            }
303:
304:            /**
305:             * Se the message's associated entity exxpires date.
306:             * @param date The date as the number of milliseconds since Java epoch,
307:             * or <strong>-1</strong> to reset the value.
308:             */
309:
310:            public void setExpires(long date) {
311:                setHeaderValue(H_EXPIRES, ((date == -1) ? null : new HttpDate(
312:                        true, date)));
313:            }
314:
315:            /**
316:             * Get the message's associated entity last modified time.
317:             * @return A long giving the date as the number of milliseconds since
318:             * Java epoch, or  <strong>-1</strong> if undefined.
319:             */
320:
321:            public long getLastModified() {
322:                HeaderValue value = getHeaderValue(H_LAST_MODIFIED);
323:                return (value != null) ? ((Long) value.getValue()).longValue()
324:                        : -1;
325:            }
326:
327:            /**
328:             * Set the message's entity header last-modified time.
329:             * @param date The date of last modification, as the number of milliseconds
330:             * since Java epoch, or <strong>-1</strong> to reset the value.
331:             */
332:
333:            public void setLastModified(long date) {
334:                setHeaderValue(H_LAST_MODIFIED, ((date == -1) ? null
335:                        : new HttpDate(true, date)));
336:            }
337:
338:            public HttpEntityMessage(MimeParser parser) {
339:                super (parser);
340:            }
341:
342:            public HttpEntityMessage() {
343:                super();
344:            }
345:
346:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.