Example usage for java.lang Integer intValue

List of usage examples for java.lang Integer intValue

Introduction

In this page you can find the example usage for java.lang Integer intValue.

Prototype

@HotSpotIntrinsicCandidate
public int intValue() 

Source Link

Document

Returns the value of this Integer as an int .

Usage

From source file:CountingMap.java

public void increment(Object key) {
    if (!backingMap.containsKey(key)) {
        backingMap.put(key, new Integer(0));
    } else {/*from   www  .  j ava  2 s  . c  om*/
        Integer i = backingMap.get(key);
        backingMap.put(key, new Integer(i.intValue() + 1));
    }
}

From source file:CountingMap.java

public void decrement(Object key) {
    if (!backingMap.containsKey(key)) {
        backingMap.put(key, new Integer(0));
    } else {/*ww  w . j a  v  a  2 s  . co  m*/
        Integer i = backingMap.get(key);
        backingMap.put(key, new Integer(i.intValue() - 1));
    }
}

From source file:ch.ralscha.extdirectspring.provider.RemoteProviderImplementation.java

@Override
public List<Row> storeRead(ExtDirectStoreReadRequest request, @RequestParam(value = "lastName") String name,
        @RequestParam(value = "theAge", defaultValue = "40") Integer age, Boolean active,
        final HttpServletRequest httpRequest) {

    assertThat(age.intValue()).isEqualTo(40);
    assertThat(httpRequest).isNotNull();
    assertThat(request).isNotNull();//from w  w  w . j  a  va 2  s. com
    assertThat(name).isEqualTo("Smith");
    assertThat(active).isTrue();

    assertThat(request.getParams()).hasSize(2);
    assertThat(request.getParams()).contains(entry("lastName", "Smith"));
    assertThat(request.getParams()).contains(entry("active", Boolean.TRUE));

    List<Row> result = new ArrayList<Row>();
    result.add(new Row(1, name, active, "" + age));
    return result;
}

From source file:MyServlet.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    HttpSession session = req.getSession();

    Integer count = (Integer) session.getAttribute("tracker.count");
    if (count == null)
        count = new Integer(1);
    else//w w w  . j  ava 2 s.c  om
        count = new Integer(count.intValue() + 1);
    session.setAttribute("tracker.count", count);

    out.println("<HTML><HEAD><TITLE>SessionTracker</TITLE></HEAD>");
    out.println("<BODY><H1>Session Tracking Demo</H1>");

    out.println("You've visited this page " + count + ((count.intValue() == 1) ? " time." : " times."));

    out.println("<P>");

    out.println("<H2>Here is your session data:</H2>");
    Enumeration e = session.getAttributeNames();
    while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        out.println(name + ": " + session.getAttribute(name) + "<BR>");
    }
    out.println("</BODY></HTML>");
}

From source file:SessionTracker.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();

    HttpSession session = req.getSession(true);

    Integer count = (Integer) session.getAttribute("count");

    if (count == null) {
        count = new Integer(1);
    } else {/* ww  w. j  av  a  2  s .c  o  m*/
        count = new Integer(count.intValue() + 1);
    }

    session.setAttribute("count", count);
    out.println("<html><head><title>SessionSnoop</title></head>");
    out.println("<body><h1>Session Details</h1>");
    out.println(
            "You've visited this page " + count + ((count.intValue() == 1) ? " time." : " times.") + "<br/>");
    out.println("<h3>Details of this session:</h3>");
    out.println("Session id: " + session.getId() + "<br/>");
    out.println("New session: " + session.isNew() + "<br/>");
    out.println("Timeout: " + session.getMaxInactiveInterval() + "<br/>");
    out.println("Creation time: " + new Date(session.getCreationTime()) + "<br/>");
    out.println("Last access time: " + new Date(session.getLastAccessedTime()) + "<br/>");
    out.println("</body></html>");
}

From source file:com.aurel.track.fieldType.runtime.matchers.converter.StringMatcherConverter.java

/**
 * Convert the xml string to object value after load
 * @param value//from w  w  w  . j a va  2 s  . c  o  m
 * @param matcherRelation
 * @return
 */
@Override
public Object fromXMLString(String value, Integer matcherRelation) {
    if (matcherRelation != null) {
        switch (matcherRelation.intValue()) {
        case MatchRelations.EQUAL:
        case MatchRelations.NOT_EQUAL:
        case MatchRelations.EQUAL_IGNORE_CASE:
        case MatchRelations.PERL_PATTERN:
        case MatchRelations.LIKE:
        case MatchRelations.NOT_LIKE:
            if (value != null) {
                return StringEscapeUtils.unescapeXml(value);
            }
        }
    }
    return null;
}

From source file:it.govpay.web.handler.MessageLoggingHandlerUtils.java

