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(new Capability[] { Capability.CREATE, Capability.DELETE, Capability.RENAME,
38                      Capability.GET_TYPE, 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          super();
48      }
49  
50      /*
51       * (non-Javadoc)
52       *
53       * @see org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider#doCreateFileSystem(
54       * org.apache.commons.vfs2.FileName, org.apache.commons.vfs2.FileSystemOptions)
55       */
56      @Override
57      protected FileSystem doCreateFileSystem(final FileName name, final FileSystemOptions fileSystemOptions)
58              throws FileSystemException {
59          return new RamFileSystem(name, fileSystemOptions);
60      }
61  
62      /*
63       * (non-Javadoc)
64       *
65       * @see org.apache.commons.vfs2.provider.FileProvider#getCapabilities()
66       */
67      @Override
68      public Collection<Capability> getCapabilities() {
69          return capabilities;
70      }
71  }