| 1 | |
package org.webslinger.ext.image; |
| 2 | |
|
| 3 | |
import java.awt.Rectangle; |
| 4 | |
import java.io.File; |
| 5 | |
import java.io.IOException; |
| 6 | |
|
| 7 | |
import org.webslinger.lang.ConcurrentCache; |
| 8 | |
import org.webslinger.util.TTLObject; |
| 9 | |
|
| 10 | 0 | public final class ImageSizeCache extends ConcurrentCache<File, TTLObject<Rectangle>> { |
| 11 | |
public ImageSizeCache(Class<?> owner, String field, String label) { |
| 12 | 0 | super(owner, field, label, ConcurrentCache.SOFT); |
| 13 | 0 | } |
| 14 | |
|
| 15 | |
public TTLObject<Rectangle> get(File key) throws IOException { |
| 16 | |
try { |
| 17 | 0 | return super.get(key); |
| 18 | 0 | } catch (IOException e) { |
| 19 | 0 | throw e; |
| 20 | 0 | } catch (RuntimeException e) { |
| 21 | 0 | throw e; |
| 22 | 0 | } catch (Exception e) { |
| 23 | 0 | throw (InternalError) new InternalError(e.getMessage()).initCause(e); |
| 24 | |
} |
| 25 | |
} |
| 26 | |
|
| 27 | |
protected TTLObject<Rectangle> createValue(File file) { |
| 28 | 0 | return new ImageBoxTTLObject(file); |
| 29 | |
} |
| 30 | |
} |