KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > webpage > CachedResource


1 /*
2  * Copyright 2000-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
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 }
70
Popular Tags