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.cpptasks;
21
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.List;
25
26 /**
27 * Implementation of FileVisitor that collects visited files for later
28 * retrieval.
29 *
30 * @author Curt Arnold
31 *
32 */
33 public final class MockFileCollector implements FileVisitor {
34
35 /**
36 * list of fileName parameter values.
37 */
38 private final List fileNames = new ArrayList();
39
40 /**
41 * list of baseDir parameter values.
42 */
43 private final List baseDirs = new ArrayList();
44
45 /**
46 * Constructor.
47 *
48 */
49 public MockFileCollector() {
50 }
51
52 /**
53 * Get value of baseDir parameter for the specified index.
54 *
55 * @param index
56 * index
57 * @return value of baseDir parameter
58 */
59 public File getBaseDir(final int index) {
60 return (File) this.baseDirs.get(index);
61 }
62
63 /**
64 * Get value of fileName parameter for a specified index.
65 *
66 * @param index
67 * index
68 * @return value of failName parameter
69 */
70 public String getFileName(final int index) {
71 return (String) this.fileNames.get(index);
72 }
73
74 /**
75 * Get count of calls to FileVisitor.visit.
76 *
77 * @return count of calls.
78 */
79 public int size() {
80 return this.fileNames.size();
81 }
82
83 /**
84 * Implementation of FileVisitor.visit.
85 *
86 * @param baseDir
87 * base directory
88 * @param fileName
89 * file name
90 */
91 @Override
92 public void visit(final File baseDir, final String fileName) {
93 this.fileNames.add(fileName);
94 this.baseDirs.add(baseDir);
95 }
96 }