当前位置: 首页>>代码示例>>Java>>正文


Java TemporaryBuffer类代码示例

本文整理汇总了Java中org.eclipse.jgit.util.TemporaryBuffer的典型用法代码示例。如果您正苦于以下问题:Java TemporaryBuffer类的具体用法?Java TemporaryBuffer怎么用?Java TemporaryBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TemporaryBuffer类属于org.eclipse.jgit.util包,在下文中一共展示了TemporaryBuffer类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: replyJson

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
public static long replyJson(
    @Nullable HttpServletRequest req,
    HttpServletResponse res,
    ListMultimap<String, String> config,
    Object result)
    throws IOException {
  TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE);
  buf.write(JSON_MAGIC);
  Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
  Gson gson = newGson(config, req);
  if (result instanceof JsonElement) {
    gson.toJson((JsonElement) result, w);
  } else {
    gson.toJson(result, w);
  }
  w.write('\n');
  w.flush();
  return replyBinaryResult(
      req, res, asBinaryResult(buf).setContentType(JSON_TYPE).setCharacterEncoding(UTF_8));
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:RestApiServlet.java

示例2: stackJsonString

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
private static BinaryResult stackJsonString(HttpServletResponse res, BinaryResult src)
    throws IOException {
  TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE);
  buf.write(JSON_MAGIC);
  try (Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
      JsonWriter json = new JsonWriter(w)) {
    json.setLenient(true);
    json.setHtmlSafe(true);
    json.value(src.asString());
    w.write('\n');
  }
  res.setHeader("X-FYI-Content-Encoding", "json");
  res.setHeader("X-FYI-Content-Type", src.getContentType());
  return asBinaryResult(buf).setContentType(JSON_TYPE).setCharacterEncoding(UTF_8);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:RestApiServlet.java

示例3: base64

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
private static BinaryResult base64(BinaryResult bin) throws IOException {
  int maxSize = base64MaxSize(bin.getContentLength());
  int estSize = Math.min(base64MaxSize(HEAP_EST_SIZE), maxSize);
  TemporaryBuffer.Heap buf = heap(estSize, maxSize);
  try (OutputStream encoded =
      BaseEncoding.base64().encodingStream(new OutputStreamWriter(buf, ISO_8859_1))) {
    bin.writeTo(encoded);
  }
  return asBinaryResult(buf);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:RestApiServlet.java

示例4: compress

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
private static BinaryResult compress(BinaryResult bin) throws IOException {
  TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, 20 << 20);
  try (GZIPOutputStream gz = new GZIPOutputStream(buf)) {
    bin.writeTo(gz);
  }
  return asBinaryResult(buf).setContentType(bin.getContentType());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:RestApiServlet.java

示例5: asBinaryResult

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
@SuppressWarnings("resource")
private static BinaryResult asBinaryResult(TemporaryBuffer.Heap buf) {
  return new BinaryResult() {
    @Override
    public void writeTo(OutputStream os) throws IOException {
      buf.writeTo(os, null);
    }
  }.setContentLength(buf.length());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:RestApiServlet.java

示例6: readPegdownCss

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
private static String readPegdownCss(AtomicBoolean file) throws IOException {
  String name = "pegdown.css";
  URL url = MarkdownFormatter.class.getResource(name);
  if (url == null) {
    throw new FileNotFoundException("Resource " + name);
  }
  file.set("file".equals(url.getProtocol()));
  try (InputStream in = url.openStream();
      TemporaryBuffer.Heap tmp = new TemporaryBuffer.Heap(128 * 1024)) {
    tmp.copy(in);
    return new String(tmp.toByteArray(), UTF_8);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:MarkdownFormatter.java

示例7: heap

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
private static Heap heap(int est, int max) {
  return new TemporaryBuffer.Heap(est, max);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:RestApiServlet.java

示例8: setBuffer

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
public void setBuffer(TemporaryBuffer buffer) {
    this.entity = new TemporaryBufferEntity(buffer);
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:4,代码来源:PreemptiveAuthHttpClientConnection.java

示例9: setFixedLengthStreamingMode

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
public void setFixedLengthStreamingMode(int contentLength) {
    if (entity != null)
        throw new IllegalArgumentException();
    entity = new TemporaryBufferEntity(new TemporaryBuffer.LocalFile(null));
    entity.setContentLength(contentLength);
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:7,代码来源:PreemptiveAuthHttpClientConnection.java

示例10: getOutputStream

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
public OutputStream getOutputStream() throws IOException {
    if (entity == null)
        entity = new TemporaryBufferEntity(new TemporaryBuffer.LocalFile(null));
    return entity.getBuffer();
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:6,代码来源:PreemptiveAuthHttpClientConnection.java

示例11: setChunkedStreamingMode

import org.eclipse.jgit.util.TemporaryBuffer; //导入依赖的package包/类
public void setChunkedStreamingMode(int chunklen) {
    if (entity == null)
        entity = new TemporaryBufferEntity(new TemporaryBuffer.LocalFile(null));
    entity.setChunked(true);
}
 
开发者ID:jenkinsci,项目名称:git-client-plugin,代码行数:6,代码来源:PreemptiveAuthHttpClientConnection.java


注:本文中的org.eclipse.jgit.util.TemporaryBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。