List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:Main.java
/** * @param long64/*from ww w. ja v a2 s . co m*/ * @return */ public static String encode64BitLong(long long64) { String hexString = Long.toHexString(long64); String highPart = "0"; String lowPart = "0"; if (hexString.length() > 8) { int lowStart = hexString.length() - 8; highPart = hexString.substring(0, lowStart - 1); lowPart = hexString.substring(lowStart); } else { lowPart = hexString; } return "L_" + highPart + "~" + lowPart; }
From source file:org.eclipse.thym.hybrid.test.TestUtils.java
public static File getTempDirectory() { if (temp == null) { String tsamp = Long.toHexString(System.currentTimeMillis()); File tempDir = new File(System.getProperty("java.io.tmpdir")); temp = new File(tempDir, tsamp); temp.mkdirs();/*from w w w. j a va 2 s. c om*/ try { org.apache.commons.io.FileUtils.forceDeleteOnExit(temp); } catch (IOException e) { e.printStackTrace(); } } return temp; }
From source file:org.eclipse.ecr.runtime.util.SimpleRuntime.java
private static synchronized String generateId() { long stamp = System.currentTimeMillis(); counter++;/* w w w . j av a 2 s . co m*/ return Long.toHexString(stamp) + '-' + System.identityHashCode(System.class) + '.' + counter; }
From source file:com.navercorp.pinpoint.web.util.ThreadDumpUtils.java
public static String createDumpMessage(TThreadDump threadDump) { TThreadState threadState = getThreadState(threadDump.getThreadState()); // set threadName StringBuilder message = new StringBuilder("\"" + threadDump.getThreadName() + "\""); // set threadId String hexStringThreadId = Long.toHexString(threadDump.getThreadId()); message.append(" Id=0x" + hexStringThreadId); // set threadState message.append(" " + threadState.name()); if (!StringUtils.isBlank(threadDump.getLockName())) { message.append(" on ").append(threadDump.getLockName()); }/*ww w .j a va2s. co m*/ if (!StringUtils.isBlank(threadDump.getLockOwnerName())) { message.append(" owned by \"").append(threadDump.getLockOwnerName()).append("\" Id=") .append(threadDump.getLockOwnerId()); } if (threadDump.isSuspended()) { message.append(" (suspended)"); } if (threadDump.isInNative()) { message.append(" (in native)"); } message.append(LINE_SEPARATOR); // set StackTrace for (int i = 0; i < threadDump.getStackTraceSize(); i++) { String stackTrace = threadDump.getStackTrace().get(i); message.append(TAB_SEPARATOR + "at ").append(stackTrace); message.append(LINE_SEPARATOR); if (i == 0 && !StringUtils.isBlank(threadDump.getLockName())) { switch (threadState) { case BLOCKED: message.append(TAB_SEPARATOR + "- blocked on ").append(threadDump.getLockName()); message.append(LINE_SEPARATOR); break; case WAITING: message.append(TAB_SEPARATOR + "- waiting on ").append(threadDump.getLockName()); message.append(LINE_SEPARATOR); break; case TIMED_WAITING: message.append(TAB_SEPARATOR + "- waiting on ").append(threadDump.getLockName()); message.append(LINE_SEPARATOR); break; default: } } if (threadDump.getLockedMonitors() != null) { for (TMonitorInfo lockedMonitor : threadDump.getLockedMonitors()) { if (lockedMonitor.getStackDepth() == i) { message.append(TAB_SEPARATOR + "- locked ").append(lockedMonitor.getStackFrame()); message.append(LINE_SEPARATOR); } } } } // set Locks List<String> lockedSynchronizers = threadDump.getLockedSynchronizers(); if (!CollectionUtils.isEmpty(lockedSynchronizers)) { message.append(LINE_SEPARATOR + TAB_SEPARATOR + "Number of locked synchronizers = ") .append(lockedSynchronizers.size()); message.append(LINE_SEPARATOR); for (String lockedSynchronizer : lockedSynchronizers) { message.append(TAB_SEPARATOR + "- ").append(lockedSynchronizer); message.append(LINE_SEPARATOR); } } message.append(LINE_SEPARATOR); return message.toString(); }
From source file:ThreadUtil.java
/** * Get the next thread id to use.//from w w w. j a va 2 s . com * * @return The next thread id. */ private static synchronized String getNextId() { return "TSThread:" + Long.toHexString(++id); }
From source file:org.cruxframework.crux.core.server.rest.state.ETagHandlerImpl.java
@Override public String generateEtag(UriInfo uri, String content) { if (StringUtils.isEmpty(content)) { return null; }//from w w w. j a va 2 s .c o m return Long.toHexString(System.currentTimeMillis()) + Integer.toHexString(content.hashCode()); }
From source file:net.udidb.server.api.results.ExpressionValueSerializer.java
@Override public void serialize(ExpressionValue value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { switch (value.getType()) { case CHAR:/*from w w w . ja v a2 s. c o m*/ jgen.writeString(Character.toString(value.getCharValue())); break; case STRING: jgen.writeString(value.getStringValue()); break; case ADDRESS: jgen.writeString("0x" + Long.toHexString(value.getAddressValue())); break; case NUMBER: jgen.writeString(value.toString()); break; } }
From source file:org.jboss.pnc.causeway.test.PncImportResourceIT.java
@Test public void checkTestMethod() throws Exception { withNewHttpClient((driver, client) -> { String var = Long.toHexString(new Date().getTime()); try {/* w ww .j av a 2s .c o m*/ String url = formatUrl("/import/test", var); HttpGet request = new HttpGet(url); request.setHeader("Content-Type", "application/json"); request.setHeader("Accept", "application/json"); request.setHeader("RESTEASY_CHOSEN_ACCEPT", "*"); HttpResponse response = client.execute(request); assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); String result = IOUtils.toString(response.getEntity().getContent()).trim(); assertThat(result, equalTo(var)); } catch (Exception e) { return new HttpCommandResult(e); } return new HttpCommandResult(); }); }
From source file:org.jbpm.bpel.graph.exe.MockIntegrationService.java
private static String getIdString(Object objectWithId) { Class classWithId = objectWithId.getClass(); // get the class name excluding the package String className = ClassUtils.getShortClassName(classWithId); // obtain the identifier getter method according to jBPM conventions String idString = "0"; try {//w w w .j av a 2 s . co m Method idGetter = classWithId.getMethod("getId", null); idGetter.setAccessible(true); Long idWrapper = (Long) idGetter.invoke(objectWithId, null); long id = idWrapper.longValue(); if (id != 0L) { idString = Long.toHexString(id); } else { // object is transient, fall back to hash code idString = Integer.toHexString(objectWithId.hashCode()); } } catch (NoSuchMethodException e) { // no id getter, fall back to hash code idString = Integer.toHexString(objectWithId.hashCode()); } catch (IllegalAccessException e) { // we made the getter accessible, should not happen e.printStackTrace(); } catch (InvocationTargetException e) { // strange a getter throws a checked exception e.printStackTrace(); } return className + idString; }
From source file:com.apabi.r2k.common.security.util.NonceUtils.java
/** * SecureRandom?Long, ?16Hex?. */ public static String randomHexLong() { return Long.toHexString(randomLong()); }