Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FindEvent |
|
| 1.1111111111111112;1.111 |
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.finder; | |
18 | ||
19 | import java.io.File; | |
20 | import java.util.EventObject; | |
21 | ||
22 | /** | |
23 | * Event upon which notification is made to a FindListener. | |
24 | * It contains references to the Finder and the Directory in which | |
25 | * the event occured. | |
26 | * Depending on the particular occasion, it may also contain | |
27 | * a set of files or a file. | |
28 | */ | |
29 | // TODO: Extend this to 3 subclasses to stop having 1 class with 3 types | |
30 | public class FindEvent extends EventObject { | |
31 | ||
32 | private File directory; | |
33 | private Finder finder; | |
34 | private File file; | |
35 | private File[] files; | |
36 | private String type; | |
37 | ||
38 | public FindEvent(Finder finder, String type, File directory) { | |
39 | 0 | super(directory); |
40 | 0 | this.finder = finder; |
41 | 0 | this.directory = directory; |
42 | 0 | this.type = type; |
43 | 0 | } |
44 | ||
45 | public FindEvent(Finder finder, String type, File directory, File file) { | |
46 | 0 | super(file); |
47 | 0 | this.finder = finder; |
48 | 0 | this.directory = directory; |
49 | 0 | this.file = file; |
50 | 0 | this.type = type; |
51 | 0 | } |
52 | ||
53 | public FindEvent(Finder finder, String type, File directory, File[] files) { | |
54 | 0 | super(files); |
55 | 0 | this.finder = finder; |
56 | 0 | this.directory = directory; |
57 | 0 | this.files = files; |
58 | 0 | this.type = type; |
59 | 0 | } |
60 | ||
61 | public File getDirectory() { | |
62 | 0 | return this.directory; |
63 | } | |
64 | ||
65 | public Finder getFinder() { | |
66 | 0 | return this.finder; |
67 | } | |
68 | ||
69 | /** | |
70 | * File found. | |
71 | */ | |
72 | public File getFile() { | |
73 | 0 | return this.file; |
74 | } | |
75 | ||
76 | /** | |
77 | * Files found in a directory. | |
78 | */ | |
79 | public File[] getFiles() { | |
80 | 0 | return this.files; |
81 | } | |
82 | ||
83 | public String getType() { | |
84 | 0 | return this.type; |
85 | } | |
86 | ||
87 | public String toString() { | |
88 | 0 | String str = "FindEvent - "+this.type+"; dir="+this.directory+", file="+this.file; |
89 | 0 | if(this.files != null) { |
90 | 0 | str += ", files="+java.util.Arrays.asList(this.files); |
91 | } | |
92 | 0 | return str; |
93 | } | |
94 | ||
95 | } |