KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > file > filters > FilenameWildcardFilter


1 /*
2  * $Id: FilenameWildcardFilter.java 4219 2006-12-09 10:15:14Z lajos $
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 MuleSource MPL
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 java.io.File JavaDoc;
14 import java.io.FilenameFilter JavaDoc;
15
16 import org.mule.providers.file.FileConnector;
17 import org.mule.routing.filters.WildcardFilter;
18 import org.mule.umo.UMOMessage;
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 JavaDoc
25 {
26
27     public FilenameWildcardFilter()
28     {
29         super();
30     }
31
32     public FilenameWildcardFilter(String JavaDoc pattern)
33     {
34         super(pattern);
35     }
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 JavaDoc dir, String JavaDoc name)
47     {
48         if (name == null)
49         {
50             logger.warn("The filename and/or directory was null");
51             return false;
52         }
53         else
54         {
55             return accept(name);
56         }
57     }
58
59     public boolean accept(UMOMessage message)
60     {
61         return accept(message.getProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME));
62     }
63
64 }
65
Popular Tags