1 22 package org.jboss.deployers.plugins.structure; 23 24 import org.jboss.virtual.VirtualFile; 25 import org.jboss.virtual.VirtualFileFilterWithAttributes; 26 import org.jboss.virtual.VisitorAttributes; 27 28 34 public class MetaDataMatchFilter implements VirtualFileFilterWithAttributes 35 { 36 37 private String name; 38 39 40 private String suffix; 41 42 43 private VisitorAttributes attributes; 44 45 53 public MetaDataMatchFilter(String name, String suffix) 54 { 55 this(name, suffix, null); 56 } 57 58 66 public MetaDataMatchFilter(String name, String suffix, VisitorAttributes attributes) 67 { 68 if (name == null && suffix == null) 69 throw new IllegalArgumentException ("Null name and suffix"); 70 this.name = name; 71 this.suffix = suffix; 72 if (attributes == null) 73 attributes = VisitorAttributes.LEAVES_ONLY; 74 this.attributes = attributes; 75 } 76 77 public VisitorAttributes getAttributes() 78 { 79 return attributes; 80 } 81 82 public boolean accepts(VirtualFile file) 83 { 84 String fileName = file.getName(); 85 if (name != null && fileName.equals(name)) 86 return true; 87 if (suffix != null) 88 return fileName.endsWith(suffix); 89 return false; 90 } 91 } 92 | Popular Tags |