public static boolean logToSystemOut(UriInfo uriInfo, HttpHeaders rsHttpHeaders, HttpServletRequest request,
        byte[] bytes, String nomeOperazione, String nomeServizio, String tipoServizio, int versioneServizio,
        Logger log, boolean outbound, Integer responseCode) {

    GpContext ctx = null;//from   w ww.  ja v a  2  s  .c  o m
    Message msg = new Message();

    try {
        msg.setContent(bytes);
    } catch (Exception e) {
        log.error("Exception in handler: " + e);
    }

    Map<String, List<String>> httpHeaders = null;

    if (outbound) {
        ctx = GpThreadLocal.get();
        //httpHeaders = (Map<String, List<String>>) smc.get(MessageContext.HTTP_RESPONSE_HEADERS);
        msg.setType(MessageType.RESPONSE_OUT);
        if (rsHttpHeaders.getMediaType() != null)
            msg.setContentType(
                    rsHttpHeaders.getMediaType().getType() + "/" + rsHttpHeaders.getMediaType().getSubtype());
        ctx.getContext().getResponse().setOutDate(new Date());
        ctx.getContext().getResponse().setOutSize(Long.valueOf(bytes.length));
        if (responseCode != null)
            ctx.getTransaction().getServer().setTransportCode(responseCode.intValue() + "");
    } else {
        try {
            ctx = new GpContext(uriInfo, rsHttpHeaders, request, nomeOperazione, nomeServizio, tipoServizio,
                    versioneServizio);
            ThreadContext.put("op", ctx.getTransactionId());
            GpThreadLocal.set(ctx);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return false;
        }
        httpHeaders = rsHttpHeaders.getRequestHeaders();
        msg.setType(MessageType.REQUEST_IN);
        if (rsHttpHeaders.getMediaType() != null)
            msg.setContentType(
                    rsHttpHeaders.getMediaType().getType() + "/" + rsHttpHeaders.getMediaType().getSubtype());
        ctx.getContext().getRequest().setInDate(new Date());
        ctx.getContext().getRequest().setInSize(Long.valueOf(bytes.length));
    }

    if (httpHeaders != null) {
        for (String key : httpHeaders.keySet()) {
            if (httpHeaders.get(key) != null) {
                if (key == null)
                    msg.addHeader(new Property("Status-line", httpHeaders.get(key).get(0)));
                else if (httpHeaders.get(key).size() == 1)
                    msg.addHeader(new Property(key, httpHeaders.get(key).get(0)));
                else
                    msg.addHeader(new Property(key, ArrayUtils.toString(httpHeaders.get(key))));
            }
        }
    }

    ctx.log(msg);

    return true;
}

From source file:com.salesmanager.central.payment.PaymentMethodListAction.java

public String displayPaymentModules() throws Exception {

    try {/* ww  w .  j a v  a  2 s  .c  o m*/

        super.setPageTitle("label.payment.methods.title");

        Context ctx = (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context);
        Integer merchantid = ctx.getMerchantid();

        ConfigurationRequest requestvo = new ConfigurationRequest(merchantid.intValue(), true, "MD_PAY_");
        MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);
        ConfigurationResponse responsevo = mservice.getConfiguration(requestvo);
        List config = responsevo.getMerchantConfigurationList();

        Map modules = new HashMap();

        if (config != null) {

            Iterator it = config.iterator();
            while (it.hasNext()) {

                MerchantConfiguration c = (MerchantConfiguration) it.next();
                String key = c.getConfigurationKey();

                if (key.equals(PaymentConstants.MODULE_PAYMENT_INDICATOR_NAME)) {
                    if (!StringUtils.isBlank(c.getConfigurationValue1())) {
                        modules.put(c.getConfigurationValue1(), c);
                    }
                }

            }

        }

        super.getServletRequest().setAttribute("paymentmethods", modules);

    } catch (Exception e) {
        log.error(e);
        super.setTechnicalMessage();
    }

    return SUCCESS;
}

From source file:br.com.avilardo.spring.sample.controller.ChannelRestController.java

@ApiOperation(value = "delete a channel by id", notes = "Remove a specific channel from cache")
@RequestMapping(value = { "/{id}" }, method = RequestMethod.DELETE)
@ResponseBody/* w ww .  ja  va 2 s  .c om*/
@ResponseStatus(HttpStatus.OK)
public void deleteChannel(@ApiParam(value = "The id of the channel to return") @PathVariable("id") Integer id) {
    ChannelRestController.getChannelList().remove(id.intValue());
}

From source file:com.stackify.metric.impl.MetricMonitorServiceTest.java

/**
 * testGetMonitorId//w  ww  .j  av  a2s .  c  om
 * @throws Exception 
 */
@Test
public void testGetMonitorId() throws Exception {
    ApiConfiguration apiConfig = Mockito.mock(ApiConfiguration.class);
    ObjectMapper objectMapper = new ObjectMapper();
    AppIdentityService appIdentityService = Mockito.mock(AppIdentityService.class);
    Mockito.when(appIdentityService.getAppIdentity()).thenReturn(Mockito.mock(AppIdentity.class));

    HttpClient httpClient = PowerMockito.mock(HttpClient.class);
    PowerMockito.whenNew(HttpClient.class).withAnyArguments().thenReturn(httpClient);
    PowerMockito.when(httpClient.post(Mockito.anyString(), (byte[]) Mockito.any()))
            .thenReturn("{\"MonitorID\": \"14\"}").thenReturn("");

    MetricMonitorService service = new MetricMonitorService(apiConfig, objectMapper, appIdentityService);

    MetricIdentity identity = new MetricIdentity("category", "name", MetricMonitorType.COUNTER);

    Integer id = service.getMonitorId(identity);

    Assert.assertNotNull(id);
    Assert.assertEquals(14, id.intValue());

    Integer cachedId = service.getMonitorId(identity);

    Assert.assertNotNull(cachedId);
    Assert.assertEquals(14, cachedId.intValue());

    Integer absentId = service.getMonitorId(new MetricIdentity("does-not", "exist", MetricMonitorType.COUNTER));

    Assert.assertNull(absentId);
}