/** * Constructs a new {@code String} by decoding the bytes as UTF-8. * * @return new string using UTF-8 encoding */ public final String toStringUtf8() { return toString(Internal.UTF_8); }
/** * Constructs a new {@code String} by decoding the bytes as UTF-8. * * @return new string using UTF-8 encoding */ public String toStringUtf8() { try { return toString("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException("UTF-8 not supported?", e); } }
/** * Constructs a new {@code String} by decoding the bytes using the * specified charset. * * @param charsetName encode using this charset * @return new string * @throws UnsupportedEncodingException if charset isn't recognized */ public final String toString(String charsetName) throws UnsupportedEncodingException { try { return toString(Charset.forName(charsetName)); } catch (UnsupportedCharsetException e) { UnsupportedEncodingException exception = new UnsupportedEncodingException(charsetName); exception.initCause(e); throw exception; } }
for (final Column column : family.getColumnsList()) { result.put(column.getQualifier().toString(UTF8_CHARSET), new ByteArrayByteIterator(column.getCells(0).getValue().toByteArray())); if (debug) { System.out.println( "Result for field: " + column.getQualifier().toString(UTF8_CHARSET) + " is: " + column.getCells(0).getValue().toString(UTF8_CHARSET));
for (final Column column : family.getColumnsList()) { rowResult.put(column.getQualifier().toString(UTF8_CHARSET), new ByteArrayByteIterator(column.getCells(0).getValue().toByteArray())); if (debug) { System.out.println( "Result for field: " + column.getQualifier().toString(UTF8_CHARSET) + " is: " + column.getCells(0).getValue().toString(UTF8_CHARSET));
/** * Constructs a new {@code String} by decoding the bytes as UTF-8. * * @return new string using UTF-8 encoding */ public final String toStringUtf8() { return toString(Internal.UTF_8); }
/** * Constructs a new {@code String} by decoding the bytes as UTF-8. * * @return new string using UTF-8 encoding */ public final String toStringUtf8() { return toString(Internal.UTF_8); }
public String toString(Charset charset) { return byteString.toString(charset); }
public String toString(Charset charset) { return byteString.toString(charset); }
/** * Constructs a new {@code String} by decoding the bytes as UTF-8. * * @return new string using UTF-8 encoding */ public String toStringUtf8() { try { return toString("UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException("UTF-8 not supported?", e); } }
public static String convertByteString(ByteString s, String charsetName) { try { return s.toString(charsetName); } catch (UnsupportedEncodingException e) { Util.uncheckedThrow(e); return null; } }
public static String convertByteString(ByteString s, String charsetName) { try { return s.toString(charsetName); } catch (UnsupportedEncodingException e) { Util.uncheckedThrow(e); return null; } }
/** * Constructs a new {@code String} by decoding the bytes using the * specified charset. * * @param charsetName encode using this charset * @return new string * @throws UnsupportedEncodingException if charset isn't recognized */ public final String toString(String charsetName) throws UnsupportedEncodingException { try { return toString(Charset.forName(charsetName)); } catch (UnsupportedCharsetException e) { UnsupportedEncodingException exception = new UnsupportedEncodingException(charsetName); exception.initCause(e); throw exception; } }
/** * Method returns the state source(s) result(s) (contains state value(s)) of the input rfidState. * * @param rfidState The RFIDState. * @return state source(s) result(s) of the input state. */ private List<RdfNodeObject> rfidStateSources(final RFIDState rfidState) { final List<RdfNodeObject> stateSources = new ArrayList<>(); final String rfidData = "\"" + rfidState.getData().toString() + "\"^^xsd:string"; stateSources.add(new RdfNodeObject(new ArrayList<String>() {{add(rfidData);}}, true)); return stateSources; }
public static String translateToString(DocumentDTO docDTO) throws IOException { DocumentWrapper dw = translate(docDTO); return dw.toByteString().toString(); }
private Object convertValueFromProto(AttrProto.Attribute attribute) throws ParseException, IOException { switch (attribute.getContentType()) { case STRING: return attribute.getValue().toString(DEFAULT_CHARSET); case DATE: return DateValue.parseFrom(attribute.getValue().toByteArray()); case JPEG: return new JpegAttributeValue(attribute.getValue().toByteArray()); case PNG: return new PngAttributeValue(attribute.getValue().toByteArray()); case JSON: return JSON_MAPPER.readValue(attribute.getValue().toString(DEFAULT_CHARSET), Map.class); default: LOG.warn("Unknown type '{}' for attribute '{}'. Attempting to parse it as a String", attribute.getContentType(), attribute.getName()); return attribute.getValue().toString(DEFAULT_CHARSET); } }
public FriendMsgCallback(CMsgClientFriendMsgIncoming.Builder msg) { sender = new SteamID(msg.getSteamidFrom()); entryType = EChatEntryType.from(msg.getChatEntryType()); fromLimitedAccount = msg.getFromLimitedAccount(); if (msg.hasMessage()) { message = msg.getMessage().toString(Charset.forName("UTF-8")); message = message.replaceAll("\0+$", ""); // trim any extra null chars from the end } }
public FriendMsgEchoCallback(CMsgClientFriendMsgIncoming.Builder msg) { sender = new SteamID(msg.getSteamidFrom()); entryType = EChatEntryType.from(msg.getChatEntryType()); fromLimitedAccount = msg.getFromLimitedAccount(); if (msg.hasMessage()) { message = msg.getMessage().toString(Charset.forName("UTF-8")); message = message.replaceAll("\0+$", ""); // trim any extra null chars from the end } }
public static String toDebugString(Update u) { if (u == null) { return null; } else { ByteString truncated = ByteString.copyFromUtf8(StringUtils.abbreviate(u.getData().toString(Charsets.UTF_8), 50)); return TextFormat.shortDebugString(Update.newBuilder(u).setData(truncated).build()); } }
@Test public void sendChatMessage() throws UnsupportedEncodingException { SteamID testId = new SteamID(123456789L); handler.sendChatMessage(testId, EChatEntryType.ChatMsg, "testmessage"); ClientMsgProtobuf<CMsgClientFriendMsg.Builder> msg = verifySend(EMsg.ClientFriendMsg); assertEquals(123456789L, msg.getBody().getSteamid()); assertEquals("testmessage", msg.getBody().getMessage().toString("UTF-8")); assertEquals(EChatEntryType.ChatMsg.code(), msg.getBody().getChatEntryType()); }