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:gov.nih.nci.ncicb.cadsr.common.persistence.dao.jdbc.JDBCUserManagerDAO.java

public boolean userInGroup(String username, String groupName) {
    UserGroupQuery query = new UserGroupQuery(getDataSource());
    String[] params = new String[2];
    params[0] = username;/* w w  w .j  av  a  2s  .co  m*/
    params[1] = groupName;

    Integer result = (Integer) query.findObject(params);

    if (result.intValue() < 1) {
        return false;
    } else {
        return true;
    }
}

From source file:com.fengduo.bee.commons.component.ComponentMappingExceptionResolver.java

/**
 * Actually resolve the given exception that got thrown during on handler execution, returning a ModelAndView that
 * represents a specific error page if appropriate.
 * <p>/*  w w  w  .j a  v a 2  s. c  o  m*/
 * May be overridden in subclasses, in order to apply specific exception checks. Note that this template method will
 * be invoked <i>after</i> checking whether this resolved applies ("mappedHandlers" etc), so an implementation may
 * simply proceed with its actual exception handling.
 * 
 * @param request current HTTP request
 * @param response current HTTP response
 * @param handler the executed handler, or <code>null</code> if none chosen at the time of the exception (for
 * example, if multipart resolution failed)
 * @param ex the exception that got thrown during handler execution
 * @return a corresponding ModelAndView to forward to, or <code>null</code> for default processing
 */
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
        Object handler, Exception ex) {

    // Log exception, both at debug log level and at warn level, if desired.
    if (logger.isDebugEnabled()) {
        logger.debug("Resolving exception from handler [" + handler + "]: " + ex);
    }
    logException(ex, request);

    // Expose ModelAndView for chosen error view.
    String viewName = determineViewName(ex, request);
    if (viewName != null) {
        // Apply HTTP status code for error views, if specified.
        // Only apply it if we're processing a top-level request.
        Integer statusCode = determineStatusCode(request, viewName);
        if (statusCode != null) {
            applyStatusCodeIfPossible(request, response, statusCode.intValue());
        }
        viewName = buildName(viewName, handler);
        return getModelAndView(viewName, ex, request);
    } else {
        return null;
    }
}

From source file:com.joliciel.talismane.filters.SentenceImpl.java

@Override
public int getColumnNumber(int originalIndex) {
    Integer lastLineObj = this.newlines.floorKey(originalIndex);
    if (lastLineObj != null)
        return (originalIndex - lastLineObj.intValue()) + 1;
    return -1;/*from   www  .  jav  a 2s  . co  m*/
}

From source file:de.hybris.platform.acceleratorservices.cronjob.SiteMapMediaJob.java

protected List<List> splitUpTheListIfExceededLimit(final List models, final Integer maxSiteMapUrlLimit) {
    final int limit = maxSiteMapUrlLimit.intValue();
    final int modelListSize = models.size() / limit;
    final List<List> modelsList = new ArrayList<>(modelListSize);
    for (int i = 0; i <= modelListSize; i++) {
        final int subListToLimit = (i == modelListSize) ? ((i * limit) + (models.size() - (i * limit)))
                : ((i + 1) * limit);//from w w  w .jav  a2s . com
        Collections.addAll(modelsList, models.subList((i * limit), subListToLimit));
    }
    return modelsList;
}

From source file:com.jiangnan.es.authorization.resource.service.impl.ResourceServiceImpl.java

/**
 * ??//w w w. j  av a2  s . c om
 * @param resources
 * @param parentId
 * @return
 */
private Resource getParent(List<Resource> resources, Integer parentId) {
    for (Resource resource : resources) {
        if (null == parentId) {
            return null;
        } else if (resource.getId().intValue() == parentId.intValue()) {
            return resource;
        }
    }
    return null;
}

