Coverage Report - org.mule.transport.file.filters.FilenameWildcardFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
FilenameWildcardFilter
22%
2/9
0%
0/2
1.5
 
 1  
 /*
 2  
  * $Id: FilenameWildcardFilter.java 10489 2008-01-23 17:53:38Z dfeist $
 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.transport.file.filters;
 12  
 
 13  
 import org.mule.api.MuleMessage;
 14  
 import org.mule.routing.filters.WildcardFilter;
 15  
 import org.mule.transport.file.FileConnector;
 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  12
         super();
 30  12
     }
 31  
 
 32  
     public FilenameWildcardFilter(String pattern)
 33  
     {
 34  0
         super(pattern);
 35  0
     }
 36  
 
 37  
     /**
 38  
      * Filter 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(MuleMessage message)
 60  
     {
 61  0
         return accept(message.getProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME));
 62  
     }
 63  
 
 64  
 }