List of usage examples for io.netty.buffer ByteBuf writeCharSequence
public abstract int writeCharSequence(CharSequence sequence, Charset charset);
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static void binaryEncodeBPCHAR(String value, ByteBuf buff) { buff.writeCharSequence(value, StandardCharsets.UTF_8); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static void binaryEncodeTEXT(String value, ByteBuf buff) { String s = String.valueOf(value); buff.writeCharSequence(s, StandardCharsets.UTF_8); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static void binaryEncodeNAME(String value, ByteBuf buff) { String s = String.valueOf(value); buff.writeCharSequence(s, StandardCharsets.UTF_8); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static void binaryEncodeJSON(Json value, ByteBuf buff) { String s = io.vertx.core.json.Json.encode(value.value()); buff.writeCharSequence(s, StandardCharsets.UTF_8); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static void binaryEncodeJSONB(Json value, ByteBuf buff) { String s = io.vertx.core.json.Json.encode(value.value()); buff.writeByte(1); // version buff.writeCharSequence(s, StandardCharsets.UTF_8); }
From source file:io.reactiverse.pgclient.impl.codec.util.Util.java
License:Apache License
public static void writeCString(ByteBuf dst, String s, Charset charset) { dst.writeCharSequence(s, charset); dst.writeByte(0); }
From source file:io.reactiverse.pgclient.impl.codec.util.Util.java
License:Apache License
public static void writeCStringUTF8(ByteBuf dst, String s) { dst.writeCharSequence(s, UTF_8); dst.writeByte(0); }
From source file:io.reactiverse.pgclient.UtilTest.java
License:Apache License
private void assertSeparator(String s, int expected) throws Exception { ByteBuf buf = Unpooled.buffer(); buf.writeCharSequence(s, StandardCharsets.UTF_8); UTF8StringEndDetector processor = new UTF8StringEndDetector(); int actual = buf.forEachByte(processor); assertEquals(expected, actual);/*w w w . j a va 2 s.co m*/ }
From source file:no.nb.nna.broprox.dnsservice.DnsLookup.java
License:Apache License
protected void storeDnsRecord(final String host, final State state) throws IOException, NoSuchAlgorithmException, InterruptedException, StatusException { ByteBuf payload = Unpooled.buffer(); // Start the record with a 14-digit date per RFC 2540 VariablePrecisionDateTime fetchDate = new VariablePrecisionDateTime(state.fetchStart, Granularity.SECOND); payload.writeCharSequence(fetchDate.toFormattedString(DateFormat.HERITRIX), StandardCharsets.UTF_8); payload.writeByte('\n'); for (Record r : state.answers) { payload.writeCharSequence(r.toString(), StandardCharsets.UTF_8); payload.writeByte('\n'); }// w ww . j a v a2 s .c o m byte[] buf = new byte[payload.readableBytes()]; payload.getBytes(payload.readerIndex(), buf); CrawlLog.Builder crawlLogBuilder = CrawlLog.newBuilder().setRecordType("response") .setRequestedUri("dns:" + host).setDiscoveryPath("P").setStatusCode(1) .setFetchTimeStamp(ProtoUtils.odtToTs(state.fetchStart)).setIpAddress(state.dnsIp) .setContentType("text/dns").setSize(payload.readableBytes()); // Shall we get a digest on the content downloaded? if (digestContent) { MessageDigest digest = MessageDigest.getInstance(getDigestAlgorithm()); String digestString = "sha1:" + new BigInteger(1, digest.digest(buf)).toString(16); crawlLogBuilder.setBlockDigest(digestString); } CrawlLog crawlLog = crawlLogBuilder.build(); if (db != null) { crawlLog = db.addCrawlLog(crawlLog); } if (contentWriterClient != null) { String uri = contentWriterClient.createSession().sendCrawlLog(crawlLog) .sendPayload(ByteString.copyFrom(buf)).finish(); } LOG.debug("DNS record for {} written", host); }
From source file:org.apache.bookkeeper.common.router.StringUtf8HashRouter.java
License:Apache License
@Override public ByteBuf getRoutingKeyData(String key) { int keyLen = key.length(); ByteBuf keyBuf = PooledByteBufAllocator.DEFAULT.buffer(keyLen); keyBuf.writeCharSequence(key, UTF_8); return keyBuf; }