Example usage for java.lang Long toHexString

List of usage examples for java.lang Long toHexString

Introduction

In this page you can find the example usage for java.lang Long toHexString.

Prototype

public static String toHexString(long i) 

Source Link

Document

Returns a string representation of the long argument as an unsigned integer in base 16.

Usage

From source file:MimeUtil.java

/**
 * Creates a new unique message identifier that can be used in message
 * header field such as Message-ID or In-Reply-To. If the given host name is
 * not <code>null</code> it will be used as suffix for the message ID
 * (following an at sign)./*from ww w  . j av  a 2  s.com*/
 * 
 * The resulting string is enclosed in angle brackets (&lt; and &gt;);
 * 
 * @param hostName host name to be included in the message ID or
 *            <code>null</code> if no host name should be included.
 * @return a new unique message identifier.
 */
public static String createUniqueMessageId(String hostName) {
    StringBuilder sb = new StringBuilder("<Mime4j.");
    sb.append(Integer.toHexString(nextCounterValue()));
    sb.append('.');
    sb.append(Long.toHexString(random.nextLong()));
    sb.append('.');
    sb.append(Long.toHexString(System.currentTimeMillis()));
    if (hostName != null) {
        sb.append('@');
        sb.append(hostName);
    }
    sb.append('>');
    return sb.toString();
}

From source file:com.mellanox.jxio.EventQueueHandler.java

void removeEventable(Eventable eventable) {
    if (LOG.isDebugEnabled()) {
        LOG.debug(this.toLogString() + "removing " + Long.toHexString(eventable.getId()) + " from map");
    }//from  ww w  . ja v a 2  s.c  om
    synchronized (eventables) {
        eventables.remove(eventable.getId());
    }
}

From source file:com.marklogic.contentpump.RDFReader.java

protected void initParser(String fsname, long size) throws IOException {
    start = 0;/*from   w w w.  j a va 2s. c o m*/
    pos = 0;
    end = 1;

    jenaStreamingParser = null;
    dataset = null;
    statementIter = null;
    graphNameIter = null;

    String ext = null;
    if (fsname.contains(".")) {
        int pos = fsname.lastIndexOf(".");
        ext = fsname.substring(pos);
        if (".gz".equals(ext)) {
            fsname = fsname.substring(0, pos);
            pos = fsname.lastIndexOf(".");
            if (pos >= 0) {
                ext = fsname.substring(pos);
            } else {
                ext = null;
            }
        }
    }
    origFn = fsname;
    inputFn = Long.toHexString(fuse(scramble(random.nextLong()), fuse(scramble(milliSecs), random.nextLong())));
    idGen = new IdGenerator(inputFn + "-" + splitStart);
    lang = null;
    if (".rdf".equals(ext)) {
        lang = Lang.RDFXML;
    } else if (".ttl".equals(ext)) {
        lang = Lang.TURTLE;
    } else if (".json".equals(ext)) {
        lang = Lang.RDFJSON;
    } else if (".n3".equals(ext)) {
        lang = Lang.N3;
    } else if (".nt".equals(ext)) {
        lang = Lang.NTRIPLES;
    } else if (".nq".equals(ext)) {
        lang = Lang.NQUADS;
    } else if (".trig".equals(ext)) {
        lang = Lang.TRIG;
    } else {
        lang = Lang.RDFXML; // We have to default to something!
    }
    synchronized (jenaLock) {
        if (size < INMEMORYTHRESHOLD) {
            dataset = DatasetFactory.createMem();
        }
    }
}

From source file:org.apache.james.mime4j.util.MimeUtil.java

/**
 * Creates a new unique message identifier that can be used in message
 * header field such as Message-ID or In-Reply-To. If the given host name is
 * not <code>null</code> it will be used as suffix for the message ID
 * (following an at sign)./*  www  .jav  a2  s .c o  m*/
 * 
 * The resulting string is enclosed in angle brackets (&lt; and &gt;);
 * 
 * @param hostName host name to be included in the message ID or
 *            <code>null</code> if no host name should be included.
 * @return a new unique message identifier.
 */
public static String createUniqueMessageId(String hostName) {
    StringBuffer sb = new StringBuffer("<Mime4j.");
    sb.append(Integer.toHexString(nextCounterValue()));
    sb.append('.');
    sb.append(Long.toHexString(random.nextLong()));
    sb.append('.');
    sb.append(Long.toHexString(System.currentTimeMillis()));
    if (hostName != null) {
        sb.append('@');
        sb.append(hostName);
    }
    sb.append('>');
    return sb.toString();
}

