本文整理了Java中akka.util.ByteString.size()
方法的一些代码示例,展示了ByteString.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.size()
方法的具体详情如下:
包路径:akka.util.ByteString
类名称:ByteString
方法名:size
暂无
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Set a Binary Data to this request.
* The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>.
*
* @param data the Binary Data
* @param tempFileCreator the temporary file creator for binary data.
* @return the modified builder
*/
public RequestBuilder bodyRaw(ByteString data, Files.TemporaryFileCreator tempFileCreator) {
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream");
}
代码示例来源:origin: com.typesafe.play/play
/**
* Set a Binary Data to this request.
* The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>.
*
* @param data the Binary Data
* @param tempFileCreator the temporary file creator for binary data.
* @return the modified builder
*/
public RequestBuilder bodyRaw(ByteString data, Files.TemporaryFileCreator tempFileCreator) {
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream");
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Set a Binary Data to this request.
* The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>.
*
* @param data the Binary Data
* @param tempFileCreator the temporary file creator for binary data.
* @return the modified builder
*/
public RequestBuilder bodyRaw(ByteString data, Files.TemporaryFileCreator tempFileCreator) {
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream");
}
代码示例来源:origin: com.typesafe.play/play
/**
* Set a Binary Data to this request using a singleton temp file creator
* The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>.
*
* @param data the Binary Data
* @return the modified builder
*/
public RequestBuilder bodyRaw(ByteString data) {
final Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator();
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream");
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Set a Binary Data to this request using a singleton temp file creator
* The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>.
*
* @param data the Binary Data
* @return the modified builder
*/
public RequestBuilder bodyRaw(ByteString data) {
final Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator();
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream");
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Set a Binary Data to this request using a singleton temp file creator
* The <tt>Content-Type</tt> header of the request is set to <tt>application/octet-stream</tt>.
*
* @param data the Binary Data
* @return the modified builder
*/
public RequestBuilder bodyRaw(ByteString data) {
final Files.TemporaryFileCreator tempFileCreator = Files.singletonTemporaryFileCreator();
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(data.size(), tempFileCreator.asScala(), data);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), "application/octet-stream");
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Set a Multipart Form url encoded body to this request saving it as a raw body.
*
* @param data the multipart-form parameters
* @param temporaryFileCreator the temporary file creator.
* @param mat a Akka Streams Materializer
* @return the modified builder
*/
public RequestBuilder bodyRaw(List<MultipartFormData.Part<Source<ByteString, ?>>> data, Files.TemporaryFileCreator temporaryFileCreator, Materializer mat) {
String boundary = MultipartFormatter.randomBoundary();
try {
ByteString materializedData = MultipartFormatter
.transform(Source.from(data), boundary)
.runWith(Sink.reduce(ByteString::concat), mat)
.toCompletableFuture()
.get();
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(materializedData.size(), temporaryFileCreator.asScala(), materializedData);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), MultipartFormatter.boundaryToContentType(boundary));
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException("Failure while materializing Multipart/Form Data", e);
}
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Set a Multipart Form url encoded body to this request saving it as a raw body.
*
* @param data the multipart-form parameters
* @param temporaryFileCreator the temporary file creator.
* @param mat a Akka Streams Materializer
* @return the modified builder
*/
public RequestBuilder bodyRaw(List<MultipartFormData.Part<Source<ByteString, ?>>> data, Files.TemporaryFileCreator temporaryFileCreator, Materializer mat) {
String boundary = MultipartFormatter.randomBoundary();
try {
ByteString materializedData = MultipartFormatter
.transform(Source.from(data), boundary)
.runWith(Sink.reduce(ByteString::concat), mat)
.toCompletableFuture()
.get();
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(materializedData.size(), temporaryFileCreator.asScala(), materializedData);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), MultipartFormatter.boundaryToContentType(boundary));
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException("Failure while materializing Multipart/Form Data", e);
}
}
代码示例来源:origin: com.typesafe.play/play
/**
* Set a Multipart Form url encoded body to this request saving it as a raw body.
*
* @param data the multipart-form parameters
* @param temporaryFileCreator the temporary file creator.
* @param mat a Akka Streams Materializer
* @return the modified builder
*/
public RequestBuilder bodyRaw(List<MultipartFormData.Part<Source<ByteString, ?>>> data, Files.TemporaryFileCreator temporaryFileCreator, Materializer mat) {
String boundary = MultipartFormatter.randomBoundary();
try {
ByteString materializedData = MultipartFormatter
.transform(Source.from(data), boundary)
.runWith(Sink.reduce(ByteString::concat), mat)
.toCompletableFuture()
.get();
play.api.mvc.RawBuffer buffer = new play.api.mvc.RawBuffer(materializedData.size(), temporaryFileCreator.asScala(), materializedData);
return body(new RequestBody(JavaParsers.toJavaRaw(buffer)), MultipartFormatter.boundaryToContentType(boundary));
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException("Failure while materializing Multipart/Form Data", e);
}
}
代码示例来源:origin: elder-oss/sourcerer
@SuppressWarnings("unchecked")
private ImmutableMap<String, String> fromEsMetadata(final Content metadata) {
if (metadata == null
|| metadata.contentType() != ContentType.json()
|| metadata.value().size() == 0) {
return ImmutableMap.of();
}
try {
return ImmutableMap.copyOf((Map) objectMapper
.readerFor(new TypeReference<Map<String, String>>() {
})
.readValue(metadata.value().iterator().asInputStream()));
} catch (IOException ex) {
throw new RetriableEventReadException("Internal error reading events", ex);
}
}
代码示例来源:origin: org.elder.sourcerer/sourcerer-eventstore
@SuppressWarnings("unchecked")
private ImmutableMap<String, String> fromEsMetadata(final Content metadata) {
if (metadata == null
|| metadata.contentType() != ContentType.json()
|| metadata.value().size() == 0) {
return ImmutableMap.of();
}
try {
return ImmutableMap.copyOf((Map) objectMapper
.readerFor(new TypeReference<Map<String, String>>() {
})
.readValue(metadata.value().iterator().asInputStream()));
} catch (IOException ex) {
throw new RetriableEventReadException("Internal error reading events", ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!