%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.modules.screens.RawScreen |
|
|
1 | package org.apache.turbine.modules.screens; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import org.apache.ecs.ConcreteElement; |
|
20 | import org.apache.turbine.modules.Screen; |
|
21 | import org.apache.turbine.util.RunData; |
|
22 | ||
23 | /** |
|
24 | * Base class for writing Screens that output binary data. This class |
|
25 | * is provided as a helper class for those who want to write Screens |
|
26 | * that output raw binary data. For example, it may be extended into |
|
27 | * a Screen that outputs a SVG file or a SWF (Flash Player format) |
|
28 | * movie. The only thing one has to do is to implement the two |
|
29 | * methods <code>getContentType(RunData data)</code> and |
|
30 | * <code>doOutput(RunData data)</code> (see below). |
|
31 | * |
|
32 | * <p> You migth want to take a look at the ImageServer screen class |
|
33 | * contained in the TDK.<br> |
|
34 | * |
|
35 | * @author <a href="mailto:rkoenig@chez.com">Regis Koenig</a> |
|
36 | * @version $Id: RawScreen.java 264148 2005-08-29 14:21:04Z henning $ |
|
37 | */ |
|
38 | 0 | public abstract class RawScreen extends Screen |
39 | { |
|
40 | /** |
|
41 | * Build the Screen. This method actually makes a call to the |
|
42 | * doOutput() method in order to generate the Screen content. |
|
43 | * |
|
44 | * @param data Turbine information. |
|
45 | * @return A ConcreteElement. |
|
46 | * @exception Exception, a generic exception. |
|
47 | */ |
|
48 | protected final ConcreteElement doBuild(RunData data) |
|
49 | throws Exception |
|
50 | { |
|
51 | 0 | data.getResponse().setContentType(getContentType(data)); |
52 | 0 | data.declareDirectResponse(); |
53 | 0 | doOutput(data); |
54 | 0 | return null; |
55 | } |
|
56 | ||
57 | /** |
|
58 | * Set the content type. This method should be overidden to |
|
59 | * actually set the real content-type header of the output. |
|
60 | * |
|
61 | * @param data Turbine information. |
|
62 | * @return A String with the content type. |
|
63 | */ |
|
64 | protected abstract String getContentType(RunData data); |
|
65 | ||
66 | /** |
|
67 | * Actually output the dynamic content. The OutputStream can be |
|
68 | * accessed like this: <pre>OutputStream out = |
|
69 | * data.getResponse().getOutputStream();</pre>. |
|
70 | * |
|
71 | * @param data Turbine information. |
|
72 | * @exception Exception, a generic exception. |
|
73 | */ |
|
74 | protected abstract void doOutput(RunData data) |
|
75 | throws Exception; |
|
76 | ||
77 | /** |
|
78 | * The layout must be set to null. |
|
79 | * |
|
80 | * @param data Turbine information. |
|
81 | * @return A null String. |
|
82 | */ |
|
83 | public final String getLayout(RunData data) |
|
84 | { |
|
85 | 0 | return null; |
86 | } |
|
87 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |