1 22 package org.jboss.system.deployers; 23 24 import java.util.HashSet ; 25 import java.util.Set ; 26 import java.util.StringTokenizer ; 27 28 import org.jboss.virtual.VirtualFile; 29 import org.jboss.virtual.VirtualFileFilter; 30 31 37 public class SARArchiveFilter implements VirtualFileFilter 38 { 39 40 private final Set <String > patterns; 41 42 43 private final boolean allowAll; 44 45 51 public SARArchiveFilter(String patternsString) 52 { 53 if (patternsString == null) 54 throw new IllegalArgumentException ("Null patternsString"); 55 56 StringTokenizer tokens = new StringTokenizer (patternsString, ","); 57 patterns = new HashSet <String >(tokens.countTokens()); 58 for (int i=0; tokens.hasMoreTokens (); ++i) 59 { 60 String token = tokens.nextToken(); 61 patterns.add(token.trim()); 62 } 63 allowAll = patterns.contains("*"); 64 } 65 66 public boolean accepts(VirtualFile file) 67 { 68 if (allowAll) 69 return true; 70 return patterns.contains(file.getName()); 71 } 72 } 73 | Popular Tags |