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 */
017package org.apache.commons.vfs2.impl;
018
019import org.apache.commons.vfs2.FileSystem;
020import org.apache.commons.vfs2.FileSystemConfigBuilder;
021import org.apache.commons.vfs2.FileSystemOptions;
022import org.apache.commons.vfs2.UserAuthenticator;
023
024/**
025 * Default options usable for all file systems.
026 */
027public class DefaultFileSystemConfigBuilder extends FileSystemConfigBuilder {
028
029    /**
030     * Dummy class that implements FileSystem.
031     */
032    abstract static class DefaultFileSystem implements FileSystem {
033    }
034
035    /** The default FileSystemConfigBuilder */
036    private static final DefaultFileSystemConfigBuilder BUILDER = new DefaultFileSystemConfigBuilder();
037
038    /**
039     * Gets the singleton builder.
040     *
041     * @return the singleton builder.
042     */
043    public static DefaultFileSystemConfigBuilder getInstance() {
044        return BUILDER;
045    }
046
047    /**
048     * Constructs a new instance.
049     */
050    public DefaultFileSystemConfigBuilder() {
051        // empty
052    }
053
054    @Override
055    protected Class<? extends FileSystem> getConfigClass() {
056        return DefaultFileSystem.class;
057    }
058
059    /**
060     * Gets the UserAuthenticator parameter.
061     *
062     * @see #setUserAuthenticator
063     * @param opts The FileSystemOptions.
064     * @return The UserAuthenticator parameter..
065     */
066    public UserAuthenticator getUserAuthenticator(final FileSystemOptions opts) {
067        return getParam(opts, "userAuthenticator");
068    }
069
070    /**
071     * Sets the user authenticator to get authentication information.
072     *
073     * @param opts The FileSystemOptions.
074     * @param userAuthenticator The UserAuthenticator.
075     */
076    public void setUserAuthenticator(final FileSystemOptions opts, final UserAuthenticator userAuthenticator) {
077        setParam(opts, "userAuthenticator", userAuthenticator);
078    }
079}