All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.connollyst.jolt.JoltCrawler Maven / Gradle / Ivy

Go to download

A Maven plugin to apply JSON to JSON transformations using the Jolt spec. Useful as part of a Maven build to transform JSON generated by one plugin to JSON consumable by another.

There is a newer version: 0.1.0.1
Show newest version
package com.github.connollyst.jolt;

import org.apache.maven.plugin.logging.Log;

import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * @author Sean Connolly
 */
class JoltCrawler extends SimpleFileVisitor {

    private final Log log;
    private final Path inputDirectory;
    private final Path outputDirectory;
    private final JoltTransformer transformer;

    JoltCrawler(Log log, Path inputDirectory, Path outputDirectory, JoltTransformer transformer) {
        this.log = log;
        this.inputDirectory = inputDirectory;
        this.outputDirectory = outputDirectory;
        this.transformer = transformer;
    }


    @Override
    public FileVisitResult visitFile(Path sourceFile, BasicFileAttributes sourceAttributes) throws IOException {
        log.info("Processing " + sourceFile);
        Path relativeSourcePath = inputDirectory.relativize(sourceFile);
        Path destinationPath = outputDirectory.resolve(relativeSourcePath);
        log.info("Output " + destinationPath);
        transformer.execute(sourceFile, destinationPath);
        return super.visitFile(sourceFile, sourceAttributes);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy