Example usage for java.lang Number intValue

List of usage examples for java.lang Number intValue

Introduction

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

Prototype

public abstract int intValue();

Source Link

Document

Returns the value of the specified number as an int .

Usage

From source file:lib.JdbcTemplate.java

@Override
@Deprecated//from  www . j  a  v  a  2s.  c  o  m
public int queryForInt(String sql, Object... args) throws DataAccessException {
    Number number = queryForObject(sql, args, Integer.class);
    return (number != null ? number.intValue() : 0);
}

From source file:lib.JdbcTemplate.java

@Override
@Deprecated/*from  ww w. jav  a 2  s .c  o m*/
public int queryForInt(String sql, Object[] args, int[] argTypes) throws DataAccessException {
    Number number = queryForObject(sql, args, argTypes, Integer.class);
    return (number != null ? number.intValue() : 0);
}

From source file:com.example.app.profile.model.ProfileDAO.java

/**
 * Test if the specified user has any of the specified MembershipTypes on
 * any active profile.// w  ww  .  j av  a 2s  .  c o  m
 *
 * @param user the user.
 * @param timeZone the current TimeZone
 * @param types the types.
 *
 * @return true or false.
 */
public boolean hasMembership(User user, TimeZone timeZone, MembershipType... types) {
    final Date now = convertForPersistence(getZonedDateTimeForComparison(timeZone));
    Number count = (Number) getSession().createQuery(
            "SELECT COUNT(DISTINCT p) FROM Profile p INNER JOIN p.membershipSet m INNER JOIN m.membershipType mt\n"
                    + " WHERE m.user = :user AND mt IN (:types)\n"
                    + " AND (m.startDate IS NULL OR m.startDate <= :now)\n"
                    + " AND (m.endDate IS NULL OR m.endDate >= :now)")
            .setParameter("user", user).setParameterList("types", types).setParameter("now", now)
            .setCacheRegion(ProjectCacheRegions.PROFILE_QUERY).setCacheable(true).uniqueResult();
    return count.intValue() > 0;
}

From source file:net.sf.jasperreports.engine.fill.JRBaseFiller.java

@continuable
protected void addPageToParent(final boolean ended) throws JRException {
    if (printPage == null) {
        return;/*from   w  ww .ja v  a  2  s  . c om*/
    }

    FillerPageAddedEvent pageAdded = new FillerPageAddedEvent() {
        @Override
        public JasperPrint getJasperPrint() {
            return jasperPrint;
        }

        @Override
        public JRPrintPage getPage() {
            return printPage;
        }

        @Override
        public boolean hasReportEnded() {
            return ended;
        }

        @Override
        public int getPageStretchHeight() {
            return offsetY + bottomMargin;
        }

        @Override
        public int getPageIndex() {
            Number pageNumber = (Number) calculator.getPageNumber().getValue();
            if (pageNumber == null)//this happens when whenNoDataType="BlankPage" //FIXMEBOOK maybe we should set the variable?
            {
                return 0;
            }
            return pageNumber.intValue() - 1;
        }

        @Override
        public JRBaseFiller getFiller() {
            return JRBaseFiller.this;
        }

        @Override
        public DelayedFillActions getDelayedActions() {
            return delayedActions;
        }
    };

    //FIXMEBOOK use a fill listener instead of this?
    bandReportParent.addPage(pageAdded);
}

From source file:com.gettec.fsnip.fsn.dao.product.impl.ProductDAOImpl.java

/**
 * dao?????//  w ww.  j a  v  a 2  s  .  c  o  m
 */
@Override
public long getCountByName(String name) throws DaoException {
    int count = 0;
    try {
        String jpql = "SELECT count(*) FROM product where name like ?1";
        Query query = entityManager.createNativeQuery(jpql).setParameter(1, "%" + name + "%");
        Number result = (Number) query.getSingleResult();
        count = result.intValue();
    } catch (Exception e) {
        throw new DaoException("dao?????", e);
    }
    return count;
}

From source file:com.gettec.fsnip.fsn.dao.product.impl.ProductDAOImpl.java

/**
 * ??/*from   w  w w.j a  va 2 s  .  c om*/
  * @author LongXianZhen   2015/05/06
 */
@Override
public boolean judgeProductOrgModify(Long organization) throws DaoException {
    try {
        String sql = " SELECT COUNT(*) FROM lead_product_org WHERE organization=?1 ";
        Query query = entityManager.createNativeQuery(sql).setParameter(1, organization);
        Number result = (Number) query.getSingleResult();
        int count = result.intValue();
        return count > 0 ? true : false;
    } catch (Exception e) {
        throw new DaoException("ProductDAOImpl.judgeProductOrgModify()-->> ?", e);
    }
}

From source file:com.gettec.fsnip.fsn.dao.product.impl.ProductDAOImpl.java

/**
 * ???//from   www .  j  av  a 2s .  c  o m
 * @param organization  id
 * @param hotWords  ??
 * @return
 * @throws DaoException 
 */
@Override
public long countByHotWord(Long organization, String hotWord) throws DaoException {
    try {
        String sql = "SELECT count(*)" + " FROM product, nutri_rpt" + " WHERE product.organization = "
                + organization + " AND product.id = nutri_rpt.product_id" + " AND nutri_rpt.`name` = '"
                + hotWord + "'";
        Query query = entityManager.createNativeQuery(sql.toString());
        Number result = (Number) query.getSingleResult();
        int count = result.intValue();
        return count;
    } catch (Exception e) {
        throw new DaoException("?DAO-error???", e);
    }
}

From source file:com.cinchapi.concourse.util.ConvertTest.java

@Test
public void testConvertLinkFromIntValue() {
    // A int/long that is wrapped between two at (@) symbols must always
    // convert to a Link
    Number number = Random.getInt();
    String value = MessageFormat.format("{0}{1}", "@", number.toString()); // must
                                                                           // use
                                                                           // number.toString()
                                                                           // so
                                                                           // comma
                                                                           // separators
                                                                           // are
                                                                           // not
                                                                           // added
                                                                           // to
                                                                           // the
                                                                           // output
    Link link = (Link) Convert.stringToJava(value);
    Assert.assertEquals(number.intValue(), link.intValue());
}