Source Code Cross Referenced for HttpProtocolParams.java in  » Net » httpcomponents-core-4.0-beta1 » org » apache » http » params » 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 » httpcomponents core 4.0 beta1 » org.apache.http.params 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/main/java/org/apache/http/params/HttpProtocolParams.java $
003:         * $Revision: 576089 $
004:         * $Date: 2007-09-16 14:39:56 +0200 (Sun, 16 Sep 2007) $
005:         *
006:         * ====================================================================
007:         * Licensed to the Apache Software Foundation (ASF) under one
008:         * or more contributor license agreements.  See the NOTICE file
009:         * distributed with this work for additional information
010:         * regarding copyright ownership.  The ASF licenses this file
011:         * to you under the Apache License, Version 2.0 (the
012:         * "License"); you may not use this file except in compliance
013:         * with the License.  You may obtain a copy of the License at
014:         *
015:         *   http://www.apache.org/licenses/LICENSE-2.0
016:         *
017:         * Unless required by applicable law or agreed to in writing,
018:         * software distributed under the License is distributed on an
019:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020:         * KIND, either express or implied.  See the License for the
021:         * specific language governing permissions and limitations
022:         * under the License.
023:         * ====================================================================
024:         *
025:         * This software consists of voluntary contributions made by many
026:         * individuals on behalf of the Apache Software Foundation.  For more
027:         * information on the Apache Software Foundation, please see
028:         * <http://www.apache.org/>.
029:         *
030:         */
031:
032:        package org.apache.http.params;
033:
034:        import org.apache.http.HttpVersion;
035:        import org.apache.http.ProtocolVersion;
036:        import org.apache.http.protocol.HTTP;
037:
038:        /**
039:         * This class implements an adaptor around the {@link HttpParams} interface
040:         * to simplify manipulation of the HTTP protocol specific parameters.
041:         * <br/>
042:         * Note that the <i>implements</i> relation to {@link CoreProtocolPNames}
043:         * is for compatibility with existing application code only. References to
044:         * the parameter names should use the interface, not this class.
045:         *
046:         * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
047:         * 
048:         * @version $Revision: 576089 $
049:         * 
050:         * @since 4.0
051:         *
052:         * @see CoreProtocolPNames
053:         */
054:        public final class HttpProtocolParams implements  CoreProtocolPNames {
055:
056:            /**
057:             */
058:            private HttpProtocolParams() {
059:                super ();
060:            }
061:
062:            /**
063:             * Returns the charset to be used for writing HTTP headers.
064:             * @return The charset
065:             */
066:            public static String getHttpElementCharset(final HttpParams params) {
067:                if (params == null) {
068:                    throw new IllegalArgumentException(
069:                            "HTTP parameters may not be null");
070:                }
071:                String charset = (String) params
072:                        .getParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET);
073:                if (charset == null) {
074:                    charset = HTTP.DEFAULT_PROTOCOL_CHARSET;
075:                }
076:                return charset;
077:            }
078:
079:            /**
080:             * Sets the charset to be used for writing HTTP headers.
081:             * @param charset The charset
082:             */
083:            public static void setHttpElementCharset(final HttpParams params,
084:                    final String charset) {
085:                if (params == null) {
086:                    throw new IllegalArgumentException(
087:                            "HTTP parameters may not be null");
088:                }
089:                params.setParameter(CoreProtocolPNames.HTTP_ELEMENT_CHARSET,
090:                        charset);
091:            }
092:
093:            /**
094:             * Returns the default charset to be used for writing content body, 
095:             * when no charset explicitly specified.
096:             * @return The charset
097:             */
098:            public static String getContentCharset(final HttpParams params) {
099:                if (params == null) {
100:                    throw new IllegalArgumentException(
101:                            "HTTP parameters may not be null");
102:                }
103:                String charset = (String) params
104:                        .getParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET);
105:                if (charset == null) {
106:                    charset = HTTP.DEFAULT_CONTENT_CHARSET;
107:                }
108:                return charset;
109:            }
110:
111:            /**
112:             * Sets the default charset to be used for writing content body,
113:             * when no charset explicitly specified.
114:             * @param charset The charset
115:             */
116:            public static void setContentCharset(final HttpParams params,
117:                    final String charset) {
118:                if (params == null) {
119:                    throw new IllegalArgumentException(
120:                            "HTTP parameters may not be null");
121:                }
122:                params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,
123:                        charset);
124:            }
125:
126:            /**
127:             * Returns {@link ProtocolVersion protocol version} to be used per default. 
128:             *
129:             * @return {@link ProtocolVersion protocol version}
130:             */
131:            public static ProtocolVersion getVersion(final HttpParams params) {
132:                if (params == null) {
133:                    throw new IllegalArgumentException(
134:                            "HTTP parameters may not be null");
135:                }
136:                Object param = params
137:                        .getParameter(CoreProtocolPNames.PROTOCOL_VERSION);
138:                if (param == null) {
139:                    return HttpVersion.HTTP_1_1;
140:                }
141:                return (ProtocolVersion) param;
142:            }
143:
144:            /**
145:             * Assigns the {@link ProtocolVersion protocol version} to be used by the 
146:             * HTTP methods that this collection of parameters applies to. 
147:             *
148:             * @param version the {@link ProtocolVersion protocol version}
149:             */
150:            public static void setVersion(final HttpParams params,
151:                    final ProtocolVersion version) {
152:                if (params == null) {
153:                    throw new IllegalArgumentException(
154:                            "HTTP parameters may not be null");
155:                }
156:                params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
157:                        version);
158:            }
159:
160:            public static String getUserAgent(final HttpParams params) {
161:                if (params == null) {
162:                    throw new IllegalArgumentException(
163:                            "HTTP parameters may not be null");
164:                }
165:                return (String) params
166:                        .getParameter(CoreProtocolPNames.USER_AGENT);
167:            }
168:
169:            public static void setUserAgent(final HttpParams params,
170:                    final String useragent) {
171:                if (params == null) {
172:                    throw new IllegalArgumentException(
173:                            "HTTP parameters may not be null");
174:                }
175:                params.setParameter(CoreProtocolPNames.USER_AGENT, useragent);
176:            }
177:
178:            public static boolean useExpectContinue(final HttpParams params) {
179:                if (params == null) {
180:                    throw new IllegalArgumentException(
181:                            "HTTP parameters may not be null");
182:                }
183:                return params.getBooleanParameter(
184:                        CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
185:            }
186:
187:            public static void setUseExpectContinue(final HttpParams params,
188:                    boolean b) {
189:                if (params == null) {
190:                    throw new IllegalArgumentException(
191:                            "HTTP parameters may not be null");
192:                }
193:                params.setBooleanParameter(
194:                        CoreProtocolPNames.USE_EXPECT_CONTINUE, b);
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.