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