List of usage examples for com.google.common.io ByteArrayDataOutput toByteArray
byte[] toByteArray();
From source file:org.wso2.carbon.analytics.datasource.core.util.GenericUtils.java
public static byte[] encodeRecordValues(Map<String, Object> values) throws AnalyticsException { ByteArrayDataOutput byteOut = ByteStreams.newDataOutput(); String name;/*from w ww.j av a 2 s . c o m*/ Object value; for (Map.Entry<String, Object> entry : values.entrySet()) { name = entry.getKey(); value = entry.getValue(); byteOut.write(encodeElement(name, value)); } return byteOut.toByteArray(); }
From source file:io.opencensus.implcore.tags.propagation.SerializationUtils.java
static byte[] serializeBinary(TagContext tags) throws TagContextSerializationException { // Use a ByteArrayDataOutput to avoid needing to handle IOExceptions. final ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput(); byteArrayDataOutput.write(VERSION_ID); int totalChars = 0; // Here chars are equivalent to bytes, since we're using ascii chars. for (Iterator<Tag> i = InternalUtils.getTags(tags); i.hasNext();) { Tag tag = i.next();/* w ww. j a v a2 s. c o m*/ if (TagTtl.NO_PROPAGATION.equals(tag.getTagMetadata().getTagTtl())) { continue; } totalChars += tag.getKey().getName().length(); totalChars += tag.getValue().asString().length(); encodeTag(tag, byteArrayDataOutput); } if (totalChars > TAGCONTEXT_SERIALIZED_SIZE_LIMIT) { throw new TagContextSerializationException( "Size of TagContext exceeds the maximum serialized size " + TAGCONTEXT_SERIALIZED_SIZE_LIMIT); } return byteArrayDataOutput.toByteArray(); }
From source file:cherry.foundation.crypto.SecureIntegerEncoder.java
@Override protected byte[] typeToBytes(Integer p) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeInt(p.intValue());/*from ww w. j av a 2 s . c o m*/ return out.toByteArray(); }
From source file:cherry.foundation.crypto.SecureLongEncoder.java
@Override protected byte[] typeToBytes(Long p) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeLong(p.longValue());/*from w w w . j a v a 2 s . c o m*/ return out.toByteArray(); }
From source file:com.facebook.presto.accumulo.model.WrappedRange.java
@JsonValue public byte[] toBytes() throws IOException { ByteArrayDataOutput out = ByteStreams.newDataOutput(); range.write(out);// ww w . j a v a 2s . co m return out.toByteArray(); }
From source file:cherry.goods.crypto.DefaultVersionStrategy.java
@Override public byte[] encode(byte[] data, Integer version) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeInt(version.intValue());// ww w.j a v a 2 s . co m out.write(data); return out.toByteArray(); }
From source file:cherry.foundation.crypto.SecureBigDecimalEncoder.java
@Override protected byte[] typeToBytes(BigDecimal p) { int scale = p.scale(); BigInteger bi = p.scaleByPowerOfTen(scale).toBigIntegerExact(); ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeInt(scale);/*from w w w . j av a 2 s .c om*/ out.write(bi.toByteArray()); return out.toByteArray(); }
From source file:org.apache.hadoop.hbase.index.TableIndices.java
public byte[] toByteArray() throws IOException { ByteArrayDataOutput out = ByteStreams.newDataOutput(); write(out);// w ww . ja v a 2 s . c o m return out.toByteArray(); }
From source file:me.lucko.luckperms.bungee.messaging.BungeeMessagingService.java
@Override protected void sendMessage(String channel, String message) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(message);// w w w . j a v a2 s.co m byte[] data = out.toByteArray(); for (ServerInfo server : plugin.getProxy().getServers().values()) { server.sendData(channel, data, true); } }
From source file:net.minecraftforge.common.network.packet.DimensionRegisterPacket.java
@Override public byte[] generatePacket() { ByteArrayDataOutput dat = ByteStreams.newDataOutput(); dat.writeInt(this.dimensionId); dat.writeInt(this.providerId); return dat.toByteArray(); }