List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:org.onesec.raven.sms.impl.SmsDeliveryReceiptChannel.java
public void sendReport(String report) { if (!isStarted()) return;/*from w ww. ja v a 2 s. c o m*/ try { Matcher matcher = regexpPattern.matcher(report); if (matcher.matches()) { Record rec = deliveryReceiptSchema.createRecord(); SimpleDateFormat fmt = new SimpleDateFormat("yyMMddHHmm"); String messageId = matcher.group(MESSAGE_ID); if (StringUtils.isNumeric(messageId)) rec.setValue(MESSAGE_ID, Long.toHexString(new Long(messageId))); else rec.setValue(MESSAGE_ID, messageId); rec.setValue(SUBMIT_DATE, fmt.parse(matcher.group(SUBMIT_DATE))); rec.setValue(DONE_DATE, fmt.parse(matcher.group(DONE_DATE))); rec.setValue(STATUS, matcher.group(STATUS)); rec.setValue(ERROR_CODE, matcher.group(ERROR_CODE)); if (isLogLevelEnabled(LogLevel.TRACE)) getLogger().trace("Created delivery report record: " + rec); DataSourceHelper.sendDataToConsumers(this, rec, new DataContextImpl(), (DataConsumer) getParent()); } else if (isLogLevelEnabled(LogLevel.WARN)) getLogger().warn("Can't parse delivery receipt report: {}", report); } catch (Exception e) { if (isLogLevelEnabled(LogLevel.ERROR)) getLogger().error("Error creating DELIVERY RECEIPT report", e); } }
From source file:UuidUtil.java
private static String addRandomTo(String hexString) { long hexAsLong = convertToLong(hexString); int nextRandom = getNextInt(); long resultInt = hexAsLong + nextRandom; String result = Long.toHexString(resultInt); // START PWC 6425338 // Always return a length of 7 int len = result.length(); if (len < 7) { result = padto7(result);/*from w ww .ja v a 2s . c o m*/ } else { result = result.substring(len - 7, len); } // END PWC 6425338 return result; }
From source file:org.apache.accumulo.tracer.TraceFormatter.java
@Override public String next() { Entry<Key, Value> next = scanner.next(); if (next.getKey().getColumnFamily().equals(SPAN_CF)) { StringBuilder result = new StringBuilder(); SimpleDateFormat dateFormatter = new SimpleDateFormat(DATE_FORMAT); RemoteSpan span = getRemoteSpan(next); result.append("----------------------\n"); result.append(String.format(" %12s:%s%n", "name", span.description)); result.append(String.format(" %12s:%s%n", "trace", Long.toHexString(span.traceId))); result.append(String.format(" %12s:%s%n", "loc", span.svc + "@" + span.sender)); result.append(String.format(" %12s:%s%n", "span", Long.toHexString(span.spanId))); result.append(String.format(" %12s:%s%n", "parent", Long.toHexString(span.parentId))); result.append(String.format(" %12s:%s%n", "start", dateFormatter.format(span.start))); result.append(String.format(" %12s:%s%n", "ms", span.stop - span.start)); if (span.data != null) { for (Entry<String, String> entry : span.data.entrySet()) { result.append(String.format(" %12s:%s%n", entry.getKey(), entry.getValue())); }/*from w w w .j a v a 2s. c om*/ } if (span.annotations != null) { for (Annotation annotation : span.annotations) { result.append(String.format(" %12s:%s:%s%n", "annotation", annotation.getMsg(), dateFormatter.format(annotation.getTime()))); } } if (config.willPrintTimestamps()) { result.append(String.format(" %-12s:%d%n", "timestamp", next.getKey().getTimestamp())); } return result.toString(); } return DefaultFormatter.formatEntry(next, config.willPrintTimestamps()); }
From source file:org.sakaiproject.nakamura.messagebucket.UntrustedMessageBucketServiceImpl.java
public String getToken(String userId, String context) throws MessageBucketException { try {//from w w w . ja va 2s. c o m String timeStamp = Long.toHexString(System.currentTimeMillis()); String hmac = Signature.calculateRFC2104HMAC(userId + ";" + timeStamp + ";" + context, sharedSecret); String token = userId + ";" + timeStamp + ";" + context + ";" + hmac; return Base64.encodeBase64URLSafeString(token.getBytes("UTF8")); } catch (SignatureException e) { throw new MessageBucketException(e.getMessage(), e); } catch (UnsupportedEncodingException e) { throw new MessageBucketException(e.getMessage(), e); } }
From source file:com.gmail.nagamatu.radiko.installer.RadikoInstallerActivity.java
private static String getDeviceId(Context context) { String id = null;// w w w . ja va2s. co m Cursor c = context.getContentResolver().query(URI_GFS_SERVICE, null, null, new String[] { "android_id" }, null); try { c.moveToFirst(); id = Long.toHexString(Long.parseLong(c.getString(1))); } catch (Exception e) { e.printStackTrace(); } finally { if (c != null) { c.close(); } } return id; }
From source file:org.apache.accumulo.server.master.tableOps.Utils.java
public static long reserveTable(String tableId, long tid, boolean writeLock, boolean tableMustExist, TableOperation op) throws Exception { if (getLock(tableId, tid, writeLock).tryLock()) { if (tableMustExist) { Instance instance = HdfsZooInstance.getInstance(); IZooReaderWriter zk = ZooReaderWriter.getRetryingInstance(); if (!zk.exists(ZooUtil.getRoot(instance) + Constants.ZTABLES + "/" + tableId)) throw new ThriftTableOperationException(tableId, "", op, TableOperationExceptionType.NOTFOUND, "Table does not exists"); }// w w w .ja v a2 s.c om log.info("table " + tableId + " (" + Long.toHexString(tid) + ") locked for " + (writeLock ? "write" : "read") + " operation: " + op); return 0; } else return 100; }
From source file:interactivespaces.service.web.server.BasicMultipleConnectionWebServerWebSocketHandlerFactory.java
/** * Create a new connection ID. * * @return the new connection ID */ private String newConnectionId() { return Long.toHexString(connectionIdFactory.getAndAdd(1)); }
From source file:com.enonic.cms.business.portal.instruction.PostProcessInstructionExecutorImplTest.java
@Before public void setUp() { executor = new PostProcessInstructionExecutorImpl(); serverName = "test.com"; now = Calendar.getInstance(); timeStamp = Long.toHexString(now.getTimeInMillis()); executor.setFileResourceService(setUpResourceServiceMock(now)); executor.setMenuItemDao(setUpMenuItemDaoMock()); request = setUpMockRequest(serverName); ServletRequestAccessor.setRequest(request); context = setUpContext(request);//from w w w . j a v a 2 s . c om // make sure site-path isn't applied in the final path VirtualHostHelper.setBasePath(request, ""); context.setSiteURLResolverEnableHtmlEscaping(setUpSiteResolverMock(true)); context.setSiteURLResolverDisableHtmlEscaping(setUpSiteResolverMock(false)); }
From source file:org.globus.workspace.common.SecurityUtil.java
private static String hash(byte[] data) { md5.reset();// w ww.j ava 2s . com md5.update(data); final byte[] md = md5.digest(); final long ret = (fixByte(md[0]) | fixByte(md[1]) << 8L | fixByte(md[2]) << 16L | fixByte(md[3]) << 24L) & 0xffffffffL; return Long.toHexString(ret); }
From source file:tools.AbstractIntegrationTest.java
protected ResponseEntity<String> checkStateOfTheTraceId(long traceId) { URI uri = URI.create(getZipkinTraceQueryUrl() + Long.toHexString(traceId)); log.info(String.format(//w w w.j a v a2 s . co m "Sending request to the Zipkin query service [%s]. " + "Checking presence of trace id [%d]", uri, traceId)); return exchangeRequest(uri); }