1 19 20 package org.openidex.search; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import org.netbeans.api.queries.SharabilityQuery; 25 import org.netbeans.api.queries.VisibilityQuery; 26 import org.openide.filesystems.FileObject; 27 import org.openide.loaders.DataFolder; 28 import org.openide.nodes.Node; 29 30 37 public final class SearchInfoFactory { 38 39 45 public static final FileObjectFilter VISIBILITY_FILTER 46 = new VisibilityFilter(); 47 48 54 public static final FileObjectFilter SHARABILITY_FILTER 55 = new SharabilityFilter(); 56 57 59 private SearchInfoFactory() {} 60 61 115 167 187 public static SearchInfo createSearchInfo( 188 final FileObject folder, 189 final boolean recursive, 190 final FileObjectFilter[] filters) { 191 if (!folder.isFolder()) { 192 throw new IllegalArgumentException ("folder expected"); } 194 195 return new SimpleSearchInfo(DataFolder.findFolder(folder), 196 recursive, 197 filters); 198 } 199 200 220 public static SearchInfo createSearchInfo( 221 final FileObject[] folders, 222 final boolean recursive, 223 final FileObjectFilter[] filters) { 224 if (folders.length == 0) { 225 return SimpleSearchInfo.EMPTY_SEARCH_INFO; 226 } 227 228 if (folders.length == 1) { 229 return createSearchInfo(folders[0], 230 recursive, 231 filters); 232 } 233 234 for (int i = 0; i < folders.length; i++) { 235 if (!folders[i].isFolder()) { 236 throw new IllegalArgumentException ( 237 "folder expected (index " + i + ')'); } 239 } 240 241 SearchInfo[] nested = new SearchInfo[folders.length]; 242 for (int i = 0; i < folders.length; i++) { 243 nested[i] = createSearchInfo(folders[i], 244 recursive, 245 filters); 246 } 247 return new CompoundSearchInfo(nested); 248 } 249 250 265 public static SearchInfo createSearchInfoBySubnodes(Node node) { 266 return new SubnodesSearchInfo(node); 267 } 268 269 } 270 | Popular Tags |