| 1 | |
package org.webslinger.commons.vfs.flat; |
| 2 | |
|
| 3 | |
import java.util.Collection; |
| 4 | |
import java.util.Iterator; |
| 5 | |
|
| 6 | |
import org.apache.commons.vfs.FileName; |
| 7 | |
import org.apache.commons.vfs.FileObject; |
| 8 | |
import org.apache.commons.vfs.FileSystem; |
| 9 | |
import org.apache.commons.vfs.FileSystemException; |
| 10 | |
|
| 11 | |
import org.webslinger.commons.vfs.handlers.attributes.AttributeMapper; |
| 12 | |
import org.webslinger.commons.vfs.handlers.attributes.AttributeMapperHandler; |
| 13 | |
import org.webslinger.commons.vfs.handlers.attributes.FlatAttributeMapper; |
| 14 | |
|
| 15 | |
public class StandardFlatAttributeMapperHandler implements AttributeMapperHandler { |
| 16 | |
protected final FlatFileSystem fs; |
| 17 | |
|
| 18 | 32 | public StandardFlatAttributeMapperHandler(FlatFileSystem fs) { |
| 19 | 32 | this.fs = fs; |
| 20 | 32 | } |
| 21 | |
|
| 22 | |
public AttributeMapper getAttributeMapper(FileName name) throws FileSystemException { |
| 23 | 1595 | FileObject realFile = fs.resolveFile(name).getRealFile(); |
| 24 | 1595 | FileObject parent = realFile.getParent(); |
| 25 | 1595 | FileObject attrFile = parent != null ? parent.resolveFile(realFile.getName().getBaseName() + "@") : realFile.resolveFile("@"); |
| 26 | 1595 | final FileName attrDirName = attrFile.getName(); |
| 27 | 1595 | final FileSystem realFS = attrFile.getFileSystem(); |
| 28 | 1595 | return new FlatAttributeMapper(fs) { |
| 29 | |
protected FileObject getAttributeDir() throws FileSystemException { |
| 30 | 29040 | return realFS.resolveFile(attrDirName); |
| 31 | |
} |
| 32 | |
|
| 33 | |
protected FileObject getAttributeFile(FileName name) throws FileSystemException { |
| 34 | 0 | return realFS.resolveFile(name); |
| 35 | |
} |
| 36 | |
}; |
| 37 | |
} |
| 38 | |
|
| 39 | |
public void excludeNames(Collection<String> names) { |
| 40 | 2631 | Iterator<String> it = names.iterator(); |
| 41 | 43483 | while (it.hasNext()) { |
| 42 | 40852 | String name = it.next(); |
| 43 | 40852 | if (name.endsWith("@")) it.remove(); |
| 44 | 40852 | } |
| 45 | 2631 | } |
| 46 | |
} |