| 1 | |
package org.webslinger.vfs; |
| 2 | |
|
| 3 | |
import java.io.InputStream; |
| 4 | |
import java.io.IOException; |
| 5 | |
import java.io.OutputStream; |
| 6 | |
import java.util.Collection; |
| 7 | |
|
| 8 | |
public class VFSDelegateProxy<I, T, P, C> extends VFSDelegate<I, T, C> { |
| 9 | |
private final VFSDelegate<I, P, C> delegate; |
| 10 | |
private final Class<P> type; |
| 11 | |
|
| 12 | 104 | public VFSDelegateProxy(VFSDelegate<I, P, C> delegate, Class<P> type) { |
| 13 | 104 | this.delegate = delegate; |
| 14 | 104 | this.type = type; |
| 15 | 104 | } |
| 16 | |
|
| 17 | |
public Class<P> getType() { |
| 18 | 0 | return type; |
| 19 | |
} |
| 20 | |
|
| 21 | |
public VFSDelegate<I, P, C> getVFSDelegate() { |
| 22 | 4302 | return delegate; |
| 23 | |
} |
| 24 | |
|
| 25 | |
protected P getReal(T id) throws IOException { |
| 26 | 0 | return getType().cast(id); |
| 27 | |
} |
| 28 | |
|
| 29 | |
public I getId(T id) throws IOException { |
| 30 | 2943 | return getVFSDelegate().getId(getReal(id)); |
| 31 | |
} |
| 32 | |
|
| 33 | |
public Type getType(T id) throws IOException { |
| 34 | 0 | return getVFSDelegate().getType(getReal(id)); |
| 35 | |
} |
| 36 | |
|
| 37 | |
public long getLastModifiedTime(T id) throws IOException { |
| 38 | 854 | return getVFSDelegate().getLastModifiedTime(getReal(id)); |
| 39 | |
} |
| 40 | |
|
| 41 | |
public Collection<Permission> getPermissions(T id) throws IOException { |
| 42 | 0 | return getVFSDelegate().getPermissions(getReal(id)); |
| 43 | |
} |
| 44 | |
|
| 45 | |
public String absolutePath(T id) throws IOException { |
| 46 | 483 | return getVFSDelegate().absolutePath(getReal(id)); |
| 47 | |
} |
| 48 | |
|
| 49 | |
public String getBaseName(T id) throws IOException { |
| 50 | 0 | return getVFSDelegate().getBaseName(getReal(id)); |
| 51 | |
} |
| 52 | |
|
| 53 | |
public C getParent(T id) throws IOException { |
| 54 | 6 | return getVFSDelegate().getParent(getReal(id)); |
| 55 | |
} |
| 56 | |
|
| 57 | |
public C resolve(T id, String name) throws IOException { |
| 58 | 3 | return getVFSDelegate().resolve(getReal(id), name); |
| 59 | |
} |
| 60 | |
|
| 61 | |
public C[] getChildren(T id) throws IOException { |
| 62 | 0 | return getVFSDelegate().getChildren(getReal(id)); |
| 63 | |
} |
| 64 | |
|
| 65 | |
public boolean attributeExists(T id, String name) throws IOException { |
| 66 | 0 | return getVFSDelegate().attributeExists(getReal(id), name); |
| 67 | |
} |
| 68 | |
|
| 69 | |
public Object getAttribute(T id, String name) throws IOException { |
| 70 | 0 | return getVFSDelegate().getAttribute(getReal(id), name); |
| 71 | |
} |
| 72 | |
|
| 73 | |
public String getContentType(T id) throws IOException { |
| 74 | 0 | return getVFSDelegate().getContentType(getReal(id)); |
| 75 | |
} |
| 76 | |
|
| 77 | |
public long getLength(T id) throws IOException { |
| 78 | 6 | return getVFSDelegate().getLength(getReal(id)); |
| 79 | |
} |
| 80 | |
|
| 81 | |
public String getString(T id) throws IOException { |
| 82 | 0 | return getVFSDelegate().getString(getReal(id)); |
| 83 | |
} |
| 84 | |
|
| 85 | |
public InputStream openInput(T id) throws IOException { |
| 86 | 6 | return getVFSDelegate().openInput(getReal(id)); |
| 87 | |
} |
| 88 | |
|
| 89 | |
public OutputStream openOutput(T id, boolean append) throws IOException { |
| 90 | 0 | return getVFSDelegate().openOutput(getReal(id), append); |
| 91 | |
} |
| 92 | |
|
| 93 | |
public RandomAccess openRandom(T id, boolean read) throws IOException { |
| 94 | 0 | return getVFSDelegate().openRandom(getReal(id), read); |
| 95 | |
} |
| 96 | |
} |