From source file:SessionSnoop.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("count");
    if (count == null)
        count = new Integer(1);
    else/*from   w w w  .j a  v a 2  s .  co  m*/
        count = new Integer(count.intValue() + 1);
    session.setAttribute("count", count);

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

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

    out.println("<P>");

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

    out.println("<H3>Here are some vital stats on your session:</H3>");
    out.println("Session id: " + session.getId() + " <I>(keep it secret)</I><BR>");
    out.println("New session: " + session.isNew() + "<BR>");
    out.println("Timeout: " + session.getMaxInactiveInterval());
    out.println("<I>(" + session.getMaxInactiveInterval() / 60 + " minutes)</I><BR>");
    out.println("Creation time: " + session.getCreationTime());
    out.println("<I>(" + new Date(session.getCreationTime()) + ")</I><BR>");
    out.println("Last access time: " + session.getLastAccessedTime());
    out.println("<I>(" + new Date(session.getLastAccessedTime()) + ")</I><BR>");

    out.println("Requested session ID from cookie: " + req.isRequestedSessionIdFromCookie() + "<BR>");
    out.println("Requested session ID from URL: " + req.isRequestedSessionIdFromURL() + "<BR>");
    out.println("Requested session ID valid: " + req.isRequestedSessionIdValid() + "<BR>");

    out.println("<H3>Test URL Rewriting</H3>");
    out.println("Click <A HREF=\"" + res.encodeURL(req.getRequestURI()) + "\">here</A>");
    out.println("to test that session tracking works via URL");
    out.println("rewriting even when cookies aren't supported.");

    out.println("</BODY></HTML>");
}

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("snoop.count");
    if (count == null)
        count = new Integer(1);
    else//from w w w .  j  a v  a2 s  . co  m
        count = new Integer(count.intValue() + 1);
    session.setAttribute("snoop.count", count);

    out.println("<HTML><HEAD><TITLE>SessionSnoop</TITLE></HEAD>");
    out.println("<BODY><H1>Session Snoop</H1>");

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

    out.println("<P>");

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

    out.println("<H3>Here are some vital stats on your session:</H3>");
    out.println("Session id: " + session.getId() + " <I>(keep it secret)</I><BR>");
    out.println("New session: " + session.isNew() + "<BR>");
    out.println("Timeout: " + session.getMaxInactiveInterval());
    out.println("<I>(" + session.getMaxInactiveInterval() / 60 + " minutes)</I><BR>");
    out.println("Creation time: " + session.getCreationTime());
    out.println("<I>(" + new Date(session.getCreationTime()) + ")</I><BR>");
    out.println("Last access time: " + session.getLastAccessedTime());
    out.println("<I>(" + new Date(session.getLastAccessedTime()) + ")</I><BR>");

    out.println("Requested session ID from cookie: " + req.isRequestedSessionIdFromCookie() + "<BR>");
    out.println("Requested session ID from URL: " + req.isRequestedSessionIdFromURL() + "<BR>");
    out.println("Requested session ID valid: " + req.isRequestedSessionIdValid() + "<BR>");

    out.println("<H3>Test URL Rewriting</H3>");
    out.println("Click <A HREF=\"" + res.encodeURL(req.getRequestURI()) + "\">here</A>");
    out.println("to test that session tracking works via URL");
    out.println("rewriting even when cookies aren't supported.");

    out.println("</BODY></HTML>");
}

From source file:com.aurel.track.dbase.InitReportTemplateBL.java