From source file:de.burlov.amazon.s3.dirsync.DirSync.java

private void saveFolder(Folder folder) throws DirSyncException {
    try {// ww  w  .ja va2 s .  c  o m
        /*
         * Neuen Folder-Objekt konstruieren und speichern
         */
        Folder newFolder = new Folder(folder.getName(), Long.toHexString(mainIndex.getNextId()));
        newFolder.setLastModified(System.currentTimeMillis());
        newFolder.setIndexData(folder.getIndexData());
        uploadObject(SYS_DATA_PREFIX + "/" + newFolder.getStorageId(), getDataEncryptionKey(), newFolder);

        /*
         * Main Index mit neuem Folder sichern
         */
        mainIndex.getFolders().put(newFolder.getName(), newFolder.getStorageId());
        saveMainIndex();
        folderCache.put(newFolder.getName(), newFolder);

        /*
         * Alten Folder-Objekt loeschen
         */
        s3Service.deleteObject(bucket, getFolderKey(folder.getStorageId()));

    } catch (Exception e) {
        throw new DirSyncException("Save folder description failed", e);
    }
}

From source file:edu.rit.flick.genetics.FastFileDeflator.java

protected void processTail() throws IOException {
    int tailCounter = 0;
    while (compressionCounter-- != 0) {
        final char nucleotide = (char) hyperCompressionBytes[tailCounter];
        tailfile.write(nucleotide);/*from   w w  w .j  a  v a  2s  .  c  o  m*/
        if (nucleotide != N && writingToNFile) {
            final String nPositionStr = Long.toHexString(dnaPosition.longValue()).toUpperCase() + PIPE;
            nfile.write(nPositionStr.getBytes());
            writingToNFile = false;
        }
        dnaPosition.increment();
        tailCounter++;
    }

    if (writingToNFile) {
        final String nPositionStr = Long.toHexString(dnaPosition.longValue()).toUpperCase() + PIPE;
        nfile.write(nPositionStr.getBytes());
        writingToNFile = false;
    }
}

From source file:com.sastix.cms.server.services.content.impl.HashedDirectoryServiceImpl.java

/**
 * Returns the crc32 hash for the input String.
 *
 * @param text a String with the text/*from   www . j a  va  2  s.co  m*/
 * @return a BigInteger with the hash
 */
@Override
public String hashText(final String text) {
    final CRC32 crc32 = new CRC32();
    crc32.reset();
    crc32.update(text.getBytes());
    return Long.toHexString(crc32.getValue());
}

From source file:com.enonic.cms.business.portal.instruction.PostProcessInstructionExecutorImpl.java

private void addTimeStampParameter(Long timeStamp, SitePath sitePath) {
    sitePath.addParam(UrlPathEncoder.encode(TIMESTAMP_PARAM_NAME),
            UrlPathEncoder.encode(Long.toHexString(timeStamp)));
}

From source file:org.xwiki.portlet.DispatchPortlet.java

/**
 * Stores the response data on the session.
 * //from ww w .  j  a  va2 s .  c  o m
 * @param session the session
 * @param responseData the response data
 * @return the key that can be used to retrieve the response data from the session
 */
@SuppressWarnings("unchecked")
private String storeResponseData(PortletSession session, ResponseData responseData) {
    String responseKey = Long.toHexString(Double.doubleToLongBits(Math.random()));
    Map<String, ResponseData> responseDataMap = (Map<String, ResponseData>) session
            .getAttribute(ATTRIBUTE_RESPONSE_DATA_MAP);
    if (responseDataMap == null) {
        responseDataMap = new HashMap<String, ResponseData>();
        session.setAttribute(ATTRIBUTE_RESPONSE_DATA_MAP, responseDataMap);
    }
    responseDataMap.put(responseKey, responseData);
    return responseKey;
}

From source file:com.microsoft.tfs.core.clients.versioncontrol.Workstation.java

/**
 * Handles a notification received by the {@link #notificationManager}.
 *
 * @param notification//from   w  w w  .  j  a  v  a  2s  .com
 *        the notification (must not be <code>null</code>)
 * @param param1
 *        the first parameter
 * @param param2
 *        the second paramter
 */
