View Javadoc
1   package org.codehaus.plexus.components.io.fileselectors;
2   
3   /*
4    * Copyright 2007 The Codehaus Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  import java.io.IOException;
20  import java.io.InputStream;
21  
22  import org.codehaus.plexus.components.io.functions.NameSupplier;
23  
24  /**
25   * An object implementing this interface is passed to the
26   * file selector when the method
27   * {@link FileSelector#isSelected(FileInfo)}
28   * is invoked. This object provides information about
29   * the file to select or deselect.
30   */
31  public interface FileInfo extends NameSupplier {
32      /**
33       * Returns the resources name, which may include path components,
34       * like directory names, or something like that. The resources name
35       * is expected to be a relative name and the path components must
36       * be separated by {@link java.io.File#pathSeparator}
37       */
38      String getName();
39  
40      /**
41       * Creates an {@link InputStream}, which may be used to read
42       * the files contents. This is useful, if the file selector
43       * comes to a decision based on the files contents.
44       */
45      InputStream getContents() throws IOException;
46  
47      /**
48       * Returns, whether the {@link FileInfo} refers to a file.
49       * This does not necessarily mean that the underlying representation *is* a file on disk,
50       * but that this resource represents a file.
51       */
52      boolean isFile();
53  
54      /**
55       * Returns, whether the {@link FileInfo} refers to a directory.
56       * This does not necessarily mean that the underlying representation *is* a directory on disk,
57       * but that this resource represents a directory.
58       */
59      boolean isDirectory();
60  
61      /**
62       * Returns, whether the {@link FileInfo} refers to a symlink.
63       * This does not necessarily mean that the underlying representation *is* a symlink on disk,
64       * but that this resource represents a symlink.
65       * This method will return "false" for java versions prior to java7.
66       */
67      boolean isSymbolicLink();
68  }