List of usage examples for java.util UUID getLeastSignificantBits
public long getLeastSignificantBits()
From source file:org.zper.ZPUtils.java
synchronized public static byte[] genTopicIdentity(String topic, int flag) { byte[] identity = new byte[1 + 2 + topic.length() + 16]; ByteBuffer buf = ByteBuffer.wrap(identity); UUID uuid = UUID.randomUUID(); buf.put((byte) topic.hashCode()); buf.put((byte) flag); buf.put((byte) topic.length()); buf.put(topic.getBytes());//w w w . j a v a 2s . com buf.putLong(uuid.getMostSignificantBits()); buf.putLong(uuid.getLeastSignificantBits()); return identity; }
From source file:com.scf.utils.UUIDUtilies.java
protected static String base64Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base64.encodeBase64URLSafeString(bb.array()); }
From source file:com.scf.utils.UUIDUtilies.java
protected static String base58Uuid(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return Base58.encode(bb.array()); }
From source file:domain.Employee.java
private static 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()); }
From source file:org.linguafranca.pwdb.kdbx.dom.DomHelper.java
static String base64FromUuid(UUID uuid) { byte[] buffer = new byte[16]; ByteBuffer b = ByteBuffer.wrap(buffer); b.putLong(uuid.getMostSignificantBits()); b.putLong(8, uuid.getLeastSignificantBits()); // round the houses for Android return new String(Base64.encodeBase64(buffer)); }
From source file:org.linguafranca.pwdb.kdbx.dom.DomHelper.java
static String hexStringFromUuid(UUID uuid) { byte[] buffer = new byte[16]; ByteBuffer b = ByteBuffer.wrap(buffer); b.putLong(uuid.getMostSignificantBits()); b.putLong(8, uuid.getLeastSignificantBits()); // round the houses for Android return new String(Hex.encodeHex(buffer)); }
From source file:org.openmrs.module.casereport.DocumentUtil.java
/** * Converts the specified uuid to its decimal representation * //from w w w . ja va2 s .co m * @param uuid the uuid to convert * @return a string representation of the decimal number */ public static String convertToDecimal(UUID uuid) { ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); BigInteger bi = new BigInteger(bb.array()); //Get the unsigned representation for -ve numbers if (bi.compareTo(BigInteger.ZERO) < 0) { bi = DECIMAL_REP_COUNT.add(bi); } return bi.toString(); }
From source file:ec.edu.chyc.manejopersonal.util.ServerUtils.java
/*** * Devuelve un UUID generado y codificado en Base64 * * @return Uuid codificado en Base64//from w w w . j a v a2s . com */ public static String generateB64Uuid() { UUID uuid = UUID.randomUUID(); ByteBuffer uuidBytes = ByteBuffer.wrap(new byte[16]); uuidBytes.putLong(uuid.getMostSignificantBits()).putLong(uuid.getLeastSignificantBits()); String asB64 = Base64.getEncoder().encodeToString(uuidBytes.array()); return asB64; }
From source file:UUIDGenerator.java
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;/*from w w w.j a v a 2 s. co m*/ }
From source file:com.predic8.membrane.core.interceptor.statistics.util.JDBCUtil.java
public static void setData(AbstractExchange exc, PreparedStatement prepSt, boolean idGenerated, int flag, String tId, String[] gatewayHCIDs) throws SQLException { int startIndex = 0; if (!idGenerated) { UUID id = UUID.randomUUID(); prepSt.setLong(++startIndex, id.getLeastSignificantBits()); }//from ww w . ja v a 2 s.c o m boolean isReq = (exc.getResponse() == null); log.info("Handling interceptor id is: " + tId); log.info((isReq) ? "logging for request" : "logging for response"); prepSt.setInt(++startIndex, (isReq) ? 200 : exc.getResponse().getStatusCode()); prepSt.setString(++startIndex, (flag == 0) ? "REQUEST" : "RESPONSE"); prepSt.setTimestamp(++startIndex, new Timestamp(ExchangesUtil.getDate(exc).getTime()));//skb prepSt.setString(++startIndex, exc.getRule().toString()); prepSt.setString(++startIndex, exc.getRequest().getMethod()); prepSt.setString(++startIndex, exc.getRequest().getUri()); prepSt.setString(++startIndex, (gatewayHCIDs != null && !"".equals(gatewayHCIDs[2])) ? gatewayHCIDs[2] : exc.getSourceHostname()); prepSt.setString(++startIndex, (gatewayHCIDs != null && !"".equals(gatewayHCIDs[3])) ? gatewayHCIDs[3] : exc.getServer()); if (gatewayHCIDs != null) { prepSt.setString(++startIndex, gatewayHCIDs[0]); prepSt.setString(++startIndex, gatewayHCIDs[1]); } else { prepSt.setString(++startIndex, exc.getSourceHostname()); prepSt.setString(++startIndex, exc.getServer()); } prepSt.setString(++startIndex, (isReq) ? exc.getRequestContentType() : exc.getResponseContentType()); prepSt.setInt(++startIndex, (isReq) ? exc.getRequestContentLength() : exc.getResponseContentLength()); /* prepSt.setString(++ startIndex, (isReq)?null:exc.getResponseContentType()); prepSt.setInt(++ startIndex, (isReq)?null:exc.getResponseContentLength()); */ prepSt.setLong(++startIndex, (isReq) ? 0 : (exc.getTimeResReceived() - exc.getTimeReqSent())); prepSt.setString(++startIndex, (String) getExProperty(exc, FileExchangeStore.MESSAGE_FILE_PATH)); /* skb */ String[] colList = { JDBCUtil.MSG_HEADER, JDBCUtil.MSG }; if (isReq) { for (String col : colList) { log.info("processing col:" + col); ++startIndex; try { byte[] os = (byte[]) getExProperty(exc, col); if (os != null) { prepSt.setBytes(startIndex, os); } else prepSt.setBytes(startIndex, null); } catch (Exception ex) { prepSt.setBytes(startIndex, null); } } } else { for (String col : colList) { log.info("processing col:" + col); ++startIndex; try { byte[] os = null; if (col.equals(JDBCUtil.MSG)) { try { os = IOUtils.toByteArray((exc.getResponse().getBodyAsStream())); } catch (Exception ex) { log.info(ex.toString()); } } else if (col.equals(JDBCUtil.MSG_HEADER)) { Message msg2 = exc.getResponse(); ByteArrayOutputStream header2 = new ByteArrayOutputStream(); msg2.writeStartLine(header2); msg2.getHeader().write(header2); header2.write((Constants.CRLF).getBytes()); os = header2.toByteArray(); } if (os != null) { prepSt.setBytes(startIndex, os); } else prepSt.setBytes(startIndex, null); } catch (Exception ex) { prepSt.setBytes(startIndex, null); } } } }