private void handleNotification(final Notification notification, final long param1, final long param2) {
    Check.notNull(notification, "notification"); //$NON-NLS-1$

    // This handler is only interested in version control cross-process
    // notifications.
    if (notification.getValue() <= Notification.VERSION_CONTROL_NOTIFICATION_BEGIN.getValue()
            || notification.getValue() >= Notification.VERSION_CONTROL_NOTIFICATION_END.getValue()) {
        return;
    }

    log.trace(MessageFormat.format("Received notification {0} ({1}, {2})", //$NON-NLS-1$
            notification, Long.toHexString(param1), Long.toHexString(param2)));

    if (Notification.VERSION_CONTROL_WORKSPACE_CREATED == notification
            || Notification.VERSION_CONTROL_WORKSPACE_CHANGED == notification) {
        // Force a reload of the cache file before raising the notification.
        reloadCache();
    }

    /*
     * Fire the correct events on the correct clients. The two-layered
     * conditionals aren't very pretty, but it keeps all the message
     * cracking from escaping further into VersionControlClient or
     * EventEngine.
     */

    if (notification == Notification.VERSION_CONTROL_WORKSPACE_CREATED
            || notification == Notification.VERSION_CONTROL_WORKSPACE_DELETED
            || notification == Notification.VERSION_CONTROL_WORKSPACE_CHANGED
            || notification == Notification.VERSION_CONTROL_PENDING_CHANGES_CHANGED
            || notification == Notification.VERSION_CONTROL_GET_COMPLETED
            || notification == Notification.VERSION_CONTROL_LOCAL_WORKSPACE_SCAN) {
        /*
         * Match these kinds of events by collection and workspace. We only
         * ever expect 32-bit int range data in these fields, so cast to
         * int.
         */
        final int collectionHashCode = (int) param1;
        final int workspaceHashCode = (int) param2;

        for (final WorkspaceInfo wsInfo : getAllLocalWorkspaceInfo()) {
            if (matchesNotification(wsInfo, collectionHashCode, workspaceHashCode)) {
                for (final VersionControlClient client : workstationEventListeners) {
                    if (client.getServerGUID().equals(wsInfo.getServerGUID())) {
                        final WorkspaceEvent event = new WorkspaceEvent(EventSource.newFromHere(),
                                client.getWorkspace(wsInfo), WorkspaceEventSource.EXTERNAL);

                        if (notification == Notification.VERSION_CONTROL_WORKSPACE_CREATED) {
                            client.getEventEngine().fireWorkspaceCreated(event);
                        } else if (notification == Notification.VERSION_CONTROL_WORKSPACE_DELETED) {
                            client.getEventEngine().fireWorkspaceDeleted(event);
                        } else if (notification == Notification.VERSION_CONTROL_WORKSPACE_CHANGED) {
                            // We can't tell the original name or location
                            // from the notification
                            client.getEventEngine()
                                    .fireWorkspaceUpdated(new WorkspaceUpdatedEvent(event.getEventSource(),
                                            event.getWorkspace(), null, null, event.getWorkspaceSource()));
                        } else if (notification == Notification.VERSION_CONTROL_PENDING_CHANGES_CHANGED) {
                            client.getEventEngine().firePendingChangesChangedEvent(event);
                        } else if (notification == Notification.VERSION_CONTROL_GET_COMPLETED) {
                            client.getEventEngine().fireGetCompletedEvent(event);
                        } else if (notification == Notification.VERSION_CONTROL_LOCAL_WORKSPACE_SCAN) {
                            client.getEventEngine().fireLocalWorkspaceScanEvent(event);
                        }
                    }
                }
            }
        }
    } else if (notification == Notification.VERSION_CONTROL_CHANGESET_RECONCILED
            || notification == Notification.VERSION_CONTROL_FOLDER_CONTENT_CHANGED) {
        /*
         * Match these kinds of events by collection only. We only ever
         * expect 32-bit int range data in these fields, so cast to int.
         */
        final int collectionHashCode = (int) param1;
        final int changesetID = (int) param2;

        for (final VersionControlClient client : workstationEventListeners) {
            if (matchesNotification(client, collectionHashCode)) {
                if (notification == Notification.VERSION_CONTROL_CHANGESET_RECONCILED) {
                    client.getEventEngine().fireChangesetReconciledEvent(
                            new ChangesetReconciledEvent(EventSource.newFromHere(), changesetID));
                } else if (notification == Notification.VERSION_CONTROL_FOLDER_CONTENT_CHANGED) {
                    client.getEventEngine().fireFolderContentChangedEvent(
                            new FolderContentChangedEvent(EventSource.newFromHere(), client, changesetID));
                }
            }
        }
    }

    if (Notification.VERSION_CONTROL_WORKSPACE_DELETED == notification) {
        // Force a reload of the cache file after raising the notification.
        reloadCache();
    }

}