View Javadoc
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>Site Renderer interface: render a collection of documents into a site, ie decored with a site template
37   * (eventually packaged as skin).</p>
38   *
39   * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
40   * @version $Id: Renderer.java 1729502 2016-02-09 23:28:47Z michaelo $
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 into a site.
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 RendererException if it bombs.
56       * @throws 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 output from a Doxia SiteRenderer Sink.
64       *
65       * @param writer the Writer to use.
66       * @param sink the Site Renderer Sink to receive the Doxia events.
67       * @param siteRenderingContext the SiteRenderingContext to use.
68       * @throws RendererException if it bombs.
69       */
70      void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext )
71          throws RendererException;
72  
73      /**
74       * Create a Site Rendering Context for a site using a skin.
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 RendererException, IOException;
87  
88      /**
89       * Create a Site Rendering Context for a site using a local template.
90       *
91       * @param templateFile
92       * @param attributes
93       * @param decoration
94       * @param defaultWindowTitle
95       * @param locale
96       * @return a SiteRenderingContext.
97       * @throws MalformedURLException if it bombs.
98       * @since 1.7, had an additional skinFile parameter before
99       * @deprecated Deprecated without replacement, use skins only.
100      * @see #createContextForSkin(File, Map, DecorationModel, String, Locale)
101      */
102     @Deprecated
103     SiteRenderingContext createContextForTemplate( File templateFile, Map<String, ?> attributes,
104                                                    DecorationModel decoration, String defaultWindowTitle,
105                                                    Locale locale )
106         throws MalformedURLException;
107 
108     /**
109      * Copy resource files.
110      *
111      * @param siteRenderingContext
112      * @param resourcesDirectory
113      * @param outputDirectory
114      * @throws IOException if it bombs.
115      * @deprecated since 1.7, use copyResources without resourcesDirectory parameter
116      */
117     void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory, File outputDirectory )
118         throws IOException;
119 
120     /**
121      * Copy resource files from skin, template, and site resources.
122      *
123      * @param siteRenderingContext
124      * @param outputDirectory
125      * @throws IOException if it bombs.
126      * @since 1.7
127      */
128     void copyResources( SiteRenderingContext siteRenderingContext, File outputDirectory )
129         throws IOException;
130 
131     /**
132      * Locate Doxia document source files in the site source context.
133      *
134      * @param siteRenderingContext
135      * @return the Doxia document renderers in a Map keyed by output file name.
136      * @throws IOException if it bombs.
137      * @throws RendererException if it bombs.
138      */
139     Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext )
140         throws IOException, RendererException;
141 
142     /**
143      * Render a document written in a Doxia markup language. This method is an internal method, used by
144      * {@link DoxiaDocumentRenderer}.
145      *
146      * @param writer the writer to render the document to.
147      * @param renderingContext the document's rendering context, which is expected to have a non-null parser id.
148      * @param siteContext the site's rendering context
149      * @throws RendererException if it bombs.
150      * @throws FileNotFoundException if it bombs.
151      * @throws UnsupportedEncodingException if it bombs.
152      */
153     void renderDocument( Writer writer, RenderingContext renderingContext, SiteRenderingContext siteContext )
154         throws RendererException, FileNotFoundException, UnsupportedEncodingException;
155 }