View Javadoc

1   /*
2    * #%L
3    * Native ARchive plugin for Maven
4    * %%
5    * Copyright (C) 2002 - 2014 NAR Maven Plugin developers.
6    * %%
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * 
11   * http://www.apache.org/licenses/LICENSE-2.0
12   * 
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   * #L%
19   */
20  package com.github.maven_nar;
21  
22  import java.io.File;
23  import java.util.List;
24  
25  /**
26   * An include path.
27   *
28   * Binds together include path itself (e.g. folder path) and allowed
29   * include file masks (e.g. *.h).
30   *
31   * @author Ivan Drobyshevskyi
32   */
33  public class IncludePath {
34    /**
35     * Include path itself.
36     *
37     * @parameter
38     * @required
39     */
40    private String path;
41  
42    /**
43     * List of include files masks.
44     *
45     * @parameter
46     */
47    private List/* <String> */includes;
48  
49    /**
50     * File corresponding to the path above.
51     */
52    private File file;
53  
54    boolean exists() {
55      return this.file.exists() && this.file.isDirectory();
56    }
57  
58    public File getFile() {
59      return this.file;
60    }
61  
62    public final String getIncludes() {
63      final StringBuilder includesString = new StringBuilder();
64  
65      if (this.includes == null) {
66        return null;
67      }
68  
69      for (final String s : (List<String>) this.includes) {
70        includesString.append(s).append(",");
71      }
72  
73      return includesString.toString();
74    }
75  
76    public String getPath() {
77      return this.path;
78    }
79  
80    public void set(final String path) {
81      setPath(path);
82    }
83  
84    public void setPath(final String path) {
85      this.path = path;
86      this.file = new File(path);
87    }
88  }