io.nosqlbench.nb.api.content.Content Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
package io.nosqlbench.nb.api.content;
import java.io.*;
import java.net.URI;
import java.nio.CharBuffer;
import java.nio.file.FileSystem;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.spi.FileSystemProvider;
import java.util.function.Supplier;
/**
* A generic content wrapper for anything that can be given to a NoSQLBench runtime
* using a specific type of locator.
*
* @param
*/
public interface Content extends Supplier, Comparable> {
T getLocation();
URI getURI();
Path asPath();
public default String asString() {
return getCharBuffer().toString();
}
CharBuffer getCharBuffer();
@Override
default CharSequence get() {
return getCharBuffer();
}
default int compareTo(Content> other) {
return getURI().compareTo(other.getURI());
}
default Reader getReader() {
InputStream inputStream = getInputStream();
return new InputStreamReader(inputStream);
}
default InputStream getInputStream() {
try {
Path path = asPath();
FileSystem fileSystem = path.getFileSystem();
FileSystemProvider provider = fileSystem.provider();
InputStream stream = provider.newInputStream(path, StandardOpenOption.READ);
return stream;
} catch (IOException ignored) {
}
String stringdata = getCharBuffer().toString();
return new ByteArrayInputStream(stringdata.getBytes());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy