Package org.eclipse.jgit.util

Examples of org.eclipse.jgit.util.TemporaryBuffer


    void read() throws IOException, InterruptedException {
      final BufferedReader in = new BufferedReader(new InputStreamReader(
          proc.getInputStream(), "ISO-8859-1"));
      String commitId = null;
      TemporaryBuffer buf = null;
      for (;;) {
        String line = in.readLine();
        if (line == null)
          break;
        if (line.startsWith("commit ")) {
          if (buf != null) {
            buf.close();
            onCommit(commitId, buf.toByteArray());
            buf.destroy();
          }
          commitId = line.substring("commit ".length());
          buf = new TemporaryBuffer.LocalFile();
        } else if (buf != null) {
          buf.write(line.getBytes("ISO-8859-1"));
          buf.write('\n');
        }
      }
      in.close();
      assertEquals(0, proc.waitFor());
      proc = null;
View Full Code Here


        e.smudgeRacilyClean();
      e.write(dos);
    }

    if (writeTree) {
      final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
      tree.write(tmp, bb);
      bb.close();

      NB.encodeInt32(tmp, 0, EXT_TREE);
      NB.encodeInt32(tmp, 4, (int) bb.length());
      dos.write(tmp, 0, 8);
      bb.writeTo(dos, null);
    }
    writeIndexChecksum = foot.digest();
    os.write(writeIndexChecksum);
    os.close();
  }
View Full Code Here

          throw new TransportException(uri,
              JGitText.get().startingReadStageWithoutWrittenRequestDataPendingIsNotSupported);
        }

        // Try to compress the content, but only if that is smaller.
        TemporaryBuffer buf = new TemporaryBuffer.Heap(http.postBuffer);
        try {
          GZIPOutputStream gzip = new GZIPOutputStream(buf);
          out.writeTo(gzip, null);
          gzip.close();
          if (out.length() < buf.length())
            buf = out;
        } catch (IOException err) {
          // Most likely caused by overflowing the buffer, meaning
          // its larger if it were compressed. Don't compress.
          buf = out;
        }

        openStream();
        if (buf != out)
          conn.setRequestProperty(HDR_CONTENT_ENCODING, ENCODING_GZIP);
        conn.setFixedLengthStreamingMode((int) buf.length());
        final OutputStream httpOut = conn.getOutputStream();
        try {
          buf.writeTo(httpOut, null);
        } finally {
          httpOut.close();
        }
      }
View Full Code Here

   */
  public OutputStream beginPut(final String bucket, final String key,
      final ProgressMonitor monitor, final String monitorTask)
      throws IOException {
    final MessageDigest md5 = newMD5();
    final TemporaryBuffer buffer = new TemporaryBuffer.LocalFile() {
      @Override
      public void close() throws IOException {
        super.close();
        try {
          putImpl(bucket, key, md5.digest(), this, monitor,
View Full Code Here

    final byte[] buf = readFully(is);
    parse(buf, 0, buf.length);
  }

  private static byte[] readFully(final InputStream is) throws IOException {
    final TemporaryBuffer b = new TemporaryBuffer.LocalFile();
    try {
      b.copy(is);
      b.close();
      return b.toByteArray();
    } finally {
      b.destroy();
    }
  }
View Full Code Here

        e.smudgeRacilyClean();
      e.write(dos);
    }

    if (writeTree) {
      final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
      tree.write(tmp, bb);
      bb.close();

      NB.encodeInt32(tmp, 0, EXT_TREE);
      NB.encodeInt32(tmp, 4, (int) bb.length());
      dos.write(tmp, 0, 8);
      bb.writeTo(dos, null);
    }
    writeIndexChecksum = foot.digest();
    os.write(writeIndexChecksum);
    os.close();
  }
View Full Code Here

      conn.setRequestProperty(HDR_ACCEPT, responseType);
    }

    void sendRequest() throws IOException {
      // Try to compress the content, but only if that is smaller.
      TemporaryBuffer buf = new TemporaryBuffer.Heap(http.postBuffer);
      try {
        GZIPOutputStream gzip = new GZIPOutputStream(buf);
        out.writeTo(gzip, null);
        gzip.close();
        if (out.length() < buf.length())
          buf = out;
      } catch (IOException err) {
        // Most likely caused by overflowing the buffer, meaning
        // its larger if it were compressed. Don't compress.
        buf = out;
      }

      openStream();
      if (buf != out)
        conn.setRequestProperty(HDR_CONTENT_ENCODING, ENCODING_GZIP);
      conn.setFixedLengthStreamingMode((int) buf.length());
      final OutputStream httpOut = conn.getOutputStream();
      try {
        buf.writeTo(httpOut, null);
      } finally {
        httpOut.close();
      }
    }
View Full Code Here

        e.smudgeRacilyClean();
      e.write(dos);
    }

    if (writeTree) {
      final TemporaryBuffer bb = new TemporaryBuffer.LocalFile();
      tree.write(tmp, bb);
      bb.close();

      NB.encodeInt32(tmp, 0, EXT_TREE);
      NB.encodeInt32(tmp, 4, (int) bb.length());
      dos.write(tmp, 0, 8);
      bb.writeTo(dos, null);
    }
    writeIndexChecksum = foot.digest();
    os.write(writeIndexChecksum);
    os.close();
  }
View Full Code Here

      conn.setRequestProperty(HDR_ACCEPT, responseType);
    }

    void sendRequest() throws IOException {
      // Try to compress the content, but only if that is smaller.
      TemporaryBuffer buf = new TemporaryBuffer.Heap(http.postBuffer);
      try {
        GZIPOutputStream gzip = new GZIPOutputStream(buf);
        out.writeTo(gzip, null);
        gzip.close();
        if (out.length() < buf.length())
          buf = out;
      } catch (IOException err) {
        // Most likely caused by overflowing the buffer, meaning
        // its larger if it were compressed. Don't compress.
        buf = out;
      }

      openStream();
      if (buf != out)
        conn.setRequestProperty(HDR_CONTENT_ENCODING, ENCODING_GZIP);
      conn.setFixedLengthStreamingMode((int) buf.length());
      final OutputStream httpOut = conn.getOutputStream();
      try {
        buf.writeTo(httpOut, null);
      } finally {
        httpOut.close();
      }
    }
View Full Code Here

      conn.setRequestProperty(HDR_ACCEPT, responseType);
    }

    void sendRequest() throws IOException {
      // Try to compress the content, but only if that is smaller.
      TemporaryBuffer buf = new TemporaryBuffer.Heap(http.postBuffer);
      try {
        GZIPOutputStream gzip = new GZIPOutputStream(buf);
        out.writeTo(gzip, null);
        gzip.close();
        if (out.length() < buf.length())
          buf = out;
      } catch (IOException err) {
        // Most likely caused by overflowing the buffer, meaning
        // its larger if it were compressed. Don't compress.
        buf = out;
      }

      openStream();
      if (buf != out)
        conn.setRequestProperty(HDR_CONTENT_ENCODING, ENCODING_GZIP);
      conn.setFixedLengthStreamingMode((int) buf.length());
      final OutputStream httpOut = conn.getOutputStream();
      try {
        buf.writeTo(httpOut, null);
      } finally {
        httpOut.close();
      }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.util.TemporaryBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.