View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      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  {
32      private transient byte[] content = null;
33      private String url = null;
34      private String lastUrl = null;
35  
36      /***
37       * Constructor for a cached resource. 
38       *
39       * @param contentType The HTTP content type for a cached resource as defined 
40       *        in WebPageHelper, i.e. WebPageHelper.CT_HTML, WebPageHelper.CT_IMAGE....
41       * @param content The byte array of content this cached. This content can be
42       *         binary images, or static text such as scripts and style sheets.
43       *         
44       */
45      public WebContentResource(String url, byte[] content)
46      {
47          this.url = url;
48          if (content != null)
49          {
50              this.content = new byte[content.length];
51              System.arraycopy(content, 0, this.content, 0, this.content.length);
52          }
53      }
54  
55      /***
56       * Gets the content of this resource in a byte array.
57       *
58       * @return A byte array of the resource's content.
59       */
60      public byte[] getContent()
61      {
62          return content;
63      }
64  
65  
66      /***
67       * @return Returns the lastUrl.
68       */
69      public String getLastUrl()
70      {
71          return lastUrl;
72      }
73      /***
74       * @param lastUrl The lastUrl to set.
75       */
76      public void setLastUrl(String lastUrl)
77      {
78          this.lastUrl = lastUrl;
79      }
80      /***
81       * @return Returns the url.
82       */
83      public String getUrl()
84      {
85          return url;
86      }
87      /***
88       * @param url The url to set.
89       */
90      public void setUrl(String url)
91      {
92          this.url = url;
93      }
94  }