private static void addReportTemplateToDatabase(Integer oid, String name, String expfmt, String description) {

    String stmt = "INSERT INTO TEXPORTTEMPLATE (OBJECTID,NAME,EXPORTFORMAT,REPOSITORYTYPE,DESCRIPTION,PROJECT,PERSON,REPORTTYPE)"
            + "VALUES (" + oid + ",'" + name + "','" + expfmt + "',2,'" + description
            + "',NULL,1,'Jasper Report')";

    Connection coni = null;/*ww  w  . ja v a 2  s.c  o m*/
    Connection cono = null;
    ResultSet rs = null;
    try {
        coni = InitDatabase.getConnection();
        cono = InitDatabase.getConnection();
        PreparedStatement istmt = coni
                .prepareStatement("SELECT MAX(OBJECTID) FROM TEXPORTTEMPLATE WHERE OBJECTID < 100");
        Statement ostmt = cono.createStatement();

        rs = istmt.executeQuery();
        Integer maxInt = 0;
        if (rs != null) {
            rs.next();
            maxInt = rs.getInt(1);
        }
        if (oid.intValue() <= maxInt.intValue()) {
            return;
        }

        istmt = coni.prepareStatement("SELECT * FROM TEXPORTTEMPLATE WHERE OBJECTID = ?");
        istmt.setInt(1, oid);

        rs = istmt.executeQuery();
        if (rs == null || !rs.next()) {
            LOGGER.info("Adding report template with OID " + oid + ": " + name);
            try {
                ostmt.executeUpdate(stmt);
            } catch (Exception exc) {
                LOGGER.error("Problem...: " + exc.getMessage());
            }
        }
    } catch (Exception e) {
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } finally {
        try {
            if (rs != null)
                rs.close();
            if (coni != null)
                coni.close();
            if (cono != null)
                cono.close();
        } catch (Exception e) {
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
}

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

@Override
public void putValueInt(String valueName, Integer value) {
    try {/* w  w w  .j  av  a2 s .  co m*/
        mJSONObject.put(valueName, value.intValue());
    } catch (JSONException e) {
        Log.e(TAG, e.toString());
    }
}

From source file:jatran.stub.AStrutsAction.java

/**
 * @param mapping  The ActionMapping used to select this instance
 * @param form     The optional ActionForm bean for this request (if any)
 * @param request  The HTTP request we are proceeding
 * @param response The HTTP response we are creating
 * @return an ActionForward instance describing where and how
 *         control should be forwarded, or null if response
 *         has already been completed/*w w  w .  j  a va 2  s .c o  m*/
 */
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    HttpSession session = request.getSession();
    TotalsHourlyForm totalsHourlyForm = (TotalsHourlyForm) form;
    Locale locale = (Locale) session.getAttribute(Globals.LOCALE_KEY);
    if (locale == null) {
        locale = new Locale("en");
    }

    Calendar calendar = Calendar.getInstance();
    boolean dateIsNow = true;
    if (!GenericValidator.isBlankOrNull(totalsHourlyForm.getDate())) {
        try {
            Date date = DateUtil.parseDate(totalsHourlyForm.getDate(), locale);
            dateIsNow = false;
            calendar.setTime(date);
        } catch (ParseException e) {
        }
    }

    if (dateIsNow) {
        totalsHourlyForm.setDate(DateUtil.formatDate(calendar.getTime(), locale));
    }

    StatisticsManager statisticsManager = (StatisticsManager) getBean(Constants.STATISTICS_MANAGER_BEAN);

    Integer day = new Integer(calendar.get(Calendar.DAY_OF_MONTH));
    Integer month = new Integer(calendar.get(Calendar.MONTH) + 1);
    Integer year = new Integer(calendar.get(Calendar.YEAR));
    List hours = statisticsManager.getTotalsHourly(year, month, day);

    int maxTotal = 1;
    int maxUnique = 1;
    for (Iterator i = hours.iterator(); i.hasNext();) {
        Object[] hourDescr = (Object[]) i.next();
        Integer total = (Integer) hourDescr[1];
        Integer unique = (Integer) hourDescr[2];
        if (total.intValue() > maxTotal) {
            maxTotal = total.intValue();
        }
        if (unique.intValue() > maxUnique) {
            maxUnique = unique.intValue();
        }
    }

    request.setAttribute("hours", hours);
    request.setAttribute("maxTotal", new Integer(maxTotal));
    request.setAttribute("maxUnique", new Integer(maxUnique));

    Date date = calendar.getTime();
    request.setAttribute("date", date);

    return mapping.findForward("showTotalsHourly");
}