01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.apache.jetspeed.portlet.webcontent;
19:
20: import java.io.Serializable;
21:
22: /**
23: * A cached resource object, stored in memory to optimize access to static resources
24: * such as images and style sheets.
25: *
26: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
27: * @version $Id: WebContentResource.java 517719 2007-03-13 15:05:48Z ate $
28: */
29:
30: public class WebContentResource implements Serializable {
31: private transient byte[] content = null;
32: private String url = null;
33: private String lastUrl = null;
34:
35: /**
36: * Constructor for a cached resource.
37: *
38: * @param contentType The HTTP content type for a cached resource as defined
39: * in WebPageHelper, i.e. WebPageHelper.CT_HTML, WebPageHelper.CT_IMAGE....
40: * @param content The byte array of content this cached. This content can be
41: * binary images, or static text such as scripts and style sheets.
42: *
43: */
44: public WebContentResource(String url, byte[] content) {
45: this .url = url;
46: if (content != null) {
47: this .content = new byte[content.length];
48: System.arraycopy(content, 0, this .content, 0,
49: this .content.length);
50: }
51: }
52:
53: /**
54: * Gets the content of this resource in a byte array.
55: *
56: * @return A byte array of the resource's content.
57: */
58: public byte[] getContent() {
59: return content;
60: }
61:
62: /**
63: * @return Returns the lastUrl.
64: */
65: public String getLastUrl() {
66: return lastUrl;
67: }
68:
69: /**
70: * @param lastUrl The lastUrl to set.
71: */
72: public void setLastUrl(String lastUrl) {
73: this .lastUrl = lastUrl;
74: }
75:
76: /**
77: * @return Returns the url.
78: */
79: public String getUrl() {
80: return url;
81: }
82:
83: /**
84: * @param url The url to set.
85: */
86: public void setUrl(String url) {
87: this.url = url;
88: }
89: }
|