List of usage examples for io.netty.buffer ByteBuf getCharSequence
public abstract CharSequence getCharSequence(int index, int length, Charset charset);
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static String binaryDecodeTEXT(int index, int len, ByteBuf buff) { return buff.getCharSequence(index, len, StandardCharsets.UTF_8).toString(); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static String textDecodeNAME(int index, int len, ByteBuf buff) { return buff.getCharSequence(index, len, StandardCharsets.UTF_8).toString(); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static String binaryDecodeNAME(int index, int len, ByteBuf buff) { return buff.getCharSequence(index, len, StandardCharsets.UTF_8).toString(); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static LocalDate textDecodeDATE(int index, int len, ByteBuf buff) { CharSequence cs = buff.getCharSequence(index, len, StandardCharsets.UTF_8); return LocalDate.parse(cs); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static LocalTime textDecodeTIME(int index, int len, ByteBuf buff) { CharSequence cs = buff.getCharSequence(index, len, StandardCharsets.UTF_8); return LocalTime.parse(cs); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static OffsetTime textDecodeTIMETZ(int index, int len, ByteBuf buff) { CharSequence cs = buff.getCharSequence(index, len, StandardCharsets.UTF_8); return OffsetTime.parse(cs, TimeFormatter.TIMETZ_FORMAT); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static LocalDateTime textDecodeTIMESTAMP(int index, int len, ByteBuf buff) { CharSequence cs = buff.getCharSequence(index, len, StandardCharsets.UTF_8); return LocalDateTime.parse(cs, DateTimeFormatter.TIMESTAMP_FORMAT); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static OffsetDateTime textDecodeTIMESTAMPTZ(int index, int len, ByteBuf buff) { CharSequence cs = buff.getCharSequence(index, len, StandardCharsets.UTF_8); return OffsetDateTime.parse(cs, DateTimeFormatter.TIMESTAMPTZ_FORMAT); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static UUID textDecodeUUID(int index, int len, ByteBuf buff) { return java.util.UUID.fromString(buff.getCharSequence(index, len, StandardCharsets.UTF_8).toString()); }
From source file:io.reactiverse.pgclient.impl.codec.DataTypeCodec.java
License:Apache License
private static Json textDecodeJSONB(int index, int len, ByteBuf buff) { // Try to do without the intermediary String (?) CharSequence cs = buff.getCharSequence(index, len, StandardCharsets.UTF_8); Object value = null;/*from www . j av a 2 s.co m*/ String s = cs.toString(); int pos = 0; while (pos < s.length() && Character.isWhitespace(s.charAt(pos))) { pos++; } if (pos == s.length()) { return null; } else if (s.charAt(pos) == '{') { value = new JsonObject(s); } else if (s.charAt(pos) == '[') { value = new JsonArray(s); } else { try { JsonNode jsonNode = io.vertx.core.json.Json.mapper.readTree(s); if (jsonNode.isNumber()) { value = jsonNode.numberValue(); } else if (jsonNode.isBoolean()) { value = jsonNode.booleanValue(); } else if (jsonNode.isTextual()) { value = jsonNode.textValue(); } } catch (IOException e) { // do nothing } } return Json.create(value); }