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.artifact.Artifact;
33  import org.apache.maven.doxia.site.decoration.DecorationModel;
34  import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
35  
36  /**
37   * <p>Site Renderer interface: render a collection of documents into a site, ie decored with a site template
38   * (eventually packaged as skin).</p>
39   *
40   * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
41   * @version $Id: Renderer.java 1767162 2016-10-30 14:48:28Z hboutemy $
42   */
43  public interface Renderer
44  {
45      /**
46       * Plexus lookup role.
47       */
48      String ROLE = Renderer.class.getName();
49  
50      /**
51       * Render a collection of documents into a site.
52       *
53       * @param documents the documents to render.
54       * @param siteRenderingContext the SiteRenderingContext to use.
55       * @param outputDirectory the output directory to write results.
56       * @throws RendererException if it bombs.
57       * @throws IOException if it bombs.
58       */
59      void render( Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext,
60                   File outputDirectory )
61          throws RendererException, IOException;
62  
63      /**
64       * Generate a document output from a Doxia SiteRenderer Sink.
65       *
66       * @param writer the Writer to use.
67       * @param sink the Site Renderer Sink to receive the Doxia events.
68       * @param siteRenderingContext the SiteRenderingContext to use.
69       * @throws RendererException if it bombs.
70       */
71      void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext )
72          throws RendererException;
73  
74      /**
75       * Create a Site Rendering Context for a site using a skin.
76       *
77       * @param skin
78       * @param attributes
79       * @param decoration
80       * @param defaultWindowTitle
81       * @param locale
82       * @return a SiteRenderingContext.
83       * @throws java.io.IOException if it bombs.
84       * @since 1.7.3 was previously with skin as File instead of Artifact
85       */
86      SiteRenderingContext createContextForSkin( Artifact skin, Map<String, ?> attributes, DecorationModel decoration,
87                                                 String defaultWindowTitle, Locale locale )
88          throws RendererException, IOException;
89  
90      /**
91       * Create a Site Rendering Context for a site using a local template.
92       *
93       * @param templateFile
94       * @param attributes
95       * @param decoration
96       * @param defaultWindowTitle
97       * @param locale
98       * @return a SiteRenderingContext.
99       * @throws MalformedURLException if it bombs.
100      * @since 1.7, had an additional skinFile parameter before
101      * @deprecated Deprecated without replacement, use skins only.
102      * @see #createContextForSkin(File, Map, DecorationModel, String, Locale)
103      */
104     @Deprecated
105     SiteRenderingContext createContextForTemplate( File templateFile, Map<String, ?> attributes,
106                                                    DecorationModel decoration, String defaultWindowTitle,
107                                                    Locale locale )
108         throws MalformedURLException;
109 
110     /**
111      * Copy resource files.
112      *
113      * @param siteRenderingContext
114      * @param resourcesDirectory
115      * @param outputDirectory
116      * @throws IOException if it bombs.
117      * @deprecated since 1.7, use copyResources without resourcesDirectory parameter
118      */
119     void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory, File outputDirectory )
120         throws IOException;
121 
122     /**
123      * Copy resource files from skin, template, and site resources.
124      *
125      * @param siteRenderingContext
126      * @param outputDirectory
127      * @throws IOException if it bombs.
128      * @since 1.7
129      */
130     void copyResources( SiteRenderingContext siteRenderingContext, File outputDirectory )
131         throws IOException;
132 
133     /**
134      * Locate Doxia document source files in the site source context.
135      *
136      * @param siteRenderingContext
137      * @return the Doxia document renderers in a Map keyed by output file name.
138      * @throws IOException if it bombs.
139      * @throws RendererException if it bombs.
140      */
141     Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext )
142         throws IOException, RendererException;
143 
144     /**
145      * Render a document written in a Doxia markup language. This method is an internal method, used by
146      * {@link DoxiaDocumentRenderer}.
147      *
148      * @param writer the writer to render the document to.
149      * @param renderingContext the document's rendering context, which is expected to have a non-null parser id.
150      * @param siteContext the site's rendering context
151      * @throws RendererException if it bombs.
152      * @throws FileNotFoundException if it bombs.
153      * @throws UnsupportedEncodingException if it bombs.
154      */
155     void renderDocument( Writer writer, RenderingContext renderingContext, SiteRenderingContext siteContext )
156         throws RendererException, FileNotFoundException, UnsupportedEncodingException;
157 }