1 19 20 package org.openidex.search; 21 22 import org.netbeans.api.queries.SharabilityQuery; 23 import org.openide.filesystems.FileObject; 24 import org.openide.filesystems.FileUtil; 25 26 30 final class SharabilityFilter implements FileObjectFilter { 31 32 34 public boolean searchFile(FileObject file) 35 throws IllegalArgumentException { 36 if (file.isFolder()) { 37 throw new java.lang.IllegalArgumentException ( 38 "file (not folder) expected"); } 40 41 return SharabilityQuery.getSharability(FileUtil.toFile(file)) 42 != SharabilityQuery.NOT_SHARABLE; 43 } 44 45 47 public int traverseFolder(FileObject folder) 48 throws IllegalArgumentException { 49 if (!folder.isFolder()) { 50 throw new java.lang.IllegalArgumentException ( 51 "folder expected"); } 53 54 final int sharability = SharabilityQuery 55 .getSharability(FileUtil.toFile(folder)); 56 switch (sharability) { 57 case SharabilityQuery.NOT_SHARABLE: 58 return DO_NOT_TRAVERSE; 59 case SharabilityQuery.SHARABLE: 60 return TRAVERSE_ALL_SUBFOLDERS; 61 default: 62 return TRAVERSE; 63 } 64 } 65 66 } 67 | Popular Tags |