| 1 | |
package org.webslinger; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
import javax.servlet.ServletException; |
| 5 | |
|
| 6 | |
import org.webslinger.container.FileInfo; |
| 7 | |
|
| 8 | |
public class ReadObjectFilterCreator extends FileInfo.ReadObjectCreator { |
| 9 | |
private final String filterAttribute; |
| 10 | |
|
| 11 | |
public ReadObjectFilterCreator(String typeAttribute, String defaultType, String filterAttribute) { |
| 12 | 0 | super(typeAttribute, defaultType); |
| 13 | 0 | this.filterAttribute = filterAttribute; |
| 14 | 0 | } |
| 15 | |
|
| 16 | |
public Object createValue(FileInfo fi, String name) throws IOException { |
| 17 | 0 | Object value = super.createValue(fi, name); |
| 18 | 0 | String filter = (String) fi.getAttribute(filterAttribute); |
| 19 | 0 | if (filter == null) return value; |
| 20 | 0 | WebslingerServletContext wsc = fi.getContainer().getWebslingerServletContext(); |
| 21 | |
try { |
| 22 | 0 | return wsc.run(wsc.resolve(filter), null, null, value); |
| 23 | 0 | } catch (ServletException e) { |
| 24 | 0 | throw (IOException) new IOException(e.getMessage()).initCause(e); |
| 25 | |
} |
| 26 | |
} |
| 27 | |
} |