01: /*
02: * Enhydra Java Application Server Project
03: *
04: * The contents of this file are subject to the Enhydra Public License
05: * Version 1.1 (the "License"); you may not use this file except in
06: * compliance with the License. You may obtain a copy of the License on
07: * the Enhydra web site ( http://www.enhydra.org/ ).
08: *
09: * Software distributed under the License is distributed on an "AS IS"
10: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11: * the License for the specific terms governing rights and limitations
12: * under the License.
13: *
14: * The Initial Developer of the Enhydra Application Server is Lutris
15: * Technologies, Inc. The Enhydra Application Server and portions created
16: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17: * All Rights Reserved.
18: *
19: * Contributor(s):
20: *
21: * $Id: ContentHeader.java,v 1.2 2006-06-15 13:47:00 sinisa Exp $
22: */
23:
24: package com.lutris.mime;
25:
26: /**
27: * Parses and represents Mime header fields that have the form of the
28: * <code>Content-Type</code> header as defined in RFC2045 Section 5.1 Page 11.
29: * The format of these headers is informally:
30: *
31: * <PRE>
32: *
33: * <Header-Type>: <value>[ ; <parameter>... ]
34: *
35: * </PRE>
36: *
37: * Examples:
38: *
39: * <PRE>
40: *
41: * Content-Type: application/octet-stream Content-Type: multipart/form-data;
42: * boundary="---123456" Content-Disposition: form-data; name=upload;
43: * filename="/tmp/myfile"
44: *
45: * </PRE>
46: *
47: * In addition to the actual header syntax, RFC822 header comments are allowed.
48: * Such comments consist of text enclosed in parentheses.
49: */
50: public class ContentHeader extends MimeHeader {
51: /**
52: * Constructs a new ContentTypeHeader object from an unparsed Mime
53: * <code>Content-Type</code> header line. The header line should include
54: * the <i>entire </i> line as read from the input source.
55: *
56: * @param headerLine
57: * The entire line containing the Mime header.
58: */
59: public ContentHeader(String headerLine) {
60: super (headerLine);
61: int pos = headerLine.indexOf(';');
62: if (pos >= 0)
63: parseParameters(headerLine.substring(pos + 1));
64: }
65:
66: /**
67: * Constructs a new ContentTypeHeader object from an existing
68: * <code>MimeHeader</code> object.
69: *
70: * @param hdr
71: * An existing <code>MimeHeader</code> object.
72: */
73: public ContentHeader(MimeHeader hdr) {
74: super (hdr.getRawHeaderLine());
75: String headerLine = hdr.getRawHeaderLine();
76: int pos = headerLine.indexOf(';');
77: if (pos >= 0)
78: parseParameters(headerLine.substring(pos + 1));
79: }
80: }
|