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

de.digitalcollections.solrocr.util.SourceAwareReader Maven / Gradle / Ivy

Go to download

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();
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy