blob: abafa535e86e99e47b53402e618e7f3eef6b8cd2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package NET.worlds.network;
import NET.worlds.console.Cursor;
import java.util.Observer;
public class CacheFile {
private URL url;
private CacheEntry entry;
private boolean active;
CacheFile(URL u, CacheEntry e) {
this.url = u;
this.active = true;
this.entry = e;
if (e != null) {
e.incRef();
}
}
@Override
public void finalize() {
if (this.active) {
this.active = false;
if (this.entry != null) {
this.entry.safeDecRef();
}
}
}
public synchronized void close() {
this.finalize();
}
public synchronized void markTemporary() {
if (this.entry != null) {
this.entry.remoteTime = 0L;
}
}
public boolean isActive() {
return this.active;
}
public void callWhenLoaded(Observer o) {
if (this.entry == null) {
o.update(null, this.url);
} else {
this.entry.addObserver(o);
}
}
public void waitUntilLoaded() {
if (this.entry != null) {
synchronized (this.entry) {
Cursor c = Cursor.getActive();
if (c == null) {
c = new Cursor(URL.make("system:WAIT_CURSOR"));
c.activate();
}
URL oldCursor = c.getURL();
c.setURL(URL.make("system:WAIT_CURSOR"));
while (this.active && !this.done()) {
try {
this.entry.wait();
} catch (InterruptedException var5) {
}
}
c.setURL(oldCursor);
}
}
}
public boolean error() {
return this.entry == null ? false : this.entry.state == 5 || this.entry.state == 6;
}
public boolean done() {
return this.entry == null ? true : this.entry.done();
}
public String getLocalName() {
return this.entry != null ? this.entry.localName : this.url.unalias();
}
public int bytesLoaded() {
return this.entry.bytes;
}
}
|