View Javadoc
1   /**************************************************************************
2    *
3    * Copyright (c) 2016-2019 Yawg project contributors.
4    *
5    **************************************************************************/
6   
7   package com.varmateo.yawg.spi;
8   
9   import java.nio.file.Path;
10  
11  
12  /**
13   * A baker of files.
14   */
15  public interface PageBaker {
16  
17  
18      /**
19       * The baker identifier. It is used to uniquely identify a baker.
20       *
21       * @return The baker name.
22       */
23      String shortName();
24  
25  
26      /**
27       * Checks if this baker is able to bake the given file.
28       *
29       * <p>Typical implementations check if the file extension is one
30       * of a set of supported file types.</p>
31       *
32       * @param path The file system path of the file to be checked.
33       *
34       * @return True if this baker can handle the file. False
35       * otherwise.
36       */
37      boolean isBakeable(Path path);
38  
39  
40      /**
41       * Bakes the given file creating the result in the specified
42       * target directory.
43       *
44       * <p>The target directory must already exist. Otherwise a
45       * failedresult will be returned.</p>
46       *
47       * @param sourcePath The file to be baked.
48       *
49       * @param context Data for performing the baking.
50       *
51       * @param targetDir The directory where the result of the bake
52       * will be created.
53       *
54       * @return A result signaling success of failure.
55       */
56      PageBakeResult bake(
57              Path sourcePath,
58              PageContext context,
59              Path targetDir);
60  }