1 package org.apache.maven.doxia.book.context; 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 org.apache.maven.doxia.book.model.BookModel; 23 24 import java.io.File; 25 import java.util.Locale; 26 import java.util.Map; 27 import java.util.HashMap; 28 29 /** 30 * Context to render a book. 31 * 32 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> 33 * @version $Id: BookContext.java 1090706 2011-04-09 23:15:28Z hboutemy $ 34 */ 35 public class BookContext 36 { 37 /** The BookModel of this context. */ 38 private BookModel book; 39 40 /** The files. */ 41 private Map<String, BookContext.BookFile> files; 42 43 /** The output directory. */ 44 private File outputDirectory; 45 46 /** The BookIndex of this context. */ 47 private BookIndex index; 48 49 /** The Locale used to generate the navigation. */ 50 private Locale locale; 51 52 /** The input encoding used to read Doxia file. */ 53 private String inputEncoding; 54 55 /** The output encoding used to write the renderer files. */ 56 private String outputEncoding; 57 58 // ---------------------------------------------------------------------- 59 // 60 // ---------------------------------------------------------------------- 61 62 /** Represents a BookFile. */ 63 public static class BookFile 64 { 65 /** The file. */ 66 private File file; 67 68 /** The id of the parser. */ 69 private String parserId; 70 71 /** 72 * Constructor. 73 * 74 * @param file the file. 75 * @param parserId the parser id. 76 */ 77 public BookFile( File file, String parserId ) 78 { 79 this.file = file; 80 this.parserId = parserId; 81 } 82 83 /** 84 * Return the file of this BookFile. 85 * 86 * @return File. 87 */ 88 public File getFile() 89 { 90 return file; 91 } 92 93 /** 94 * Return the parserId of this BookFile. 95 * 96 * @return String. 97 */ 98 public String getParserId() 99 { 100 return parserId; 101 } 102 } 103 104 // ---------------------------------------------------------------------- 105 // Accessors 106 // ---------------------------------------------------------------------- 107 108 /** 109 * Return the BookModel of this BookContext. 110 * 111 * @return BookModel. 112 */ 113 public BookModel getBook() 114 { 115 return book; 116 } 117 118 /** 119 * Set the BookModel of this BookContext. 120 * 121 * @param book the BookModel. 122 */ 123 public void setBook( BookModel book ) 124 { 125 this.book = book; 126 } 127 128 /** 129 * Return the files of this BookContext. 130 * 131 * @return Map. A new HashMap is constructed if the current Map is null. 132 */ 133 public Map<String, BookContext.BookFile> getFiles() 134 { 135 if ( files == null ) 136 { 137 files = new HashMap<String, BookContext.BookFile>(); 138 } 139 140 return files; 141 } 142 143 /** 144 * Set the files of this BookContext. 145 * 146 * @param files the Map of files. 147 */ 148 public void setFiles( Map<String, BookContext.BookFile> files ) 149 { 150 this.files = files; 151 } 152 153 /** 154 * Return the outputDirectory of this BookContext. 155 * 156 * @return File. 157 */ 158 public File getOutputDirectory() 159 { 160 return outputDirectory; 161 } 162 163 /** 164 * Set the outputDirectory of this BookContext. 165 * 166 * @param outputDirectory the output directory. 167 */ 168 public void setOutputDirectory( File outputDirectory ) 169 { 170 this.outputDirectory = outputDirectory; 171 } 172 173 /** 174 * Return the index of this BookContext. 175 * 176 * @return BookIndex. 177 */ 178 public BookIndex getIndex() 179 { 180 return index; 181 } 182 183 /** 184 * Set the index of this BookContext. 185 * 186 * @param index the index to set. 187 */ 188 public void setIndex( BookIndex index ) 189 { 190 this.index = index; 191 } 192 193 /** 194 * <p>Getter for the field <code>locale</code>.</p> 195 * 196 * @return the locale 197 * @since 1.1 198 */ 199 public Locale getLocale() 200 { 201 return locale; 202 } 203 204 /** 205 * <p>Setter for the field <code>locale</code>.</p> 206 * 207 * @param locale the locale to set 208 * @since 1.1 209 */ 210 public void setLocale( Locale locale ) 211 { 212 this.locale = locale; 213 } 214 215 /** 216 * <p>Getter for the field <code>inputEncoding</code>.</p> 217 * 218 * @return the inputEncoding 219 * @since 1.1 220 */ 221 public String getInputEncoding() 222 { 223 return inputEncoding; 224 } 225 226 /** 227 * <p>Setter for the field <code>inputEncoding</code>.</p> 228 * 229 * @param inputEncoding the inputEncoding to set 230 * @since 1.1 231 */ 232 public void setInputEncoding( String inputEncoding ) 233 { 234 this.inputEncoding = inputEncoding; 235 } 236 237 /** 238 * <p>Getter for the field <code>outputEncoding</code>.</p> 239 * 240 * @return the outputEncoding 241 * @since 1.1 242 */ 243 public String getOutputEncoding() 244 { 245 return outputEncoding; 246 } 247 248 /** 249 * <p>Setter for the field <code>outputEncoding</code>.</p> 250 * 251 * @param outputEncoding the outputEncoding to set 252 * @since 1.1 253 */ 254 public void setOutputEncoding( String outputEncoding ) 255 { 256 this.outputEncoding = outputEncoding; 257 } 258 }