-
1. Re: VFS doesn't support scanning
starksm64 Apr 24, 2006 9:58 PM (in response to bill.burke)Yes, my feeling would be to add a visitor pattern to the ReadOnlyVFS:
// General acceptance visitor Iterator<VirtualFile> scan(Visitor acceptVisitor); // Simple visitor wrapper that would use a simple VirtualFile name regex Iterator<VirtualFile> scan(String fileNameRegex);
I don't believe there should be a jar specific VFS implementation as a jar it not a usable protocol due to the lack of nested jars. A jar is just a compacted file system rooted under the jar name. The VirtualFile implementations for a given VFS would have to deal with nested jars.
In terms of vfs behavior, its just a question of getting consistent behavior between a packed/unpacked jar. As you mentioned elsewhere this currently is not the case. Jars do have notions of directories so this should not be a big change to the current JarImpl. -
2. Re: VFS doesn't support scanning
bill.burke Apr 24, 2006 11:05 PM (in response to bill.burke)You are really contradicting yourself here. scanning can't be a VFS function if there is no Jar VFS implementation. Scanning should be a function of VirtualFile then.
-
3. Re: VFS doesn't support scanning
starksm64 Apr 25, 2006 12:54 AM (in response to bill.burke)Why? The vfs uses the getChildren call to traverse the files. The jar is handled by a vf impl. Show me why a jar needs to be treated as a seperate url protocol.
-
4. Re: VFS doesn't support scanning
starksm64 Apr 25, 2006 9:45 PM (in response to bill.burke)The following scan method has been added:
public interface ReadOnlyVFS { /** * Scan the VFS for files accepted by the visitor. * * @param acceptVisitor - the visitor that defines which files to accept * @return Iterator<VirtualFile> of the matches */ public Iterator<VirtualFile> scan(VFSVisitor acceptVisitor); } public interface VFSVisitor { /** * Visit a virtual file and indicate if it should be included in the scan. * A directory must be included if its children are to be scanned. * @param vf - the virtual file to test for inclusion * @return true if the file should be included. */ public boolean visit(VirtualFile vf); }
See the TestFileVFS.testClassScan for an example. Next is to add a testUnpackedClassScan to validate an unpacked jar vfs scan. -
5. Re: VFS doesn't support scanning
bill.burke Apr 28, 2006 2:07 AM (in response to bill.burke)I implemented something before reading this. Your interface didn't meet my requirements anyways. I added a getChildrenRecursively() to VirtualFile as I need to be able to do this on a per-child basis.
Also, I added some metadata to VirtualFile, specifically isArchive() so that you can know if it is a JAR, exploded jar, or just a plain file/directory.
Also fixed a few bugs. -
6. Re: VFS doesn't support scanning
starksm64 Apr 30, 2006 5:17 AM (in response to bill.burke)When do you need to know whether a file is a jar or not from an external use point of view?