public THandleIdentifier toTHandleIdentifier() { byte[] guid = new byte[16]; byte[] secret = new byte[16]; ByteBuffer guidBB = ByteBuffer.wrap(guid); ByteBuffer secretBB = ByteBuffer.wrap(secret); guidBB.putLong(publicId.getMostSignificantBits()); guidBB.putLong(publicId.getLeastSignificantBits()); secretBB.putLong(secretId.getMostSignificantBits()); secretBB.putLong(secretId.getLeastSignificantBits()); return new THandleIdentifier(ByteBuffer.wrap(guid), ByteBuffer.wrap(secret)); }
@Override public void writeExternal(DataOutput out) throws IOException { super.writeExternal(out); out.writeLong(uuid1.getMostSignificantBits()); out.writeLong(uuid1.getLeastSignificantBits()); out.writeLong(uuid2.getMostSignificantBits()); out.writeLong(uuid2.getLeastSignificantBits()); out.writeLong(uuid3.getMostSignificantBits()); out.writeLong(uuid3.getLeastSignificantBits()); UtfHelper.writeUtf(out, string1); }
@Override public void writeExternal(final ObjectOutput out) throws IOException { out.writeLong(queryId.getMostSignificantBits()); out.writeLong(queryId.getLeastSignificantBits()); out.writeLong(serviceId.getMostSignificantBits()); out.writeLong(serviceId.getLeastSignificantBits()); out.writeInt(bopId); out.writeInt(partitionId); // Note: partitionId is 32-bits clean LongPacker.packLong(out, sinkMessagesOut); LongPacker.packLong(out, altSinkMessagesOut); // out.writeInt(sinkMessagesOut); // out.writeInt(altSinkMessagesOut); out.writeObject(stats); out.writeObject(cause); }
public static JpsRemoteProto.Message.UUID toProtoUUID(UUID requestId) { return JpsRemoteProto.Message.UUID .newBuilder() .setMostSigBits(requestId.getMostSignificantBits()) .setLeastSigBits(requestId.getLeastSignificantBits()) .build(); }
/** * Writes header of a set of segments (e.g. segments from one locus). * * @param taxonId NCBI taxon id (see: <a * href="http://www.ncbi.nlm.nih.gov/taxonomy">http://www.ncbi.nlm.nih.gov/taxonomy</a>) * @param locus gene * @param uuid uuid * @throws java.io.IOException if an I/O error occurs. */ public void writeBeginOfLocus(int taxonId, Locus locus, UUID uuid) throws IOException { stream.writeByte(LOCUS_BEGIN_TYPE); stream.writeUTF(locus.getId()); stream.writeInt(taxonId); stream.writeLong(uuid.getLeastSignificantBits()); stream.writeLong(uuid.getMostSignificantBits()); }
protected void putUUID(String name, UUID val) { _put(BINARY, name); _buf.writeInt(16); _buf.write(B_UUID); _buf.writeLong(val.getMostSignificantBits()); _buf.writeLong(val.getLeastSignificantBits()); }
public static void addCryptoInputParcel( Context context, Intent data, CryptoInputParcel inputParcel) { UUID mTicket = addCryptoInputParcel(context, inputParcel); // And write out the UUID most and least significant bits. data.putExtra(OpenPgpApi.EXTRA_CALL_UUID1, mTicket.getMostSignificantBits()); data.putExtra(OpenPgpApi.EXTRA_CALL_UUID2, mTicket.getLeastSignificantBits()); }
public static String fromSeed(String seed) { StringBuilder sb = new StringBuilder(); UUID uuid = UUID.nameUUIDFromBytes(seed.getBytes()); sb.append( String.format("%016x%016x", uuid.getMostSignificantBits(), uuid.getLeastSignificantBits())); return sb.toString(); }
protected static String a() { String str = null; try { Info advertisingIdInfo = AdvertisingIdClient.getAdvertisingIdInfo(Chartboost.sharedChartboost().getContext()); } catch (IOException e) { String str2 = str; } catch (GooglePlayServicesRepairableException e2) { str2 = str; } catch (GooglePlayServicesNotAvailableException e3) { str2 = str; } if (advertisingIdInfo == null) { c.a(a.c); return str; } else { if (advertisingIdInfo.isLimitAdTrackingEnabled()) { c.a(a.e); } else { c.a(a.d); } try { UUID fromString = UUID.fromString(advertisingIdInfo.getId()); ByteBuffer wrap = ByteBuffer.wrap(new byte[16]); wrap.putLong(fromString.getMostSignificantBits()); wrap.putLong(fromString.getLeastSignificantBits()); return b.b(wrap.array()); } catch (IllegalArgumentException e4) { CBLogging.a("CBIdentityAdv", "Exception raised retrieveAdvertisingID", e4); return advertisingIdInfo.getId().replace("-", AdTrackerConstants.BLANK); } } }
/** * Serialize an object into a given byte buffer. * * @param o The object to serialize. * @param b The bytebuf to serialize it into. */ @Override public void serialize(Object o, ByteBuf b) { String className = o == null ? "null" : o.getClass().getName(); if (className.contains("$ByteBuddy$")) { String SMRClass = className.split("\\$")[0]; className = "CorfuObject"; byte[] classNameBytes = className.getBytes(); b.writeShort(classNameBytes.length); b.writeBytes(classNameBytes); byte[] SMRClassNameBytes = SMRClass.getBytes(); b.writeShort(SMRClassNameBytes.length); b.writeBytes(SMRClassNameBytes); UUID id = ((ICorfuObject) o).getStreamID(); log.trace("Serializing a CorfuObject of type {} as a stream pointer to {}", SMRClass, id); b.writeLong(id.getMostSignificantBits()); b.writeLong(id.getLeastSignificantBits()); } else { byte[] classNameBytes = className.getBytes(); b.writeShort(classNameBytes.length); b.writeBytes(classNameBytes); if (o == null) { return; } try (ByteBufOutputStream bbos = new ByteBufOutputStream(b)) { try (OutputStreamWriter osw = new OutputStreamWriter(bbos)) { gson.toJson(o, o.getClass(), osw); } } catch (IOException ie) { log.error("Exception during serialization!", ie); } } }
// implement click listener @Override public void onClick(View v) { // read from Edit View String client_name = client_name_EditText.getText().toString(); String server_address = server_address_EditText.getText().toString(); // get preference int mode = Activity.MODE_PRIVATE; SharedPreferences preferences = getSharedPreferences(MY_PREFS, mode); SharedPreferences.Editor editor = preferences.edit(); editor.putString(CLIENT_NAME, client_name); editor.putLong(CLIENT_ID, 0); editor.putString(SERVER_ADDRESS, server_address); editor.putString(CHAT_ROOM_NAME, "_DEFAULT"); editor.putLong(SEQUENCE_NUMBER, 0); // sequence record starts with 0 editor.putString(LATITUDE, "0"); editor.putString(LONGITUDE, "0"); UUID registerationID = UUID.randomUUID(); long least = registerationID.getLeastSignificantBits(); long most = registerationID.getMostSignificantBits(); editor.putLong(LEAST_SIGNIFICANT_BITS, least); editor.putLong(MOST_SIGNIFICANT_BITS, most); // commit editor.commit(); }
public String uuidToBase64(String str) { UUID uuid = UUID.fromString(str); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
@Override public void serializeNative(UUID object, byte[] stream, int startPosition, Object... hints) { OLongSerializer.INSTANCE.serializeNative( object.getMostSignificantBits(), stream, startPosition, hints); OLongSerializer.INSTANCE.serializeNative( object.getLeastSignificantBits(), stream, startPosition + OLongSerializer.LONG_SIZE, hints); }
@Override public OutputStream getOutputStream(Blob blob) throws BlobException { UUID uuid = UUID.randomUUID(); byte[] blobKey = Bytes.toBytes(uuid.getMostSignificantBits()); blobKey = Bytes.add(blobKey, Bytes.toBytes(uuid.getLeastSignificantBits())); return new HBaseBlobOutputStream(table, blobKey, blob); }
public String newId(String... body) { StringBuilder id = new StringBuilder(); if (body != null) for (String p : body) if (p != null) id.append(p).append('_'); UUID uid = id.length() > 0 ? UUID.fromString(id.toString()) : UUID.randomUUID(); return String.valueOf(uid.getMostSignificantBits()) + String.valueOf(uid.getLeastSignificantBits()); }
/* * Creates a type 4 UUID */ private static byte[] createType4() { UUID type4 = UUID.randomUUID(); byte[] uuid = new byte[16]; longToBytes(type4.getMostSignificantBits(), uuid, 0); longToBytes(type4.getLeastSignificantBits(), uuid, 8); return uuid; }
private static byte[] createTCPMsg(int opcode) { ByteBuffer buffer = ByteBuffer.wrap(new byte[1]); switch (opcode) { case 0: buffer = ByteBuffer.wrap(new byte[1]); buffer.put((byte) 0x00); break; case 1: String userName = "******"; buffer = ByteBuffer.wrap(new byte[userName.length() + 1]); buffer.put((byte) 0x01); buffer.put(userName.getBytes(StandardCharsets.UTF_8)); break; case 2: case 3: case 4: buffer = ByteBuffer.wrap(new byte[17]); buffer.put((byte) opcode); buffer.putLong(userId.getMostSignificantBits()); buffer.putLong(userId.getLeastSignificantBits()); break; } return buffer.array(); }
public VersionedStatsLRURegionEntryHeapUUIDKey( RegionEntryContext context, UUID key, Object value) { super(context, value); // DO NOT modify this class. It was generated from LeafRegionEntry.cpp this.keyMostSigBits = key.getMostSignificantBits(); this.keyLeastSigBits = key.getLeastSignificantBits(); }
public static String generate() { StringBuilder sb = new StringBuilder(); UUID uuid = UUID.randomUUID(); sb.append( String.format("%016x%016x", uuid.getMostSignificantBits(), uuid.getLeastSignificantBits())); return sb.toString(); }
@Override protected void setUpdateStatementValues(ChargeSession session, PreparedStatement ps) throws SQLException { // cols: auth_status = ?, xid = ?, ended = ?, posted = ? // sessionid_hi, sessionid_lo ps.setString(1, session.getStatus() != null ? session.getStatus().toString() : null); if (session.getTransactionId() == null) { ps.setNull(2, Types.BIGINT); } else { ps.setLong(2, session.getTransactionId().longValue()); } if (session.getEnded() != null) { // store ts in UTC time zone Calendar cal = calendarForDate(session.getEnded()); Timestamp ts = new Timestamp(cal.getTimeInMillis()); ps.setTimestamp(3, ts, cal); } else { ps.setNull(3, Types.TIMESTAMP); } if (session.getPosted() != null) { // store ts in UTC time zone Calendar cal = calendarForDate(session.getPosted()); Timestamp ts = new Timestamp(cal.getTimeInMillis()); ps.setTimestamp(4, ts, cal); } else { ps.setNull(4, Types.TIMESTAMP); } UUID pk = UUID.fromString(session.getSessionId()); ps.setLong(5, pk.getMostSignificantBits()); ps.setLong(6, pk.getLeastSignificantBits()); }
@Override public void save(ProtectedChunkRegion protectedChunkRegion) { PreparedStatement var1; Iterator<ProtectedChunk> var2 = protectedChunkRegion.getProtectedChunks().iterator(); ProtectedChunk var3; UUID currentUUID; while (var2.hasNext()) { try { var1 = baseSqliteConnection.createPreparedStatement( baseSqliteConnection.insertRegionIndex.replace( "%w", protectedChunkRegion.getWorld().getUID().toString().replace("-", ""))); var3 = var2.next(); currentUUID = protectedChunkRegion.getUUID(); var1.setString(1, protectedChunkRegion.getId()); var1.setInt(2, var3.getX()); var1.setInt(3, var3.getZ()); var1.setString( 4, String.format( "%s:%s", String.valueOf(currentUUID.getMostSignificantBits()), String.valueOf(currentUUID.getLeastSignificantBits()))); var1.executeUpdate(); var1.close(); var1 = baseSqliteConnection.createPreparedStatement( baseSqliteConnection.insertRegion.replace( "%w", protectedChunkRegion.getWorld().getUID().toString().replace("-", ""))); var1.setString( 1, String.format( "%s:%s", String.valueOf(currentUUID.getMostSignificantBits()), String.valueOf(currentUUID.getLeastSignificantBits()))); var1.setString(2, protectedChunkRegion.serialize()); var1.executeUpdate(); var1.close(); } catch (SQLException e) { e.printStackTrace(); } } }
@Override public void writeEntityToNBT(NBTTagCompound nbt) { super.writeEntityToNBT(nbt); nbt.setLong("friendPlayerUUID-lsb", friendPlayerUUID.getLeastSignificantBits()); nbt.setLong("friendPlayerUUID-msb", friendPlayerUUID.getMostSignificantBits()); nbt.setBoolean("isImprisoned", isImprisoned); }
public String getCompUniqueID() { UUID tempID = null; long longID = 0L; StringBuffer result = new StringBuffer(); tempID = getPackage_id(); if (IdAssigner.NULL_UUID.equals(tempID)) tempID = getPackage_idCachedValue(); result.append(Long.toHexString(tempID.getMostSignificantBits())); result.append(Long.toHexString(tempID.getLeastSignificantBits())); tempID = getDt_id(); if (IdAssigner.NULL_UUID.equals(tempID)) tempID = getDt_idCachedValue(); result.append(Long.toHexString(tempID.getMostSignificantBits())); result.append(Long.toHexString(tempID.getLeastSignificantBits())); return result.toString(); }
@Override public int hashCode() { UUID uid = getUID(); long hash = uid.getMostSignificantBits(); hash += (hash << 5) + uid.getLeastSignificantBits(); return (int) (hash ^ hash >> 32); }
@Override public void serializeInDirectMemory( UUID object, ODirectMemoryPointer pointer, long offset, Object... hints) { OLongSerializer.INSTANCE.serializeInDirectMemory( object.getMostSignificantBits(), pointer, offset, hints); OLongSerializer.INSTANCE.serializeInDirectMemory( object.getLeastSignificantBits(), pointer, offset + OLongSerializer.LONG_SIZE, hints); }
@Override public void writeCustomNBT(NBTTagCompound cmp) { super.writeCustomNBT(cmp); if (golemConnected != null) { cmp.setLong(TAG_UUID_MOST, golemConnected.getMostSignificantBits()); cmp.setLong(TAG_UUID_LEAST, golemConnected.getLeastSignificantBits()); } }
@Test public void testTimeUUID() { // two different UUIDs w/ the same timestamp UUID uuid1 = UUID.fromString("1077e700-c7f2-11de-86d5-f5bcc793a028"); byte[] bytes1 = new byte[16]; ByteBuffer bb1 = ByteBuffer.wrap(bytes1); bb1.putLong(uuid1.getMostSignificantBits()); bb1.putLong(uuid1.getLeastSignificantBits()); UUID uuid2 = UUID.fromString("1077e700-c7f2-11de-982e-6fad363d5f29"); byte[] bytes2 = new byte[16]; ByteBuffer bb2 = ByteBuffer.wrap(bytes2); bb2.putLong(uuid2.getMostSignificantBits()); bb2.putLong(uuid2.getLeastSignificantBits()); assert new TimeUUIDType().compare(ByteBuffer.wrap(bytes1), ByteBuffer.wrap(bytes2)) != 0; }
@Override public void objectToEntry(List<UUID> e, TupleOutput to) { to.writeShort(e.size()); for (UUID uuid : e) { to.writeLong(uuid.getMostSignificantBits()); to.writeLong(uuid.getLeastSignificantBits()); } }
@Override public SessionID createIdentifier() { final UUID uuid = UUID.randomUUID(); ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return SessionID.createSessionID(bb.array()); }
@Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(spiderType.getId()); if (owner != null) { buffer.writeLong(owner.getMostSignificantBits()); buffer.writeLong(owner.getLeastSignificantBits()); } }