@Nullable @Override public byte[] convert(Binary source) { return source.getData(); } }
private Binary getData() { if (bufferOffset < chunkSizeBytes) { byte[] sizedBuffer = new byte[bufferOffset]; System.arraycopy(buffer, 0, sizedBuffer, 0, bufferOffset); buffer = sizedBuffer; } return new Binary(buffer); }
@Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null) { return null; } if (Message.class.isAssignableFrom(sourceType.getObjectType())) { return new Binary(this.serializingConverter.convert(source)); } else { return this.deserializingConverter.convert(((Binary) source).getData()); } }
public static void main(String[] args) throws IOException { System.out.println("enter the number you want to convert"); BufferedReader bReader = new BufferedReader(newInputStreamReader(System.in)); int number = Integer.parseInt(bReader.readLine()); Binary binaryObject = new Binary(); StringBuffer result = binaryObject.calculateBinary(number); System.out.println(result); }
@Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { if (source == null) { return null; } if (Message.class.isAssignableFrom(sourceType.getObjectType())) { return new Binary(this.serializingConverter.convert(source)); } else { return this.deserializingConverter.convert(((Binary) source).getData()); } }
public Builder initialTimestamp(Binary initialTimestamp) { this.initialTimestamp = new Timestamp.GTID(initialTimestamp.getData(), null); return this; }
private Criteria stringBitmask(String operator, String bitmask) { Assert.hasText(bitmask, "Bitmask must not be null!"); target.criteria.put(operator, new Binary(Base64Utils.decodeFromString(bitmask))); return target; }
/** * deserializes DBBinary/byte[] to object * * @param data the data to read * @param zipped true if the data is compressed * @return the deserialized object * @throws IOException thrown when an error is encountered reading the data * @throws ClassNotFoundException thrown if the Class definition can not be found */ public static Object deserialize(final Object data, final boolean zipped) throws IOException, ClassNotFoundException { final ByteArrayInputStream bais; if (data instanceof Binary) { bais = new ByteArrayInputStream(((Binary) data).getData()); } else { bais = new ByteArrayInputStream((byte[]) data); } InputStream is = bais; try { if (zipped) { is = new GZIPInputStream(is); } final ObjectInputStream ois = new ObjectInputStream(is); return ois.readObject(); } finally { is.close(); } }
@Override public void gotBinary(final String name, final byte type, final byte[] data) { if (type == BSON.B_GENERAL || type == BSON.B_BINARY) { _put(name, data); } else { _put(name, new Binary(type, data)); } }
/** * Fills the map with the values from the DBObject. * * @param resultMap * The map to fill/ * @param obj * The object to copy values from. */ protected void fillMap(Map<String, ByteIterator> resultMap, Document obj) { for (Map.Entry<String, Object> entry : obj.entrySet()) { if (entry.getValue() instanceof Binary) { resultMap.put(entry.getKey(), new ByteArrayByteIterator(((Binary) entry.getValue()).getData())); } } } }
@Override public String encode(CodecRegistryProvider provider, boolean quoted) { if (quoted) { return Base64Utils.encodeToString(this.value); } return encode(provider, new Binary(this.value), BinaryCodec::new); } }
result = new Timestamp.GTID(((Binary) id).getData(), (Date) timestamp); } else if (id instanceof byte[]) { result = new Timestamp.GTID((byte[]) id, (Date) timestamp);
@Override public Binary decode(final BsonReader reader, final DecoderContext decoderContext) { BsonBinary bsonBinary = reader.readBinaryData(); return new Binary(bsonBinary.getType(), bsonBinary.getData()); }
private void writeSlice(BlockBuilder output, Type type, Object value) { String base = type.getTypeSignature().getBase(); if (base.equals(StandardTypes.VARCHAR)) { type.writeSlice(output, utf8Slice(toVarcharValue(value))); } else if (type.equals(OBJECT_ID)) { type.writeSlice(output, wrappedBuffer(((ObjectId) value).toByteArray())); } else if (type.equals(VARBINARY)) { if (value instanceof Binary) { type.writeSlice(output, wrappedBuffer(((Binary) value).getData())); } else { output.appendNull(); } } else { throw new PrestoException(GENERIC_INTERNAL_ERROR, "Unhandled type for Slice: " + type.getTypeSignature()); } }
return new Binary(type.getSlice(block, position).getBytes());