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 org.codehaus.plexus.components.io.functions.NameSupplier;
20  
21  import java.io.IOException;
22  import java.io.InputStream;
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      /**
34       * Returns the resources name, which may include path components,
35       * like directory names, or something like that. The resources name
36       * is expected to be a relative name and the path components must
37       * be separated by {@link java.io.File#pathSeparator}
38       */
39      String getName();
40  
41      /**
42       * Creates an {@link InputStream}, which may be used to read
43       * the files contents. This is useful, if the file selector
44       * comes to a decision based on the files contents.
45       */
46      InputStream getContents() throws IOException;
47  
48      /**
49       * Returns, whether the {@link FileInfo} refers to a file.
50       * This does not necessarily mean that the underlying representation *is* a file on disk,
51       * but that this resource represents a file.
52       */
53      boolean isFile();
54  
55      /**
56       * Returns, whether the {@link FileInfo} refers to a directory.
57       * This does not necessarily mean that the underlying representation *is* a directory on disk,
58       * but that this resource represents a directory.
59       */
60      boolean isDirectory();
61  
62      /**
63       * Returns, whether the {@link FileInfo} refers to a symlink.
64       * This does not necessarily mean that the underlying representation *is* a symlink on disk,
65       * but that this resource represents a symlink.
66       * This method will return "false" for java versions prior to java7.
67       */
68      boolean isSymbolicLink();
69  }