1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.services.webpage;
18
19 /***
20 * A cached resource object, stored in memory to optimize access to static resources
21 * such as images and style sheets.
22 *
23 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
24 * @version $Id: CachedResource.java,v 1.3 2004/02/23 03:46:26 jford Exp $
25 */
26
27 public class CachedResource
28 {
29 private int contentType;
30 private byte[] content;
31
32 /***
33 * Constructor for a cached resource.
34 *
35 * @param contentType The HTTP content type for a cached resource as defined
36 * in WebPageHelper, i.e. WebPageHelper.CT_HTML, WebPageHelper.CT_IMAGE....
37 * @param content The byte array of content this cached. This content can be
38 * binary images, or static text such as scripts and style sheets.
39 *
40 */
41 public CachedResource(int contentType, byte[] content)
42 {
43 this.contentType = contentType;
44 this.content = new byte[content.length];
45 System.arraycopy(content, 0, this.content, 0, this.content.length);
46 }
47
48 /***
49 * Gets the content of this resource in a byte array.
50 *
51 * @return A byte array of the resource's content.
52 */
53 public byte[] getContent()
54 {
55 return content;
56 }
57
58 /***
59 * Accessor to get the content type for this resource as defined in WebPageHelper
60 *
61 * @return The content type for this resource.
62 */
63 public int getContentType()
64 {
65 return contentType;
66 }
67
68
69 }