01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: /** max size key */
28: private static final String MAX_SIZE_KEY = "maxsize";
29:
30: /** config builder singleton */
31: private static RamFileSystemConfigBuilder singleton = new RamFileSystemConfigBuilder();
32:
33: /**
34: * Constructor
35: */
36: private RamFileSystemConfigBuilder() {
37: super ();
38: }
39:
40: /**
41: * @return the config builder singleton
42: */
43: public static RamFileSystemConfigBuilder getInstance() {
44: return singleton;
45: }
46:
47: /**
48: * @inheritDoc
49: */
50: protected Class getConfigClass() {
51: return RamFileSystem.class;
52: }
53:
54: /**
55: * @param opts
56: * @return
57: * @see #setMaxSize
58: */
59: public int getMaxSize(FileSystemOptions opts) {
60: Integer size = (Integer) getParam(opts, MAX_SIZE_KEY);
61: if (size != null) {
62: return size.intValue();
63: } else {
64: return Integer.MAX_VALUE;
65: }
66: }
67:
68: /**
69: * sets the maximum size of the file system
70: *
71: * @param opts
72: * @param sizeInBytes
73: */
74: public void setMaxSize(FileSystemOptions opts, int sizeInBytes) {
75: setParam(opts, MAX_SIZE_KEY, new Integer(sizeInBytes));
76: }
77:
78: }
|