/** * Creates a Challenge based on a JSON resource file * * @param checkName * The name of the check that will look for the json challenge info * @return The challenge based from the resource json file */ public static Challenge fromResource(final String checkName) { final ClassResource challenge = new ClassResource(checkName + FileSuffix.JSON.toString()); return challenge.getJSONResourceObject(Survey.class); }
/** * @return True if the name of this resource lets believe that the resource contains Gzipped * contents. */ default boolean isGzipped() { return FileSuffix.GZIP.matches(this); }
@Override public InputStream read() { return this.source.read(); }
public File(final java.io.File file) { this.javaFile = file; if (file.getAbsolutePath().endsWith(FileSuffix.GZIP.toString())) { this.setCompressor(Compressor.GZIP); this.setDecompressor(Decompressor.GZIP); } if (this.javaFile.getParentFile() != null) { this.javaFile.getParentFile().mkdirs(); } }
@Test public void testExistsButNoMatch() { Assert.assertFalse(FileSuffix.CSV.matches(new FileSuffixTestCaseResource("test.csv.ext"))); }
public String getFileName(final File atlasResource) { return atlasResource.getName(); }
public LoadingClassifier(final String classResource) { this(new ClassResource(classResource)); }
public StringResource(final InputStream source) { this(new InputStreamResource(source)); }
/** * Copy all the contents of another {@link Resource} to this {@link WritableResource} * * @param input * The input {@link Resource} */ default void copyFrom(final Resource input) { input.copyTo(this); }
public String getName() { return this.source.getName(); }
public StringResource withName(final String name) { this.setName(name); return this; }
@Override public long length() { return this.source.length(); }
public InputStreamResource withName(final String name) { this.setName(name); return this; }
public File withCompressor(final Compressor compressor) { this.setCompressor(compressor); return this; }
public InputStreamResource withDecompressor(final Decompressor decompressor) { this.setDecompressor(decompressor); return this; }
public File withDecompressor(final Decompressor decompressor) { this.setDecompressor(decompressor); return this; }
@Test public void testMatches() { Assert.assertTrue(FileSuffix.CSV.matches(new FileSuffixTestCaseResource("test.csv"))); } }
/** * Copy all the contents of another {@link Resource} to this {@link WritableResource} while * notifying a progress listener * * @param input * The input {@link Resource} * @param listener * The notification {@link IOProgressListener} called as data is being copied */ default void copyFrom(final Resource input, final IOProgressListener listener) { input.copyTo(this, listener); }
@Test public void testDoesntExistNoMatch() { Assert.assertFalse(FileSuffix.CSV.matches(new FileSuffixTestCaseResource("test.fizzbuzz"))); }