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 java.util.Arrays;
20  import java.util.Collection;
21  import java.util.Collections;
22  
23  import org.apache.commons.vfs.Capability;
24  import org.apache.commons.vfs.FileName;
25  import org.apache.commons.vfs.FileSystem;
26  import org.apache.commons.vfs.FileSystemException;
27  import org.apache.commons.vfs.FileSystemOptions;
28  import org.apache.commons.vfs.provider.AbstractOriginatingFileProvider;
29  import org.apache.commons.vfs.provider.FileProvider;
30  
31  /***
32   * RAM File Provider
33   */
34  public class RamFileProvider extends AbstractOriginatingFileProvider implements
35  		FileProvider
36  {
37  
38  	public final static Collection capabilities = Collections
39  			.unmodifiableCollection(Arrays.asList(new Capability[]
40  			{ Capability.CREATE, Capability.DELETE, Capability.RENAME,
41  					Capability.GET_TYPE, Capability.GET_LAST_MODIFIED,
42  					Capability.SET_LAST_MODIFIED_FILE,
43  					Capability.SET_LAST_MODIFIED_FOLDER,
44  					Capability.LIST_CHILDREN, Capability.READ_CONTENT,
45  					Capability.URI, Capability.WRITE_CONTENT,
46  					Capability.APPEND_CONTENT, Capability.RANDOM_ACCESS_READ,
47  					Capability.RANDOM_ACCESS_WRITE }));
48  
49  	/***
50  	 * Constructor
51  	 */
52  	public RamFileProvider()
53  	{
54  		super();
55  	}
56  
57  	/*
58  	 * (non-Javadoc)
59  	 * 
60  	 * @see org.apache.commons.vfs.provider.AbstractOriginatingFileProvider#doCreateFileSystem(org.apache.commons.vfs.FileName,
61  	 *      org.apache.commons.vfs.FileSystemOptions)
62  	 */
63  	protected FileSystem doCreateFileSystem(FileName name,
64  			FileSystemOptions fileSystemOptions) throws FileSystemException
65  	{
66  		return new RamFileSystem(name, fileSystemOptions);
67  	}
68  
69  	/*
70  	 * (non-Javadoc)
71  	 * 
72  	 * @see org.apache.commons.vfs.provider.FileProvider#getCapabilities()
73  	 */
74  	public Collection getCapabilities()
75  	{
76  		return capabilities;
77  	}
78  }