1 package org.apache.maven.doxia.siterenderer; 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 import java.io.File; 23 import java.io.FileNotFoundException; 24 import java.io.IOException; 25 import java.io.UnsupportedEncodingException; 26 import java.io.Writer; 27 import java.net.MalformedURLException; 28 import java.util.Collection; 29 import java.util.Locale; 30 import java.util.Map; 31 32 import org.apache.maven.doxia.sink.render.RenderingContext; 33 import org.apache.maven.doxia.site.decoration.DecorationModel; 34 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink; 35 36 /** 37 * <p>Renderer interface.</p> 38 * 39 * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a> 40 * @version $Id: Renderer.java 1294330 2012-02-27 21:13:51Z hboutemy $ 41 */ 42 public interface Renderer 43 { 44 /** 45 * Plexus lookup role. 46 */ 47 String ROLE = Renderer.class.getName(); 48 49 /** 50 * Render a collection of documents. 51 * 52 * @param documents the documents to render. 53 * @param siteRenderingContext the SiteRenderingContext to use. 54 * @param outputDirectory the output directory to write results. 55 * @throws org.apache.maven.doxia.siterenderer.RendererException if it bombs. 56 * @throws java.io.IOException if it bombs. 57 */ 58 void render( Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, 59 File outputDirectory ) 60 throws RendererException, IOException; 61 62 /** 63 * Generate a document. 64 * 65 * @param writer the Writer to use. 66 * @param sink the Sink to receive the events. 67 * @param siteRenderingContext the SiteRenderingContext to use. 68 * @throws org.apache.maven.doxia.siterenderer.RendererException if it bombs. 69 */ 70 void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext ) 71 throws RendererException; 72 73 /** 74 * Return a SiteRenderingContext. 75 * 76 * @param skinFile 77 * @param attributes 78 * @param decoration 79 * @param defaultWindowTitle 80 * @param locale 81 * @return a SiteRenderingContext. 82 * @throws java.io.IOException if it bombs. 83 */ 84 SiteRenderingContext createContextForSkin( File skinFile, Map<String, ?> attributes, DecorationModel decoration, 85 String defaultWindowTitle, Locale locale ) 86 throws IOException; 87 88 /** 89 * Return a SiteRenderingContext. 90 * 91 * @param templateFile 92 * @param skinFile 93 * @param attributes 94 * @param decoration 95 * @param defaultWindowTitle 96 * @param locale 97 * @return a SiteRenderingContext. 98 * @throws java.net.MalformedURLException if it bombs. 99 */ 100 SiteRenderingContext createContextForTemplate( File templateFile, File skinFile, Map<String, ?> attributes, 101 DecorationModel decoration, String defaultWindowTitle, 102 Locale locale ) 103 throws MalformedURLException; 104 105 /** 106 * Copy resource files. 107 * 108 * @param siteRenderingContext 109 * @param resourcesDirectory 110 * @param outputDirectory 111 * @throws java.io.IOException if it bombs. 112 */ 113 void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory, File outputDirectory ) 114 throws IOException; 115 116 /** 117 * Return the document files in a Map. 118 * 119 * @param siteRenderingContext 120 * @return the document files in a Map. 121 * @throws java.io.IOException if it bombs. 122 * @throws org.apache.maven.doxia.siterenderer.RendererException if it bombs. 123 */ 124 Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext ) 125 throws IOException, RendererException; 126 127 /** 128 * Render a document. 129 * 130 * @param writer the writer to render the document to. 131 * @param renderingContext the document's rendering context 132 * @param siteContext the site's rendering context 133 * @throws RendererException if it bombs. 134 * @throws FileNotFoundException if it bombs. 135 * @throws UnsupportedEncodingException if it bombs. 136 */ 137 void renderDocument( Writer writer, RenderingContext renderingContext, SiteRenderingContext siteContext ) 138 throws RendererException, FileNotFoundException, UnsupportedEncodingException; 139 }