Source Code Cross Referenced for HttpHeaderElement.java in  » Net » SkunkDAV » HTTPClient » 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 » Net » SkunkDAV » HTTPClient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)HttpHeaderElement.java				0.3-2 18/06/1999
003:         *
004:         *  This file is part of the HTTPClient package
005:         *  Copyright (C) 1996-1999  Ronald Tschalär
006:         *
007:         *  This library is free software; you can redistribute it and/or
008:         *  modify it under the terms of the GNU Lesser General Public
009:         *  License as published by the Free Software Foundation; either
010:         *  version 2 of the License, or (at your option) any later version.
011:         *
012:         *  This library is distributed in the hope that it will be useful,
013:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *  Lesser General Public License for more details.
016:         *
017:         *  You should have received a copy of the GNU Lesser General Public
018:         *  License along with this library; if not, write to the Free
019:         *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
020:         *  MA 02111-1307, USA
021:         *
022:         *  For questions, suggestions, bug-reports, enhancement-requests etc.
023:         *  I may be contacted at:
024:         *
025:         *  ronald@innovation.ch
026:         *
027:         */
028:
029:        package HTTPClient;
030:
031:        /**
032:         * This class holds a description of an http header element. It is used
033:         * by <code>HTTPClient.Util.parseHeader()</code>.
034:         *
035:         * @see Util#parseHeader(java.lang.String)
036:         * @see Util#getElement(java.util.Vector, java.lang.String)
037:         * @see Util#assembleHeader(java.util.Vector)
038:         * @version	0.3-2  18/06/1999
039:         * @author	Ronald Tschalär
040:         */
041:
042:        public class HttpHeaderElement {
043:            /** element name */
044:            private String name;
045:
046:            /** element value */
047:            private String value;
048:
049:            /** element parameters */
050:            private NVPair[] parameters;
051:
052:            // Constructors
053:
054:            /**
055:             * Construct an element with the given name. The value and parameters
056:             * are set to null. This can be used when a dummy element is constructed
057:             * for comparison or retrieval purposes.
058:             *
059:             * @param name   the name of the element
060:             */
061:            public HttpHeaderElement(String name) {
062:                this .name = name;
063:                this .value = null;
064:                parameters = new NVPair[0];
065:            }
066:
067:            /**
068:             * @param name   the first token in the element
069:             * @param value  the value part, or null
070:             * @param params the parameters
071:             */
072:            public HttpHeaderElement(String name, String value, NVPair[] params) {
073:                this .name = name;
074:                this .value = value;
075:                if (params != null) {
076:                    parameters = new NVPair[params.length];
077:                    System.arraycopy(params, 0, parameters, 0, params.length);
078:                } else
079:                    parameters = new NVPair[0];
080:            }
081:
082:            // Methods
083:
084:            /**
085:             * @return the name
086:             */
087:            public String getName() {
088:                return name;
089:            }
090:
091:            /**
092:             * @return the value
093:             */
094:            public String getValue() {
095:                return value;
096:            }
097:
098:            /**
099:             * @return the parameters
100:             */
101:            public NVPair[] getParams() {
102:                return parameters;
103:            }
104:
105:            /**
106:             * Two elements are equal if they have the same name. The comparison is
107:             * <em>case-insensitive</em>.
108:             *
109:             * @param obj the object to compare with
110:             * @return true if <var>obj</var> is an HttpHeaderElement with the same
111:             *         name as this element.
112:             */
113:            public boolean equals(Object obj) {
114:                if ((obj != null) && (obj instanceof  HttpHeaderElement)) {
115:                    String other = ((HttpHeaderElement) obj).name;
116:                    return name.equalsIgnoreCase(other);
117:                }
118:
119:                return false;
120:            }
121:
122:            /**
123:             * @return a string containing the HttpHeaderElement formatted as it
124:             *         would appear in a header
125:             */
126:            public String toString() {
127:                StringBuffer buf = new StringBuffer();
128:                appendTo(buf);
129:                return buf.toString();
130:            }
131:
132:            /**
133:             * Append this header element to the given buffer. This is basically a
134:             * more efficient version of <code>toString()</code> for assembling
135:             * multiple elements.
136:             *
137:             * @param buf the StringBuffer to append this header to
138:             * @see #toString()
139:             */
140:            public void appendTo(StringBuffer buf) {
141:                buf.append(name);
142:
143:                if (value != null) {
144:                    if (Util.needsQuoting(value)) {
145:                        buf.append("=\"");
146:                        buf.append(Util.quoteString(value, "\\\""));
147:                        buf.append('"');
148:                    } else {
149:                        buf.append('=');
150:                        buf.append(value);
151:                    }
152:                }
153:
154:                for (int idx = 0; idx < parameters.length; idx++) {
155:                    buf.append(";");
156:                    buf.append(parameters[idx].getName());
157:                    String pval = parameters[idx].getValue();
158:                    if (pval != null) {
159:                        if (Util.needsQuoting(pval)) {
160:                            buf.append("=\"");
161:                            buf.append(Util.quoteString(pval, "\\\""));
162:                            buf.append('"');
163:                        } else {
164:                            buf.append('=');
165:                            buf.append(pval);
166:                        }
167:                    }
168:                }
169:            }
170:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.