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