Example usage for java.lang Long longValue

List of usage examples for java.lang Long longValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public long longValue() 

Source Link

Document

Returns the value of this Long as a long value.

Usage

From source file:com.ntsync.android.sync.syncadapter.SyncAdapter.java

private void notifyUserConctactNotSynced(int maxCount, int totalLocalContacts, String accountName) {
    AccountManager acm = AccountManager.get(mContext);
    Account account = new Account(accountName, Constants.ACCOUNT_TYPE);
    String lastTimeShown = acm.getUserData(account, NOTIF_SHOWN_CONTACTS_SYNCED);
    Long lastTime;
    try {/*from   w ww.j a  va  2s . c o  m*/
        lastTime = lastTimeShown != null ? Long.parseLong(lastTimeShown) : null;
    } catch (NumberFormatException ex) {
        LogHelper.logWCause(TAG,
                "Invalid Config-Settings:" + NOTIF_SHOWN_CONTACTS_SYNCED + " Value:" + lastTimeShown, ex);
        lastTime = null;
    }

    if (lastTime == null || System.currentTimeMillis() > lastTime.longValue() + NOTIF_WAIT_TIME) {
        // Create Shop-Intent
        Intent shopIntent = new Intent(mContext, ShopActivity.class);
        shopIntent.putExtra(ShopActivity.PARM_ACCOUNT_NAME, account.name);
        // Adds the back stack
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(mContext);
        stackBuilder.addParentStack(ShopActivity.class);
        stackBuilder.addNextIntent(shopIntent);

        // Create Notification
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mContext)
                .setSmallIcon(Constants.NOTIF_ICON)
                .setContentTitle(String.format(getText(R.string.notif_contactnotsynced_title), maxCount,
                        totalLocalContacts))
                .setContentText(String.format(getText(R.string.notif_contactnotsynced_content), account.name))
                .setAutoCancel(true).setOnlyAlertOnce(true)
                .setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT));
        NotificationManager mNotificationManager = (NotificationManager) mContext
                .getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.notify(Constants.NOTIF_CONTACTS_NOT_SYNCED, mBuilder.build());
        acm.setUserData(account, NOTIF_SHOWN_CONTACTS_SYNCED, String.valueOf(System.currentTimeMillis()));
    }
}

From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java

