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


001:        // MimeHeaders.java
002:        // $Id: MimeHeaders.java,v 1.4 2000/08/16 21:38:01 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.www.mime;
007:
008:        import java.io.IOException;
009:        import java.io.InputStream;
010:        import java.io.PrintStream;
011:
012:        import java.util.Enumeration;
013:        import java.util.Hashtable;
014:
015:        /**
016:         * The most stupid MIME header holder.
017:         * This class uses a hashtable mapping header names (as String), to header
018:         * values (as String). Header names are lowered before entering the hashtable.
019:         */
020:
021:        public class MimeHeaders implements  MimeHeaderHolder {
022:            Hashtable headers = null;
023:            MimeParser parser = null;
024:
025:            /**
026:             * A new header has been parsed.
027:             * @param name The name of the encountered header.
028:             * @param buf The byte buffer containing the value.
029:             * @param off Offset of the header value in the above buffer.
030:             * @param len Length of the value in the above header.
031:             * @exception MimeParserException if the parsing failed
032:             */
033:
034:            public void notifyHeader(String name, byte buf[], int off, int len)
035:                    throws MimeParserException {
036:                String lname = name.toLowerCase();
037:                String oldval = null;
038:                if (headers == null) {
039:                    headers = new Hashtable(5);
040:                } else {
041:                    oldval = (String) headers.get(lname);
042:                }
043:                String newval = ((oldval != null) ? oldval + ","
044:                        + new String(buf, 0, off, len) : new String(buf, 0,
045:                        off, len));
046:                headers.put(lname, newval);
047:            }
048:
049:            /**
050:             * The parsing is now about to start, take any appropriate action.
051:             * This hook can return a <strong>true</strong> boolean value to enforce
052:             * the MIME parser into transparent mode (eg the parser will <em>not</em>
053:             * try to parse any headers.
054:             * <p>This hack is primarily defined for HTTP/0.9 support, it might
055:             * also be usefull for other hacks.
056:             * @param parser The Mime parser.
057:             * @return A boolean <strong>true</strong> if the MimeParser shouldn't
058:             * continue the parsing, <strong>false</strong> otherwise.
059:             * @exception IOException if an IO error occurs.
060:             */
061:
062:            public boolean notifyBeginParsing(MimeParser parser)
063:                    throws IOException {
064:                return false;
065:            }
066:
067:            /**
068:             * All the headers have been parsed, take any appropriate actions.
069:             * @param parser The Mime parser.
070:             * @exception IOException if an IO error occurs.
071:             */
072:
073:            public void notifyEndParsing(MimeParser parser) throws IOException {
074:                return;
075:            }
076:
077:            /**
078:             * Set a header value.
079:             * @param name The header name.
080:             * @param value The header value.
081:             */
082:
083:            public void setValue(String name, String value) {
084:                if (headers == null)
085:                    headers = new Hashtable(5);
086:                headers.put(name.toLowerCase(), value);
087:            }
088:
089:            /**
090:             * Retreive a header value.
091:             * @param name The name of the header.
092:             * @return The value for this header, or <strong>null</strong> if 
093:             * undefined.
094:             */
095:
096:            public String getValue(String name) {
097:                return ((headers != null) ? (String) headers.get(name
098:                        .toLowerCase()) : null);
099:            }
100:
101:            /**
102:             * Enumerate the headers defined by the holder.
103:             * @return A enumeration of header names, or <strong>null</strong> if no
104:             * header is defined.
105:             */
106:
107:            public Enumeration enumerateHeaders() {
108:                if (headers == null)
109:                    return null;
110:                return headers.keys();
111:            }
112:
113:            /**
114:             * Get the entity stream attached to these headers, if any.
115:             * @return An InputStream instance, or <strong>null</strong> if no
116:             * entity available.
117:             */
118:
119:            public InputStream getInputStream() {
120:                return ((parser != null) ? parser.getInputStream() : null);
121:            }
122:
123:            /**
124:             * Dump all headers to the given stream.
125:             * @param out The stream to dump to.
126:             */
127:
128:            public void dump(PrintStream out) {
129:                Enumeration names = enumerateHeaders();
130:                if (names != null) {
131:                    while (names.hasMoreElements()) {
132:                        String name = (String) names.nextElement();
133:                        out.println(name + ": " + headers.get(name));
134:                    }
135:                }
136:            }
137:
138:            public MimeHeaders(MimeParser parser) {
139:                this .parser = parser;
140:            }
141:
142:            public MimeHeaders() {
143:            }
144:
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.