001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.commons.vfs.provider.http;
018:
019: import org.apache.commons.vfs.FileSystemConfigBuilder;
020: import org.apache.commons.vfs.FileSystemOptions;
021: import org.apache.commons.vfs.UserAuthenticator;
022: import org.apache.commons.httpclient.Cookie;
023:
024: /**
025: * Configuration options for HTTP
026: *
027: * @author <a href="mailto:imario@apache.org">Mario Ivankovits</a>
028: * @version $Revision: 480428 $ $Date: 2006-11-28 22:15:24 -0800 (Tue, 28 Nov 2006) $
029: */
030: public class HttpFileSystemConfigBuilder extends
031: FileSystemConfigBuilder {
032: private final static HttpFileSystemConfigBuilder builder = new HttpFileSystemConfigBuilder();
033:
034: public static HttpFileSystemConfigBuilder getInstance() {
035: return builder;
036: }
037:
038: private HttpFileSystemConfigBuilder() {
039: }
040:
041: /**
042: * Set the charset used for url encoding<br>
043: *
044: * @param chaset the chaset
045: */
046: public void setUrlCharset(FileSystemOptions opts, String chaset) {
047: setParam(opts, "urlCharset", chaset);
048: }
049:
050: /**
051: * Set the charset used for url encoding<br>
052: *
053: * @return the chaset
054: */
055: public String getUrlCharset(FileSystemOptions opts) {
056: return (String) getParam(opts, "urlCharset");
057: }
058:
059: /**
060: * Set the proxy to use for http connection.<br>
061: * You have to set the ProxyPort too if you would like to have the proxy relly used.
062: *
063: * @param proxyHost the host
064: * @see #setProxyPort
065: */
066: public void setProxyHost(FileSystemOptions opts, String proxyHost) {
067: setParam(opts, "proxyHost", proxyHost);
068: }
069:
070: /**
071: * Set the proxy-port to use for http connection
072: * You have to set the ProxyHost too if you would like to have the proxy relly used.
073: *
074: * @param proxyPort the port
075: * @see #setProxyHost
076: */
077: public void setProxyPort(FileSystemOptions opts, int proxyPort) {
078: setParam(opts, "proxyPort", new Integer(proxyPort));
079: }
080:
081: /**
082: * Get the proxy to use for http connection
083: * You have to set the ProxyPort too if you would like to have the proxy relly used.
084: *
085: * @return proxyHost
086: * @see #setProxyPort
087: */
088: public String getProxyHost(FileSystemOptions opts) {
089: return (String) getParam(opts, "proxyHost");
090: }
091:
092: /**
093: * Get the proxy-port to use for http the connection
094: * You have to set the ProxyHost too if you would like to have the proxy relly used.
095: *
096: * @return proxyPort: the port number or 0 if it is not set
097: * @see #setProxyHost
098: */
099: public int getProxyPort(FileSystemOptions opts) {
100: if (!hasParam(opts, "proxyPort")) {
101: return 0;
102: }
103:
104: return ((Number) getParam(opts, "proxyPort")).intValue();
105: }
106:
107: /**
108: * Set the proxy authenticator where the system should get the credentials from
109: */
110: public void setProxyAuthenticator(FileSystemOptions opts,
111: UserAuthenticator authenticator) {
112: setParam(opts, "proxyAuthenticator", authenticator);
113: }
114:
115: /**
116: * Get the proxy authenticator where the system should get the credentials from
117: */
118: public UserAuthenticator getProxyAuthenticator(
119: FileSystemOptions opts) {
120: return (UserAuthenticator) getParam(opts, "proxyAuthenticator");
121: }
122:
123: /**
124: * The cookies to add to the reqest
125: */
126: public void setCookies(FileSystemOptions opts, Cookie[] cookies) {
127: setParam(opts, "cookies", cookies);
128: }
129:
130: /**
131: * The cookies to add to the reqest
132: */
133: public Cookie[] getCookies(FileSystemOptions opts) {
134: return (Cookie[]) getParam(opts, "cookies");
135: }
136:
137: protected Class getConfigClass() {
138: return HttpFileSystem.class;
139: }
140: }
|