public void indexList(List<Long> studyIds) {
    long ioProblemCount = 0;
    boolean ioProblem = false;
    Indexer indexer = Indexer.getInstance();
    /*// ww w . j a  v  a2s  .c  om
    try {
    indexer.setup();
    } catch (IOException ex) {
    ex.printStackTrace();
    }
     */
    for (Iterator it = studyIds.iterator(); it.hasNext();) {
        Long elem = (Long) it.next();
        try {
            addDocument(elem.longValue());
        } catch (IOException ex) {
            ioProblem = true;
            ioProblemCount++;
            Logger.getLogger(IndexServiceBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    handleIOProblems(ioProblem, ioProblemCount);
}

From source file:gov.va.oia.terminology.converters.sharedUtils.EConceptUtility.java

/**
 * Set up all the boilerplate stuff./*from  w  w w .j  ava  2s .c o  m*/
 * 
 * @param object - The object to do the setting to
 * @param statusUuid - Uuid or null (for current)
 * @param time - time or null (for default)
 */
public void setRevisionAttributes(TtkRevision object, Status status, Long time) {
    object.setAuthorUuid(authorUuid_);
    object.setModuleUuid(moduleUuid_);
    object.setPathUuid(terminologyPathUUID_);
    object.setStatus(status == null ? Status.ACTIVE : status);
    object.setTime(time == null ? defaultTime_ : time.longValue());
}

From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java

public void deleteIndexList(List<Long> studyIds) {
    Indexer indexer = Indexer.getInstance();
    /*//from w  w w .j ava2 s  . com
    try {
    indexer.setup();
    } catch (IOException ex) {
    ex.printStackTrace();
    }
     */
    for (Iterator it = studyIds.iterator(); it.hasNext();) {
        Long elem = (Long) it.next();
        try {
            deleteDocument(elem.longValue());
        } catch (EJBException e) {
            if (e.getCause() instanceof IllegalArgumentException) {
                System.out.println("Study id " + elem.longValue() + " not found");
                e.printStackTrace();
            } else {
                throw e;
            }
        }
    }
}

From source file:com.intuit.tank.vm.settings.AgentConfigCpTest.java

/**
 * Run the Long getConnectionTimeout() method test.
 * /*from   w  ww. j  a v  a  2 s  . c  om*/
 * @throws Exception
 * 
 * @generatedBy CodePro at 9/3/14 3:44 PM
 */
@Test
public void testGetConnectionTimeout_1() throws Exception {
    AgentConfig fixture = new AgentConfig(new HierarchicalConfiguration());
    fixture.setResultsTypeMap(new HashMap());

    Long result = fixture.getConnectionTimeout();

    assertNotNull(result);
    assertEquals("40000", result.toString());
    assertEquals((byte) 64, result.byteValue());
    assertEquals((short) -25536, result.shortValue());
    assertEquals(40000, result.intValue());
    assertEquals(40000L, result.longValue());
    assertEquals(40000.0f, result.floatValue(), 1.0f);
    assertEquals(40000.0, result.doubleValue(), 1.0);
}

From source file:com.nextep.designer.dbgm.services.impl.DataService.java

@Override
public void loadDataLinesFromRepository(IDataSet dataSet, IProgressMonitor m) {
    SubMonitor monitor = SubMonitor.convert(m, 100000);

    // Check if already loaded
    if (dataSet.getStorageHandle() != null || dataSet.getUID() == null) {
        return;//from  w  ww  .j  a v a  2 s . c  o m
    } else {
        storageService.createDataSetStorage(dataSet);
    }

    // Make sure that data set version is tagged
    Session session = HibernateUtil.getInstance().getSandBoxSession();
    final IVersionInfo version = VersionHelper.getVersionInfo(dataSet);
    Long versionTag = version.getVersionTag();
    long computedVersionTag = VersionHelper.computeVersion(version);
    if (versionTag == null || versionTag.longValue() != computedVersionTag) {
        version.setVersionTag(computedVersionTag);
        CorePlugin.getIdentifiableDao().save(version, true, session, true);
    }
    // Connecting explicitly to repository
    Connection repoConn = null;
    PreparedStatement stmt = null;
    ResultSet rset = null;
    // Building reference map to avoid instantiating references
    final Map<Long, IReference> colRefMap = new HashMap<Long, IReference>();
    for (IReference colRef : dataSet.getColumnsRef()) {
        colRefMap.put(colRef.getUID().rawId(), colRef);
    }
    // Building version tree id list
    List<Long> idList = buildVersionIdHistoryList(version);
    try {
        repoConn = getRepositoryConnection();
        monitor.subTask(DBGMMessages.getString("service.data.executingRepositoryQuery")); //$NON-NLS-1$
        final String selectStmt = buildSelectRepositoryValuesStmt(idList);
        stmt = repoConn.prepareStatement(selectStmt);
        // "SELECT dlc.dset_row_id, dlv.column_refid, dlv.column_value "
        // + "FROM dbgm_dset_rows dlc LEFT JOIN dbgm_dset_rows dln "
        // + "       ON dln.dset_refid = dlc.dset_refid "
        // + "      AND dln.dset_row_id = dlc.dset_row_id "
        // + "      AND dln.version_tag > dlc.version_tag "
        // + "      AND dln.version_tag <= ? "
        // + "  JOIN dbgm_dset_row_values dlv ON dlv.drow_id = dlc.drow_id "
        // + "WHERE dlc.dset_refid = ? AND dlc.version_tag <= ? "
        // + "AND dln.dset_refid IS NULL ");
        // "ORDER BY dlc.dlin_no, dlc.version_tag" );
        final long setRefId = version.getReference().getUID().rawId();
        int colIndex = 1;
        stmt.setLong(colIndex++, setRefId);
        for (Long id : idList) {
            stmt.setLong(colIndex++, id);
        }
        stmt.setLong(colIndex++, setRefId);
        // stmt.setLong(4, versionTag);
        rset = stmt.executeQuery();
        monitor.worked(1);
        IDataLine line = typedObjectFactory.create(IDataLine.class);
        long lineId;
        boolean isEmpty = true;

        // Preparing line buffer
        Collection<IDataLine> bufferedLines = new ArrayList<IDataLine>(LINE_BUFFER_SIZE);
        long counter = 0;
        while (rset.next()) {
            if (monitor.isCanceled()) {
                return;
            }
            lineId = rset.getLong(1);

            // If new row id, new line
            if (line.getRowId() != lineId && !isEmpty) {
                bufferedLines.add(line);
                if (bufferedLines.size() >= LINE_BUFFER_SIZE) {
                    counter += LINE_BUFFER_SIZE;
                    monitor.subTask(
                            MessageFormat.format(DBGMMessages.getString("service.data.loadedLines"), counter)); //$NON-NLS-1$
                    monitor.worked(LINE_BUFFER_SIZE);
                    addDataline(dataSet, bufferedLines.toArray(new IDataLine[bufferedLines.size()]));
                    bufferedLines.clear();
                }
                line = typedObjectFactory.create(IDataLine.class);
            }
            line.setRowId(lineId);
            isEmpty = false;
            final long colRefId = rset.getLong(2);
            final String strValue = rset.getString(3);
            final IReference colRef = colRefMap.get(colRefId);

            /*
             * We might have unresolved column reference when the column has been removed from
             * the dataset. In this case we simply ignore the value.
             */
            if (colRef != null) {
                final Object value = storageService.decodeValue(colRef, strValue);
                // Preparing column value
                final IColumnValue colValue = typedObjectFactory.create(IColumnValue.class);
                colValue.setDataLine(line);
                colValue.setColumnRef(colRef);
                colValue.setValue(value);
                line.addColumnValue(colValue);
            }
        }
        if (!isEmpty) {
            bufferedLines.add(line);
            addDataline(dataSet, bufferedLines.toArray(new IDataLine[bufferedLines.size()]));
        }
        monitor.done();
    } catch (SQLException e) {
        throw new ErrorException(
                DBGMMessages.getString("service.data.loadRepositoryDataSetError") + e.getMessage(), e); //$NON-NLS-1$
    } finally {
        safeClose(rset, stmt, repoConn, true);
    }
    handleDataSetStructuralChanges(dataSet);
}

From source file:fr.treeptik.cloudunit.service.impl.ModuleServiceImpl.java

/**
 * Affecte un nom disponible pour le module que l'on souhaite crer
 *
 * @param module//from w w w. j a v  a  2 s. c  o  m
 * @param applicationName
 * @param counter
 * @return module
 * @throws ServiceException
 */
private Module initNewModule(Module module, String applicationName, int counter) throws ServiceException {
    try {

        Long nbInstance = imageService.countNumberOfInstances(module.getName(), applicationName,
                module.getApplication().getUser().getLogin());

        Long counterGlobal = (nbInstance.longValue() == 0 ? 1L : (nbInstance + counter));
        try {
            String containerName = AlphaNumericsCharactersCheckUtils
                    .convertToAlphaNumerics(module.getApplication().getUser().getLogin()) + "-"
                    + AlphaNumericsCharactersCheckUtils.convertToAlphaNumerics(
                            module.getApplication().getName())
                    + "-" + module.getName() + "-" + counterGlobal;
            logger.info("containerName generated : " + containerName);
            Module moduleTemp = moduleDAO.findByName(containerName);
            if (moduleTemp == null) {
                module.setName(containerName);
            } else {
                initNewModule(module, applicationName, counter + 1);
            }
        } catch (UnsupportedEncodingException e1) {
            throw new ServiceException("Error renaming container", e1);
        }
    } catch (ServiceException e) {
        throw new ServiceException(e.getLocalizedMessage(), e);
    }
    return module;
}

From source file:com.cyberway.issue.crawler.admin.StatisticsTracker.java

/**
 * Returns the time (in millisec) when a URI belonging to a given host was
 * last finished processing. /*from   w  w w  .  ja  v  a  2s. c  o m*/
 * 
 * @param host The host to look up time of last completed URI.
 * @return Returns the time (in millisec) when a URI belonging to a given 
 * host was last finished processing. If no URI has been completed for host
 * -1 will be returned. 
 */
public long getHostLastFinished(String host) {
    Long l = null;
    synchronized (hostsLastFinished) {
        l = (Long) hostsLastFinished.get(host);
    }
    return (l != null) ? l.longValue() : -1;
}

From source file:com.frameworkset.commons.dbcp2.datasources.PerUserPoolDataSource.java

/**
 * Gets the user specific value for/*from  w  w  w  .j ava2  s  .  c o  m*/
 * {@link GenericObjectPool#getMaxWaitMillis()} for the
 * specified user's pool or the default if no user specific value is defined.
 */
public long getPerUserMaxWaitMillis(String key) {
    Long value = null;
    if (perUserMaxWaitMillis != null) {
        value = perUserMaxWaitMillis.get(key);
    }
    if (value == null) {
        return getDefaultMaxWaitMillis();
    }
    return value.longValue();
}

From source file:com.sshtools.j2ssh.connection.ConnectionProtocol.java

/**
 *
 *
 * @param channel//from  www .j  ava 2  s  . com
 * @param eventListener
 *
 * @return
 *
 * @throws IOException
 * @throws SshException
 */
public boolean openChannel(Channel channel, ChannelEventListener eventListener) throws IOException {
    //synchronized (activeChannels) {
    UnopenedChannel uoc = null;
    synchronized (unopenedChannels) {
        Long channelId = getChannelId();

        // Create the message
        SshMsgChannelOpen msg = new SshMsgChannelOpen(channel.getChannelType(), channelId.longValue(),
                channel.getLocalWindow().getWindowSpace(), channel.getLocalPacketSize(),
                channel.getChannelOpenData());

        // Send the message
        transport.sendMessage(msg, this);

        uoc = new UnopenedChannel(channelId, channel, eventListener);
        unopenedChannels.put(channelId, uoc);
    }
    try {
        boolean b = uoc.tail();
        log.info("Channel opened successfully.");
        return b;
    } catch (InterruptedException e) {
        throw new SshException("The thread was interrupted whilst waiting for a connection protocol message");
    }

    /*
    // Wait for the next message to confirm the open channel (or not)
    int[] messageIdFilter = new int[2];
    messageIdFilter[0] = SshMsgChannelOpenConfirmation.
        SSH_MSG_CHANNEL_OPEN_CONFIRMATION;
            
    messageIdFilter[1] = SshMsgChannelOpenFailure.
        SSH_MSG_CHANNEL_OPEN_FAILURE;
            
    try {
      SshMessage result = transport.getMessageStore().getMessage(messageIdFilter);
            
      if (result.getMessageId() ==
    SshMsgChannelOpenConfirmation.SSH_MSG_CHANNEL_OPEN_CONFIRMATION) {
        SshMsgChannelOpenConfirmation conf = (SshMsgChannelOpenConfirmation)
      result;
        activeChannels.put(channelId, channel);
            
        log.debug("Initiating channel");
        channel.init(this, channelId.longValue(),
               conf.getSenderChannel(), conf.getInitialWindowSize(),
               conf.getMaximumPacketSize(), eventListener);
            
        channel.open();
        log.info("Channel "
           + String.valueOf(channel.getLocalChannelId())
           + " is open [" + channel.getName() + "]");
            
        return true;
      }
      else {
        // Make sure the channels state is closed
        channel.getState().setValue(ChannelState.CHANNEL_CLOSED);
            
        return false;
      }
    }
    catch (MessageStoreEOFException mse) {
      throw new IOException(mse.getMessage());
    }
    catch (InterruptedException ex) {
      throw new SshException(
    "The thread was interrupted whilst waiting for a connection protocol message");
     }*/
    //}
}