Exemplo n.º 1
1
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + (stream == null ? 0 : stream.hashCode());
   return result;
 }
Exemplo n.º 2
1
 @Override
 public int hashCode() {
   int result = name.hashCode();
   result = 31 * result + (value != null ? value.hashCode() : 0);
   result = 31 * result + (file != null ? file.hashCode() : 0);
   result = 31 * result + (fileBody != null ? fileBody.hashCode() : 0);
   return result;
 }
Exemplo n.º 3
1
  /**
   * @param source source input stream
   * @return InputStream the resulting input stream
   */
  public InputStream getDestinationStream(InputStream source) throws Exception {
    try {
      boolean useTemporaryFile =
          ConfigurationManager.getBooleanProperty("pdffilter.largepdfs", false);

      // get input stream from bitstream
      // pass to filter, get string back
      PDFTextStripper pts = new PDFTextStripper();
      PDDocument pdfDoc = null;
      Writer writer = null;
      File tempTextFile = null;
      ByteArrayOutputStream byteStream = null;

      if (useTemporaryFile) {
        tempTextFile = File.createTempFile("dspacepdfextract" + source.hashCode(), ".txt");
        tempTextFile.deleteOnExit();
        writer = new OutputStreamWriter(new FileOutputStream(tempTextFile));
      } else {
        byteStream = new ByteArrayOutputStream();
        writer = new OutputStreamWriter(byteStream);
      }

      try {
        pdfDoc = PDDocument.load(source);
        pts.writeText(pdfDoc, writer);
      } finally {
        try {
          if (pdfDoc != null) pdfDoc.close();
        } catch (Exception e) {
          log.error("Error closing PDF file: " + e.getMessage(), e);
        }

        try {
          writer.close();
        } catch (Exception e) {
          log.error("Error closing temporary extract file: " + e.getMessage(), e);
        }
      }

      if (useTemporaryFile) {
        return new FileInputStream(tempTextFile);
      } else {
        byte[] bytes = byteStream.toByteArray();
        return new ByteArrayInputStream(bytes);
      }
    } catch (OutOfMemoryError oome) {
      log.error("Error parsing PDF document " + oome.getMessage(), oome);
      if (!ConfigurationManager.getBooleanProperty("pdffilter.skiponmemoryexception", false)) {
        throw oome;
      }
    }

    return null;
  }
 private File fileFromStream(InputStream stream) throws IOException {
   File f = folder.newFile("tweet" + stream.hashCode() + ".txt");
   PrintWriter writer = new PrintWriter(new BufferedOutputStream(new FileOutputStream(f)));
   BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
   String line = null;
   while ((line = reader.readLine()) != null) {
     writer.println(line);
   }
   writer.flush();
   writer.close();
   return f;
 }
Exemplo n.º 5
1
 @Override
 public int hashCode() {
   int result = status != null ? status.hashCode() : 0;
   result = 31 * result + (int) (inReplyToStatusId ^ inReplyToStatusId >>> 32);
   result = 31 * result + (location != null ? location.hashCode() : 0);
   result = 31 * result + (placeId != null ? placeId.hashCode() : 0);
   result = 31 * result + (displayCoordinates ? 1 : 0);
   result = 31 * result + (possiblySensitive ? 1 : 0);
   result = 31 * result + (mediaName != null ? mediaName.hashCode() : 0);
   result = 31 * result + (mediaBody != null ? mediaBody.hashCode() : 0);
   result = 31 * result + (mediaFile != null ? mediaFile.hashCode() : 0);
   return result;
 }
Exemplo n.º 6
1
 public int hashCode() {
   return delegate.hashCode();
 }
Exemplo n.º 7
1
 public SnuggleInput(final InputStream inputStream) {
   this(inputStream, "[Stream input @" + inputStream.hashCode() + "]");
 }