1
2
3
4
5
6
7 package nl.mineleni.cbsviewer.servlet.wms.cache;
8
9 import java.awt.image.BufferedImage;
10
11
12
13
14
15
16
17 public class CacheImage implements CachableImage<BufferedImage> {
18
19
20 private final long expireBy;
21
22
23 private String fName;
24
25
26 private BufferedImage image = null;
27
28
29
30
31
32
33
34
35
36
37
38 public CacheImage(final BufferedImage image, final String filename,
39 final long expireBy) {
40 this.image = image;
41 this.fName = filename;
42 this.expireBy = expireBy;
43 }
44
45
46
47
48
49
50
51
52
53 public CacheImage(final BufferedImage image, final long secondsToLive) {
54 final long expires = secondsToLive != -1 ? System.currentTimeMillis()
55 + (secondsToLive * 1000) : secondsToLive;
56 this.image = image;
57 this.expireBy = expires;
58 }
59
60
61
62
63
64
65 @Override
66 public long getExpireBy() {
67 return this.expireBy;
68 }
69
70
71
72
73
74
75 @Override
76 public BufferedImage getItem() {
77 return this.image;
78 }
79
80
81
82
83
84
85 @Override
86 public String getName() {
87 return this.fName;
88 }
89
90
91
92
93
94
95 @Override
96 public boolean isValid() {
97 return ((this.image != null) && (this.fName != null) && (this.expireBy > System
98 .currentTimeMillis()));
99 }
100
101
102
103
104
105
106 public BufferedImage getImage() {
107 return getItem();
108 }
109
110
111
112
113
114
115
116 public void setFileName(final String name) {
117 this.fName = name;
118 }
119 }