1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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 }