de.digitalcollections.solrocr.util.SourceAwareReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solr-ocrhighlighting Show documentation
Show all versions of solr-ocrhighlighting Show documentation
Solr plugin to add support for highlighting directly from various OCR formats (hOCR/ALTO/MiniOCR)
without having to store the OCR documents in the index.
The newest version!
package de.digitalcollections.solrocr.util;
import java.io.IOException;
import java.io.Reader;
import java.util.Optional;
public interface SourceAwareReader {
default Optional getSource() {
return Optional.empty();
}
class Wrapper extends Reader implements SourceAwareReader {
private final Reader input;
public Wrapper(Reader input) {
this.input = input;
}
@Override
public Optional getSource() {
if (this.input instanceof SourceAwareReader) {
return ((SourceAwareReader) this.input).getSource();
} else {
return Optional.empty();
}
}
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
return input.read(cbuf, off, len);
}
@Override
public void close() throws IOException {
input.close();
}
}
}