List of usage examples for java.lang Long toHexString
public static String toHexString(long i)
From source file:com.teletalk.jserver.util.SpillOverByteArrayOutputStream.java
/** * Performs spill over./*from ww w. ja v a 2 s . c om*/ */ private void spillOver() { try { this.spillOverFile = File.createTempFile("SpillOver" + Long.toHexString( (long) System.identityHashCode(Thread.currentThread()) + (long) System.identityHashCode(this)), ".tmp"); this.spillOverFileOutputStream = new BufferedOutputStream(new FileOutputStream(this.spillOverFile)); if (this.byteArrayOutputStream != null) { this.byteArrayOutputStream.writeTo(this.spillOverFileOutputStream); this.byteArrayOutputStream = null; } } catch (Exception e) { this.spillOverFileOutputStream = null; this.spillOverFailed = true; Class commonsLoggingLogClass = null; try { commonsLoggingLogClass = Class.forName("org.apache.commons.logging.LogFactory"); } catch (Throwable t) { } if (commonsLoggingLogClass != null) { org.apache.commons.logging.LogFactory.getLog(this.getClass()) .error("Error (" + e + ") creating spill over file!", e); } else { System.out.println("Error (" + e + ") creating spill over file!"); e.printStackTrace(); } } }
From source file:org.apache.accumulo.master.tableOps.Utils.java
public static void unreserveNamespace(String namespaceId, long id, boolean writeLock) throws Exception { getLock(namespaceId, id, writeLock).unlock(); log.info("namespace " + namespaceId + " (" + Long.toHexString(id) + ") unlocked for " + (writeLock ? "write" : "read")); }
From source file:org.apache.isis.core.runtime.persistence.adaptermanager.PojoAdapterHashMap.java
public void add(final Object pojo, final ObjectAdapter adapter) { adapterByPojoMap.put(key(pojo), adapter); if (LOG.isDebugEnabled()) { LOG.debug("add adapter: #" + Long.toHexString(pojo.hashCode()) + " -> #" + Long.toHexString(adapter.hashCode())); }/*from w w w . jav a 2s. co m*/ // log at end so that if toString needs adapters they're in maps. if (adapter.isResolved()) { if (LOG.isDebugEnabled()) { LOG.debug("add " + new ToString(pojo) + " as " + adapter); } } }
From source file:org.sipfoundry.sipxbridge.SipXauthIdentity.java
static private String encodeIdentity(String identity, String callId, String fromTag, long timestamp) { // calculate timestamp Long seconds = timestamp / 1000; String stamp = Long.toHexString(seconds).toUpperCase(); String strSignature = stamp + SignatureFieldSeparator; // signature-hash=MD5(<timestamp><secret><from-tag><call-id><identity>) try {//from w ww . jav a2 s .c o m MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(stamp.getBytes()); digest.update(sSignatureSecretDecoded); digest.update(fromTag.getBytes()); digest.update(callId.getBytes()); digest.update(identity.getBytes()); // create md5 hash of token byte md5hash[] = digest.digest(); BigInteger number = new BigInteger(1, md5hash); strSignature += number.toString(16); } catch (Exception ex) { logger.error("Failed to generate signature", ex); } String encodedUrl = "<sip:" + identity + ";signature=" + strSignature + ">"; return encodedUrl; }
From source file:cc.arduino.contributions.GPGDetachedSignatureVerifier.java
private PGPPublicKey readPublicKey(InputStream input, String id) throws IOException, PGPException { PGPPublicKeyRingCollection pgpPub = new PGPPublicKeyRingCollection(PGPUtil.getDecoderStream(input), new BcKeyFingerprintCalculator()); Iterator<PGPPublicKeyRing> keyRingIter = pgpPub.getKeyRings(); while (keyRingIter.hasNext()) { PGPPublicKeyRing keyRing = keyRingIter.next(); Iterator<PGPPublicKey> keyIter = keyRing.getPublicKeys(); while (keyIter.hasNext()) { PGPPublicKey key = keyIter.next(); if (Long.toHexString(key.getKeyID()).toUpperCase().endsWith(id)) { return key; }/*from w w w . ja v a 2 s .c o m*/ } } throw new IllegalArgumentException("Can't find encryption key in key ring."); }
From source file:com.navercorp.pinpoint.web.util.ThreadDumpUtils.java
public static String createDumpMessage(ThreadDumpBo threadDump) { ThreadState 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()); }/*from ww w .j ava 2 s . c om*/ 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 final int stackTraceSize = threadDump.getStackTraceList().size(); for (int i = 0; i < stackTraceSize; i++) { final String stackTrace = threadDump.getStackTraceList().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 (CollectionUtils.hasLength(threadDump.getLockedMonitorInfoList())) { for (MonitorInfoBo lockedMonitor : threadDump.getLockedMonitorInfoList()) { if (lockedMonitor.getStackDepth() == i) { message.append(TAB_SEPARATOR + "- locked ").append(lockedMonitor.getStackFrame()); message.append(LINE_SEPARATOR); } } } } // set Locks List<String> lockedSynchronizerList = threadDump.getLockedSynchronizerList(); if (CollectionUtils.hasLength(lockedSynchronizerList)) { message.append(LINE_SEPARATOR + TAB_SEPARATOR + "Number of locked synchronizers = ") .append(lockedSynchronizerList.size()); message.append(LINE_SEPARATOR); for (String lockedSynchronizer : lockedSynchronizerList) { message.append(TAB_SEPARATOR + "- ").append(lockedSynchronizer); message.append(LINE_SEPARATOR); } } message.append(LINE_SEPARATOR); return message.toString(); }
From source file:alma.acs.container.archive.IdentifierJMock.java
private String createUid() { String uid = "uid://X" + StringUtils.leftPad(Long.toHexString(archiveid), archiveIdLength, '0') + "/X" + Long.toHexString(rangeid) + "/X0"; return uid;/* w w w. j a va2s. co m*/ }
From source file:com.mellanox.jxio.ServerSession.java
/** * Constructor of ServerSession. This object should be created after ServerPortal receives * callback onNewSession./*from www.ja v a 2 s.c om*/ * * @param sessionKey * - was received in ServerPortal's callback onNewSession * @param callbacks * - implementation of Interface ServerSession.Callbacks */ public ServerSession(SessionKey sessionKey, Callbacks callbacks) { if (LOG.isDebugEnabled()) { LOG.debug("SS CTOR entry"); } this.callbacks = callbacks; setId(sessionKey.getSessionPtr()); this.uri = sessionKey.getUri(); this.name = "jxio.SS[" + Long.toHexString(getId()) + "]"; this.nameForLog = this.name + ": "; if (LOG.isDebugEnabled()) { LOG.debug(this.toLogString() + "listening to " + sessionKey.getUri()); LOG.debug(this.toLogString() + "SS CTOR done"); } }
From source file:pt.ist.fenixedu.integration.task.exportData.parking.ExportCarParkUsers.java
private String toHex(final String rfid) { return invert(makeStringLeftBlock(Long.toHexString(Long.parseLong(rfid)), 8)); }
From source file:org.apache.ode.utils.fs.TempFileManager.java
public static synchronized File getTemporaryFile(String handle, File parent) { // force initialization if necessary if (__singleton == null) { getInstance();/* w ww . j av a 2s .c o m*/ } if (handle == null) { handle = "temp-"; } if (parent == null) { parent = (__workDir != null ? __workDir : __baseDir); } File tmp; try { tmp = File.createTempFile(handle + Long.toHexString(System.currentTimeMillis()), ".tmp", parent); } catch (IOException ioe) { __log.error("Unable to create temporary file in working directory " + (parent == null ? "<null>; " : (parent.getPath() + "; ")) + "falling back to current working directory.", ioe); tmp = new File(handle + new GUID().toString()); } registerTemporaryFile(tmp); return tmp; }