| 1 | |
package org.webslinger.commons.vfs.flat; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.Collection; |
| 5 | |
import java.util.HashMap; |
| 6 | |
import java.util.Map; |
| 7 | |
|
| 8 | |
import org.apache.commons.vfs.Capability; |
| 9 | |
import org.apache.commons.vfs.FileName; |
| 10 | |
import org.apache.commons.vfs.FileObject; |
| 11 | |
import org.apache.commons.vfs.FileType; |
| 12 | |
import org.apache.commons.vfs.FileSystemException; |
| 13 | |
import org.apache.commons.vfs.FileSystemManager; |
| 14 | |
import org.apache.commons.vfs.FileSystemOptions; |
| 15 | |
|
| 16 | |
import org.webslinger.commons.vfs.FileSet; |
| 17 | |
import org.webslinger.commons.vfs.FilteringFileSystem; |
| 18 | |
import org.webslinger.commons.vfs.handlers.ExclusionHandler; |
| 19 | |
import org.webslinger.commons.vfs.handlers.HandlerFactory; |
| 20 | |
import org.webslinger.commons.vfs.handlers.attributes.AttributeMapperHandler; |
| 21 | |
import org.webslinger.commons.vfs.handlers.attributes.DefaultAttributeMapperHandler; |
| 22 | |
|
| 23 | 9711 | public class FlatFileSystem extends FilteringFileSystem<FileName, FlatFileObject, FlatFileSystem> implements ExclusionHandler { |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
private final FileObject root; |
| 42 | |
private AttributeMapperHandler attributeHandler; |
| 43 | |
private ExclusionHandler exclusionHandler; |
| 44 | |
|
| 45 | |
public FlatFileSystem(FileName name, FileObject root, FileSystemOptions options) throws FileSystemException { |
| 46 | 33 | super(name, root, options); |
| 47 | 33 | this.root = root; |
| 48 | 33 | } |
| 49 | |
|
| 50 | |
public FlatFileObject createFile(FileName name) throws FileSystemException { |
| 51 | |
|
| 52 | 7125 | return new FlatFileObject(name, this, root.resolveFile(name.getPath().substring(1))); |
| 53 | |
} |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
protected AttributeMapperHandler getAttributeHandler() throws FileSystemException { |
| 69 | 4226 | if (attributeHandler != null) return attributeHandler; |
| 70 | 32 | HandlerFactory<AttributeMapperHandler, FlatFileSystem> factory = FlatConfigBuilder.getInstance().getAttributeMapperHandlerFactory(getFileSystemOptions()); |
| 71 | 32 | if (factory != null) attributeHandler = factory.getHandler(this, AttributeMapperHandler.class); |
| 72 | 32 | if (attributeHandler == null) attributeHandler = new StandardFlatAttributeMapperHandler(this); |
| 73 | 32 | return attributeHandler; |
| 74 | |
} |
| 75 | |
|
| 76 | |
protected ExclusionHandler getExclusionHandler() throws FileSystemException { |
| 77 | 2631 | if (exclusionHandler != null) return exclusionHandler; |
| 78 | 27 | HandlerFactory<ExclusionHandler, FlatFileSystem> factory = FlatConfigBuilder.getInstance().getExclusionHandlerFactory(getFileSystemOptions()); |
| 79 | 27 | if (factory != null) exclusionHandler = factory.getHandler(this, ExclusionHandler.class); |
| 80 | 27 | if (exclusionHandler == null) exclusionHandler = new ExclusionHandler.NullHandler(); |
| 81 | 27 | return exclusionHandler; |
| 82 | |
} |
| 83 | |
|
| 84 | |
protected FileSet getRealFiles(FlatFileObject file) throws FileSystemException { |
| 85 | 0 | return createFileSet(new FileObject[] {file.getRealFile()}, new FileObject[0]); |
| 86 | |
} |
| 87 | |
|
| 88 | |
protected FlatFileObject[] newArray(int length) { |
| 89 | 2586 | return new FlatFileObject[length]; |
| 90 | |
} |
| 91 | |
|
| 92 | |
public void excludeNames(Collection<String> names) throws FileSystemException { |
| 93 | 2631 | getAttributeHandler().excludeNames(names); |
| 94 | 2631 | ExclusionHandler exclusionHandler = getExclusionHandler(); |
| 95 | 2631 | if (exclusionHandler == null) return; |
| 96 | 2631 | exclusionHandler.excludeNames(names); |
| 97 | 2631 | } |
| 98 | |
} |
| 99 | |
|