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:AutoServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, java.io.IOException {

    //client browser will request the page every 60 seconds
    HttpSession session = request.getSession();
    Long times = (Long) session.getAttribute("times");
    if (times == null)
        session.setAttribute("times", new Long(0));
    long temp = 1;
    if (times != null)
        temp = (times.longValue()) + 1;

    if (temp < 5)
        response.addHeader("Refresh", "15");

    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    out.println("<html><head><title>Client Refresh</title></head><body>");

    //More HTML or dynamic content
    out.println("You've viewed this page " + temp + " times.");
    session.setAttribute("times", new Long(temp));
    out.println("</body></html>");

}

From source file:com.redhat.rhn.domain.kickstart.KickstartFactory.java

/**
 * Lookup a KickstartSession for a the passed in Server.  This method
 * finds the *most recent* KickstartSession associated with this Server.
 *
 * We use the serverId instead of the Hibernate object because this method gets
 * called by our ACL layer./*from w w w  .  jav a 2s  .  co m*/
 *
 * @param sidIn id of the Server that you want to lookup the most
 * recent KickstartSession for
 * @return KickstartSession if found.
 */
public static KickstartSession lookupKickstartSessionByServer(Long sidIn) {
    Session session = null;
    session = HibernateFactory.getSession();
    List ksessions = session.getNamedQuery("KickstartSession.findByServer").setLong("server", sidIn.longValue())
            .list();
    if (ksessions.size() > 0) {
        return (KickstartSession) ksessions.iterator().next();
    }
    return null;
}

From source file:net.sf.sze.service.impl.zeugnis.BewertungErfassungsServiceImpl.java

/**
 * {@inheritDoc}/*  w ww . j a v a 2 s .c  o  m*/
 */
@Override
public BewertungWithNeigbors getBewertungWithNeighbors(ZeugnisFormular formular, Long schulfachId,
        Long bewertungsId) {
    final List<Bewertung> bewertungen = getSortedBewertungen(formular, schulfachId.longValue());
    return new BewertungWithNeigbors(bewertungen, bewertungsId);
}

From source file:com.amalto.core.save.generator.HazelcastAutoIncrementGenerator.java

@Override
public String generateId(String dataClusterName, String conceptName, String keyElementName) {
    long nextId = 0;
    String key = dataClusterName + "."
            + AutoIncrementGenerator.getConceptForAutoIncrement(dataClusterName, conceptName) + "."
            + keyElementName;//  w w  w  .j a  v a 2 s .  c om
    CONFIGURATION.lock(key);
    try {
        Long value = CONFIGURATION.get(key);
        if (value != null) {
            nextId = value.longValue();
        }
        nextId++;
        if (!DataRecord.ValidateRecord.get()) {// don't actually save if for Record Validation
            CONFIGURATION.put(key, nextId);
            NEED_TO_SAVE.set(1);
        }
    } finally {
        CONFIGURATION.unlock(key);
    }
    return String.valueOf(nextId);
}

From source file:edu.stanford.mobisocial.dungbeetle.DBIdentityProvider.java

public List<RSAPublicKey> publicKeysForContactIds(List<Long> ids) {
    ArrayList<RSAPublicKey> result = new ArrayList<RSAPublicKey>(ids.size());
    SQLiteStatement s = mHelper.getReadableDatabase().compileStatement(
            "SELECT " + Contact.PUBLIC_KEY + " FROM " + Contact.TABLE + " WHERE " + Contact._ID + " = ?");
    for (Long id : ids) {
        s.bindLong(1, id.longValue());
        try {/*from   w ww . j a v a  2 s . c o  m*/
            String pks = s.simpleQueryForString();
            result.add(RSACrypto.publicKeyFromString(pks));
        } catch (SQLiteDoneException e) {
            Log.e(TAG, "Data consisteny error: unknown contact id " + id);
        }
    }
    s.close();
    return result;
}

From source file:org.horizontaldb.integration.DatabaseIntegrationTest.java

@Test
public void shouldSucceedAuthenticatedServiceCall() {
    ShardContext context = new ShardContext(TestUser.JOE.name());

    try {/*from  w  w w .  j  a  v  a  2 s.c  o  m*/
        testService.authenticate(testUserHelper.getJoeToken());

        Long actualCount = testService.getCountOfDepartments(context);

        assertEquals(0, actualCount.longValue());
    } finally {
        testService.logoff(testUserHelper.getJoeToken());
    }
}

From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java

@Override
public void putValueLong(String valueName, Long value) {
    try {/*from ww w  .jav  a 2 s.c o m*/
        mJSONObject.put(valueName, value.longValue());
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
    }
}

From source file:com.github.rvesse.github.pr.stats.collectors.LongStatsCollector.java

@Override
public void collect(GitHubClient client, Long item) {
    if (item == null)
        throw new IllegalArgumentException("item cannot be null");
    this.items.add(item);

    this.freq.incrementValue(item.longValue(), 1);
    this.stats.addValue(item.doubleValue());
}

From source file:com.kulik.android.jaxb.library.composer.providers.jsonProvider.JSONObjectProvider.java

@Override
public void putAttributeLong(String annotationName, Long value) {
    try {/*  ww w . j a  v  a 2  s.c om*/
        mJSONObject.put(annotationName, value.longValue());
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
    }
}

From source file:com.scvngr.levelup.core.model.util.JsonUtilsTest.java

/**
 * Tests {@link JsonUtils#optLongNullable}.
 *//*from   w w  w .j av a 2  s.  c  o m*/
@SmallTest
public void testOptLongNullable() throws JSONException {
    final JSONObject object = new JSONObject();
    object.put("test_literal", 1L);
    object.put("test_object", Long.valueOf(1L));
    object.put("test_null", null);

    final Long literal = JsonUtils.optLongNullable(object, "test_literal");
    assertNotNull(literal);
    assertEquals(1L, literal.longValue());

    assertEquals(Long.valueOf(1L), JsonUtils.optLongNullable(object, "test_object"));
    assertNull(JsonUtils.optLongNullable(object, "test_null"));
    assertNull(JsonUtils.optLongNullable(object, "test_key_not_found"));
}