2023-03-16 20:35:54 +00:00
|
|
|
package plan;
|
2022-05-19 15:45:26 +00:00
|
|
|
|
|
|
|
import org.yaml.snakeyaml.Yaml;
|
|
|
|
|
|
|
|
import java.io.FileReader;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
|
|
|
public class CrawlPlanLoader {
|
|
|
|
private final Yaml yaml;
|
|
|
|
|
|
|
|
public CrawlPlanLoader() {
|
|
|
|
yaml = new Yaml();
|
|
|
|
}
|
|
|
|
|
2023-03-12 10:42:07 +00:00
|
|
|
public CrawlPlan load(Path yamlFile) throws IOException {
|
2022-05-19 15:45:26 +00:00
|
|
|
try (var reader = new FileReader(yamlFile.toFile())) {
|
2023-03-12 10:42:07 +00:00
|
|
|
return yaml.loadAs(reader, CrawlPlan.class);
|
2022-05-19 15:45:26 +00:00
|
|
|
}
|
|
|
|
catch (IOException ex) {
|
|
|
|
throw new IOException("Failed to load crawl plan " + yamlFile, ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|