KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > IAsset


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

15 package org.apache.tapestry;
16
17 import java.io.InputStream JavaDoc;
18
19 import org.apache.hivemind.Locatable;
20 import org.apache.hivemind.Resource;
21
22 /**
23  * Representation of a asset (GIF, JPEG, etc.) that may be owned by a {@link IComponent}.
24  * <p>
25  * Assets may be completely external (i.e., on some other web site), contained by the
26  * {@link javax.servlet.ServletContext}, or stored somewhere in the classpath.
27  * <p>
28  * In the latter two cases, the resource may be localized.
29  *
30  * @author Howard Lewis Ship
31  */

32
33 public interface IAsset extends Locatable
34 {
35     /**
36      * Returns a URL for the asset, ready to be inserted into the output HTML. If the asset can be
37      * localized, the localized version (matching the {@link java.util.Locale}of the current
38      * {@link IPage page}) is returned.
39      *
40      * @throws ApplicationRuntimeException
41      * if the asset does not exist.
42      */

43
44     public String JavaDoc buildURL(IRequestCycle cycle);
45
46     /**
47      * Accesses the localized version of the resource (if possible) and returns it as an input
48      * stream. A version of the resource localized to the current {@link IPage page}is returned.
49      *
50      * @throws ApplicationRuntimeException
51      * if the asset does not exist, or can't be read.
52      */

53
54     public InputStream JavaDoc getResourceAsStream(IRequestCycle cycle);
55
56     /**
57      * Returns the underlying location of the asset.
58      */

59
60     public Resource getResourceLocation();
61 }
Popular Tags