Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FilenameWildcardFilter |
|
| 1.5;1.5 |
1 | /* | |
2 | * $Id: FilenameWildcardFilter.java 7976 2007-08-21 14:26:13Z dirk.olmes $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.providers.file.filters; | |
12 | ||
13 | import org.mule.providers.file.FileConnector; | |
14 | import org.mule.routing.filters.WildcardFilter; | |
15 | import org.mule.umo.UMOMessage; | |
16 | ||
17 | import java.io.File; | |
18 | import java.io.FilenameFilter; | |
19 | ||
20 | /** | |
21 | * <code>FilenameWildcardFilter</code> filters incoming files from a directory, | |
22 | * based on file patterns. | |
23 | */ | |
24 | public class FilenameWildcardFilter extends WildcardFilter implements FilenameFilter | |
25 | { | |
26 | ||
27 | public FilenameWildcardFilter() | |
28 | { | |
29 | 0 | super(); |
30 | 0 | } |
31 | ||
32 | public FilenameWildcardFilter(String pattern) | |
33 | { | |
34 | 0 | super(pattern); |
35 | 0 | } |
36 | ||
37 | /** | |
38 | * UMOFilter condition decider method. <p/> Returns | |
39 | * <code>boolean</code> <code>TRUE</code> if the file conforms to an | |
40 | * acceptable pattern or <code>FALSE</code> otherwise. | |
41 | * | |
42 | * @param dir The directory to apply the filter to. | |
43 | * @param name The name of the file to apply the filter to. | |
44 | * @return indication of acceptance as boolean. | |
45 | */ | |
46 | public boolean accept(File dir, String name) | |
47 | { | |
48 | 0 | if (name == null) |
49 | { | |
50 | 0 | logger.warn("The filename and/or directory was null"); |
51 | 0 | return false; |
52 | } | |
53 | else | |
54 | { | |
55 | 0 | return accept(name); |
56 | } | |
57 | } | |
58 | ||
59 | public boolean accept(UMOMessage message) | |
60 | { | |
61 | 0 | return accept(message.getProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME)); |
62 | } | |
63 | ||
64 | } |