View Javadoc
1   /*
2    * Copyright 2012-2025 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.thumbnail;
17  
18  import java.io.File;
19  import java.util.Map;
20  
21  import org.codelibs.core.misc.Tuple3;
22  
23  /**
24   * Interface for thumbnail generation implementations.
25   * Provides methods for creating thumbnails from various document types.
26   */
27  public interface ThumbnailGenerator {
28  
29      /**
30       * Gets the name of this thumbnail generator.
31       * @return The generator name.
32       */
33      String getName();
34  
35      /**
36       * Generates a thumbnail for the given thumbnail ID and saves it to the output file.
37       *
38       * @param thumbnailId the unique identifier for the thumbnail
39       * @param outputFile the file where the generated thumbnail will be saved
40       * @return true if the thumbnail was successfully generated, false otherwise
41       */
42      boolean generate(String thumbnailId, File outputFile);
43  
44      /**
45       * Checks if this generator can handle the given document.
46       * @param docMap The document map containing metadata.
47       * @return True if this generator can handle the document, false otherwise.
48       */
49      boolean isTarget(Map<String, Object> docMap);
50  
51      /**
52       * Checks if this thumbnail generator is available for use.
53       * @return True if available, false otherwise.
54       */
55      boolean isAvailable();
56  
57      /**
58       * Destroys this thumbnail generator and releases any resources.
59       */
60      void destroy();
61  
62      /**
63       * Creates a thumbnail generation task.
64       * @param path The path to the source document.
65       * @param docMap The document map containing metadata.
66       * @return A tuple containing task information.
67       */
68      Tuple3<String, String, String> createTask(String path, Map<String, Object> docMap);
69  }