01: /* ResourceInfo.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Tue Aug 30 18:27:16 2005, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2005 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.web.util.resource;
20:
21: import java.io.File;
22: import java.net.URL;
23:
24: /** Represents a resource.
25: * Note: we would like to use path as the key while we need file for loading,
26: * so we pack them as one object.
27: *
28: * @author tomyeh
29: */
30: /*package*/class ResourceInfo {
31: /*package*/final String path;
32: /*package*/final File file;
33: /*package*/final URL url;
34: /*package*/final Object extra;
35:
36: /**
37: * @param extra the extra paramter passed from {@link ResourceCaches#get}.
38: */
39: /*package*/ResourceInfo(String path, File file, Object extra) {
40: if (file == null)
41: throw new IllegalArgumentException("null");
42: this .path = path;
43: this .file = file;
44: this .url = null;
45: this .extra = extra;
46: }
47:
48: /*package*/ResourceInfo(String path, URL url, Object extra) {
49: if (url == null)
50: throw new IllegalArgumentException("url");
51: this .path = path;
52: this .file = null;
53: this .url = url;
54: this .extra = extra;
55: }
56:
57: //-- Object --//
58: public boolean equals(Object o) {
59: return (o instanceof ResourceInfo)
60: && path.equals(((ResourceInfo) o).path);
61: }
62:
63: public int hashCode() {
64: return this .path.hashCode();
65: }
66:
67: public String toString() {
68: return this.path;
69: }
70: }
|