View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.vfs.provider.ram;
    18
    19  import org.apache.commons.vfs.FileSystemConfigBuilder;
    20  import org.apache.commons.vfs.FileSystemOptions;
    21
    22  /***
    23   * Config Builder for the RAM filesystem.
    24   */
    25  public class RamFileSystemConfigBuilder extends FileSystemConfigBuilder
    26  {
    27
    28  	/*** max size key */
    29  	private static final String MAX_SIZE_KEY = "maxsize";
    30
    31  	/*** config builder singleton */
    32  	private static RamFileSystemConfigBuilder singleton = new RamFileSystemConfigBuilder();
    33
    34  	/***
    35  	 * Constructor
    36  	 */
    37  	private RamFileSystemConfigBuilder()
    38  	{
    39  		super();
    40  	}
    41
    42  	/***
    43  	 * @return the config builder singleton
    44  	 */
    45  	public static RamFileSystemConfigBuilder getInstance()
    46  	{
    47  		return singleton;
    48  	}
    49
    50  	/***
    51  	 * @inheritDoc
    52  	 */
    53  	protected Class getConfigClass()
    54  	{
    55  		return RamFileSystem.class;
    56  	}
    57
    58  	/***
    59  	 * @param opts
    60  	 * @return
    61  	 * @see #setMaxSize
    62  	 */
    63  	public int getMaxSize(FileSystemOptions opts)
    64  	{
    65  		Integer size = (Integer) getParam(opts, MAX_SIZE_KEY);
    66  		if (size != null)
    67  		{
    68  			return size.intValue();
    69  		}
    70  		else
    71  		{
    72  			return Integer.MAX_VALUE;
    73  		}
    74  	}
    75
    76  	/***
    77  	 * sets the maximum size of the file system
    78  	 *
    79  	 * @param opts
    80  	 * @param sizeInBytes
    81  	 */
    82  	public void setMaxSize(FileSystemOptions opts, int sizeInBytes)
    83  	{
    84  		setParam(opts, MAX_SIZE_KEY, new Integer(sizeInBytes));
    85  	}
    86
    87  }