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


001:        /*
002:         * ====================================================================
003:         *
004:         * The Apache Software License, Version 1.1
005:         *
006:         * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
007:         * reserved.
008:         *
009:         * Redistribution and use in source and binary forms, with or without
010:         * modification, are permitted provided that the following conditions
011:         * are met:
012:         *
013:         * 1. Redistributions of source code must retain the above copyright
014:         *    notice, this list of conditions and the following disclaimer.
015:         *
016:         * 2. Redistributions in binary form must reproduce the above copyright
017:         *    notice, this list of conditions and the following disclaimer in
018:         *    the documentation and/or other materials provided with the
019:         *    distribution.
020:         *
021:         * 3. The end-user documentation included with the redistribution, if
022:         *    any, must include the following acknowlegement:
023:         *       "This product includes software developed by the
024:         *        Apache Software Foundation (http://www.apache.org/)."
025:         *    Alternately, this acknowlegement may appear in the software itself,
026:         *    if and wherever such third-party acknowlegements normally appear.
027:         *
028:         * 4. The names "The Jakarta Project", "Commons", and "Apache Software
029:         *    Foundation" must not be used to endorse or promote products derived
030:         *    from this software without prior written permission. For written
031:         *    permission, please contact apache@apache.org.
032:         *
033:         * 5. Products derived from this software may not be called "Apache"
034:         *    nor may "Apache" appear in their names without prior written
035:         *    permission of the Apache Group.
036:         *
037:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
038:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
039:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
040:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
041:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
042:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
043:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
044:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
045:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
046:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
047:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
048:         * SUCH DAMAGE.
049:         * ====================================================================
050:         *
051:         * This software consists of voluntary contributions made by many
052:         * individuals on behalf of the Apache Software Foundation.  For more
053:         * information on the Apache Software Foundation, please see
054:         * <http://www.apache.org/>.
055:         */
056:        /* ====================================================================
057:         The Jicarilla Software License
058:
059:         Copyright (c) 2003 Leo Simons.
060:         All rights reserved.
061:
062:         Permission is hereby granted, free of charge, to any person obtaining
063:         a copy of this software and associated documentation files (the
064:         "Software"), to deal in the Software without restriction, including
065:         without limitation the rights to use, copy, modify, merge, publish,
066:         distribute, sublicense, and/or sell copies of the Software, and to
067:         permit persons to whom the Software is furnished to do so, subject to
068:         the following conditions:
069:
070:         The above copyright notice and this permission notice shall be
071:         included in all copies or substantial portions of the Software.
072:
073:         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
074:         EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
075:         MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
076:         IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
077:         CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
078:         TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
079:         SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
080:         ==================================================================== */
081:
082:        package org.jicarilla.http;
083:
084:        import org.jicarilla.lang.Recyclable;
085:        import org.jicarilla.http.util.NioUtil;
086:
087:        import java.io.Serializable;
088:        import java.nio.ByteBuffer;
089:
090:        /**
091:         * <p>Simple JavaBean representing an HTTP header.</p>
092:         *
093:         * This class is originally from the
094:         * <a href="http://jakarta.apache.org/">Jakarta Commons</a> httpclient
095:         * libraries.
096:         *
097:         * @author <a href="mailto: lsimons at jicarilla dot org">Leo Simons</a>
098:         * @author <a href="mailto:remm at apache dot org">Remy Maucherat</a>
099:         * @author <a href="mailto:mbowler at GargoyleSoftware dot com">Mike Bowler</a>
100:         * @version $Id: HTTPField.java,v 1.5 2004/03/23 13:37:48 lsimons Exp $
101:         */
102:        public class HTTPField implements  Recyclable, Serializable {
103:            // ----------------------------------------------------------------------
104:            //  Properties
105:            // ----------------------------------------------------------------------
106:            protected ByteBuffer m_name = null;
107:            protected ByteBuffer m_value = null;
108:
109:            // ----------------------------------------------------------------------
110:            //  Constructors
111:            // ----------------------------------------------------------------------
112:            /** Default constructor. */
113:            public HTTPField() {
114:                this (null, null);
115:            }
116:
117:            /**
118:             * Constructor.
119:             *
120:             * @param name The name.
121:             * @param value The value.
122:             */
123:            public HTTPField(final ByteBuffer name, final ByteBuffer value) {
124:                m_name = name;
125:                m_value = value;
126:            }
127:
128:            // ----------------------------------------------------------------------
129:            //  Getters/Setters
130:            // ----------------------------------------------------------------------
131:
132:            /**
133:             * Set the name.
134:             *
135:             * @param name The new name
136:             * @see #getName()
137:             */
138:            public void setName(final ByteBuffer name) {
139:                m_name = name;
140:            }
141:
142:            /**
143:             * Return the name.
144:             *
145:             * @return String name The name
146:             * @see #setName(ByteBuffer)
147:             */
148:            public ByteBuffer getName() {
149:                return m_name;
150:            }
151:
152:            public String getNameString() {
153:                return NioUtil.toString(m_name);
154:            }
155:
156:            /**
157:             * Set the value.
158:             *
159:             * @param value The new value.
160:             */
161:            public void setValue(final ByteBuffer value) {
162:                m_value = value;
163:            }
164:
165:            /**
166:             * Return the current value.
167:             *
168:             * @return String value The current value.
169:             */
170:            public ByteBuffer getValue() {
171:                return m_value;
172:            }
173:
174:            public String getValueString() {
175:                return NioUtil.toString(m_value);
176:            }
177:
178:            // ----------------------------------------------------------------------
179:            //  Utility methods
180:            // ----------------------------------------------------------------------
181:
182:            /**
183:             * Test if the given <i>object</i> is equal to me. In this implementation,
184:             * an <i>object</i> is equal to me iff it has the same runtime type and the
185:             * <i>name</i> and <i>value</i> attributes are both <tt>equal</tt> (or
186:             * <tt>==</tt>).
187:             *
188:             * @param object the {@link java.lang.Object} to compare to
189:             * @return true if the objects are equal.
190:             */
191:            public boolean equals(final Object object) {
192:                if (this  == object) {
193:                    return true;
194:                } else if (this .getClass().equals(object.getClass())) {
195:                    final HTTPField pair = (HTTPField) object;
196:                    return (null == m_name ? null == pair.m_name : m_name
197:                            .equals(pair.m_name))
198:                            && (null == m_value ? null == pair.m_value
199:                                    : m_value.equals(pair.m_value));
200:                } else {
201:                    return false;
202:                }
203:            }
204:
205:            /**
206:             * hashCode. Returns a hash code for this object such that if <tt>a.{@link
207:             * #equals equals}(b)</tt> then <tt>a.hashCode() == b.hashCode()</tt>.
208:             * @return The hash code.
209:             */
210:            public int hashCode() {
211:                return this .getClass().hashCode()
212:                        ^ (null == m_name ? 0 : m_name.hashCode())
213:                        ^ (null == m_value ? 0 : m_value.hashCode());
214:            }
215:
216:            /**
217:             * Get a {@link java.lang.String} representation of me, suitable
218:             * for use in an HTTP head.
219:             *
220:             * @return string value for a HTTP HEAD
221:             */
222:            public String toExternalForm() {
223:                final StringBuffer buffer = new StringBuffer();
224:                NioUtil.append(buffer, m_name);
225:                buffer.append(": ");
226:                NioUtil.append(buffer, m_value);
227:                buffer.append("\r\n");
228:
229:                return buffer.toString();
230:            }
231:
232:            /**
233:             * Returns a {@link java.lang.String} representation of me.
234:             *
235:             * @see #toExternalForm
236:             * @return String representation
237:             */
238:            public String toString() {
239:                return toExternalForm();
240:            }
241:
242:            // ----------------------------------------------------------------------
243:            //  Work Interface: Recyclable
244:            // ----------------------------------------------------------------------
245:            public void recycle() {
246:                m_name = null;
247:                m_value = null;
248:            }
249:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.