1 22 package org.jboss.net.protocol; 23 24 import java.util.Arrays ; 25 import java.util.HashSet ; 26 import java.util.Collection ; 27 import java.util.StringTokenizer ; 28 import java.net.URL ; 29 import java.io.IOException ; 30 31 37 public abstract class URLListerBase implements URLLister 38 { 39 public Collection listMembers (URL baseUrl, String patterns, 40 boolean scanNonDottedSubDirs) throws IOException 41 { 42 StringTokenizer tokens = new StringTokenizer (patterns, ","); 44 String [] members = new String [tokens.countTokens ()]; 45 for (int i=0; tokens.hasMoreTokens (); i++) 46 { 47 String token = tokens.nextToken (); 48 members[i] = token.trim(); 50 } 51 URLFilter filter = new URLFilterImpl (members); 52 return listMembers (baseUrl, filter, scanNonDottedSubDirs); 53 } 54 55 public Collection listMembers (URL baseUrl, String patterns) throws IOException 56 { 57 return listMembers (baseUrl, patterns, false); 58 } 59 60 64 public static class URLFilterImpl implements URLFilter 65 { 66 protected boolean allowAll; 67 protected HashSet constants; 68 69 public URLFilterImpl (String [] patterns) 70 { 71 constants = new HashSet (Arrays.asList (patterns)); 72 allowAll = constants.contains ("*"); 73 } 74 75 public boolean accept (URL baseUrl, String name) 76 { 77 if (allowAll) 78 { 79 return true; 80 } 81 if (constants.contains (name)) 82 { 83 return true; 84 } 85 return false; 86 } 87 } 88 89 protected static final URLFilter acceptAllFilter = new URLFilter () 90 { 91 public boolean accept (URL baseURL, String memberName) 92 { 93 return true; 94 } 95 }; 96 } 97 | Popular Tags |