com.reprezen.genflow.api.source.FileSource Maven / Gradle / Ivy
/*******************************************************************************
* Copyright © 2013, 2016 Modelsolv, Inc.
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property
* of ModelSolv, Inc. See the file license.html in the root directory of
* this project for further information.
*******************************************************************************/
package com.reprezen.genflow.api.source;
import java.io.File;
import com.reprezen.genflow.api.GenerationException;
import com.reprezen.genflow.api.loadability.AbstractLoadabilityTester;
import com.reprezen.genflow.api.loadability.LoadabilityTester;
/**
* Generic Source implementation that can be used to provide access to files for
* which value-loading source implementations are unavailable.
*
* The "value" of a FileSource is simply a File object referencing whatever file
* is bound to the source. The file is not opened or processed in any way; it is
* exactly as provided by the GenTarget during binding.
*
* @author Andy
*
*/
public class FileSource extends AbstractSource {
public FileSource() {
super();
}
public FileSource(File inputFile) {
super(inputFile);
}
@Override
public String getLabel() {
return "File";
}
@Override
public File load(File inFile) throws GenerationException {
return inputFile;
}
@Override
public ILocator getLocator(File soureValue) {
return null;
}
@Override
public LoadabilityTester getLoadabilityTester() {
return new FileLoadabilityTester();
}
public static LoadabilityTester loadabilityTester() {
return new FileLoadabilityTester();
}
public static class FileLoadabilityTester extends AbstractLoadabilityTester {
@Override
public Loadability _getLoadability(File file, int diligence) {
return Loadability.loadable();
}
}
}