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