@Override public void run() { StringObservable.from(new ByteArrayInputStream("ABC".getBytes())) .subscribe(new Action1<byte[]>() { @Override public void call(byte[] bytes) { log(bytes.length); } }); } });
@Override public void run() { StringObservable.encode(Observable.just("abc"), "UTF-8").subscribe(new Action1<byte[]>() { @Override public void call(byte[] bytes) { log(bytes.length); } }); } });
@Override public void run() { StringObservable.decode(Observable.just("ABC".getBytes(Charset.forName("UTF-8"))), Charset.forName("UTF-8")).subscribe(new Action1<String>() { @Override public void call(String s) { log(s); } }); } });
@Override public void run() { StringObservable.join(Observable.just("abc", "def"), "#").subscribe(new Action1<String>() { @Override public void call(String s) { log(s); } }); } });
@Override public void run() { StringObservable.byLine(Observable.just("ab\r\ncd\r\nef", "12\r\n34")) .subscribe(new Action1<String>() { @Override public void call(String s) { log(s); } }); } });
@Override public void run() { StringObservable.split(Observable.just("ab#cd#ef"), "#").subscribe(new Action1<String>() { @Override public void call(String s) { log(s); } }); } });
@Override public void run() { StringObservable.stringConcat(Observable.just("abc", "def")) .subscribe(new Action1<String>() { @Override public void call(String s) { log(s); } }); } });
@Override public Observable<byte[]> asChunks() { return StringObservable.from(inputStream) .doAfterTerminate(completionHandler != null ? completionHandler : () -> {}); }
Observable<byte[]> body = StringObservable.encode(Observable.just(queryText), StandardCharsets.UTF_8); return new RxDocumentServiceRequest(operation, resourceType, relativePath, body, headers);
@Test public void decode() { byte[] bytes = new byte[16]; Arrays.fill(bytes, (byte)65); byte[] bytes2 = new byte[16]; Arrays.fill(bytes, (byte)65); bytes[15] = 10; Observable<byte[]> data = Observable.just(bytes, bytes, bytes2).repeat(500); StringObservable.decode(data, StandardCharsets.UTF_8) .observeOn(Schedulers.computation(), false, 1) .toBlocking() .subscribe(System.out::println); }
/** * Creates a DocumentServiceRequest with a stream. * * @param operation the operation type. * @param resourceType the resource type. * @param relativePath the relative URI path. * @param inputStream the input stream. * @param headers the request headers. * @return the created document service request. */ public static RxDocumentServiceRequest create(OperationType operation, ResourceType resourceType, String relativePath, InputStream inputStream, Map<String, String> headers) { return new RxDocumentServiceRequest(operation, resourceType, relativePath, StringObservable.from(inputStream), headers); }
Observable<byte[]> body = StringObservable.encode(Observable.just(queryText), StandardCharsets.UTF_8); return new RxDocumentServiceRequest(operation, resourceType, relativePath, body, headers);
/** * Creates a DocumentServiceRequest with a stream. * * @param operation the operation type. * @param resourceType the resource type. * @param relativePath the relative URI path. * @param inputStream the input stream. * @param headers the request headers. * @return the created document service request. */ public static RxDocumentServiceRequest create(OperationType operation, ResourceType resourceType, String relativePath, InputStream inputStream, Map<String, String> headers) { // StringObservable is mis-named. It doesn't make any assumptions on character set // and handles bytes only return new RxDocumentServiceRequest(operation, resourceType, relativePath, StringObservable.from(inputStream), headers); }