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:com.prowidesoftware.swift.model.field.Field331.java

/**
 * Set the component10 from a Number object.
 * <br />/*from  w w w  . j  a va2 s .  c om*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent10(String) 
 * method.
 * 
 * @see #setComponent10(String)
 *
 * @param component10 the Number with the component10 content to set
 */
public Field331 setComponent10(java.lang.Number component10) {
    if (component10 != null) {
        setComponent(10, "" + component10.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field331.java

/**
 * Set the component11 from a Number object.
 * <br />/*from www.jav  a  2s  .  c  om*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent11(String) 
 * method.
 * 
 * @see #setComponent11(String)
 *
 * @param component11 the Number with the component11 content to set
 */
public Field331 setComponent11(java.lang.Number component11) {
    if (component11 != null) {
        setComponent(11, "" + component11.intValue());
    }
    return this;
}

From source file:com.prowidesoftware.swift.model.field.Field331.java

/**
 * Set the component12 from a Number object.
 * <br />/*from   w  w w  .  j a v  a  2  s  .  com*/
 * <em>If the component being set is a fixed length number, the argument will not be 
 * padded.</em> It is recommended for these cases to use the setComponent12(String) 
 * method.
 * 
 * @see #setComponent12(String)
 *
 * @param component12 the Number with the component12 content to set
 */
public Field331 setComponent12(java.lang.Number component12) {
    if (component12 != null) {
        setComponent(12, "" + component12.intValue());
    }
    return this;
}

From source file:com.xtructure.xevolution.genetics.impl.AbstractPopulation.java

/**
 * Adds the attribute in the given {@link Genome} with the given
 * {@link XValId} to the corresponding value in the accumulation map.
 * //from w w  w .  j a  v  a  2s .  c  o  m
 * @param <V>
 *            the type of the attribute
 * @param valueId
 *            the id of the attribute
 * @param accMap
 *            the accumulation map
 * @param genome
 *            the {@link Genome} from which to get the attribute
 */
private <V extends Comparable<V>> void updateAccMap(XValId<V> valueId, ValueMap accMap, Genome<D> genome) {
    getLogger().trace("begin %s.updateAccMap(%s, %s, %s)", getClass().getSimpleName(), valueId, accMap, genome);
    if (Number.class.isAssignableFrom(valueId.getType())) {
        if (accMap.get(valueId) == null) {
            accMap.set(//
                    valueId, //
                    genome.getAttribute(valueId));
        } else {
            Number acc = (Number) accMap.get(valueId);
            Number nxt = (Number) genome.getAttribute(valueId);
            Number sum = null;
            ValueType type = ValueType.getValueType(valueId.getType());
            if (type != null) {
                switch (type) {
                case DOUBLE:
                    sum = acc.doubleValue() + nxt.doubleValue();
                    break;
                case FLOAT:
                    sum = acc.floatValue() + nxt.floatValue();
                    break;
                case LONG:
                    sum = acc.longValue() + nxt.longValue();
                    break;
                case INTEGER:
                    sum = acc.intValue() + nxt.intValue();
                    break;
                case SHORT:
                    sum = acc.shortValue() + nxt.shortValue();
                    break;
                case BYTE:
                    sum = acc.byteValue() + nxt.byteValue();
                    break;
                default:
                    break;
                }
                @SuppressWarnings("unchecked")
                V v = (V) sum;
                accMap.set(valueId, v);
            }
        }
    }
    getLogger().trace("end %s.updateAccMap()", getClass().getSimpleName());
}

From source file:com.gettec.fsnip.fsn.dao.member.impl.MemberDAOImpl.java

/**
 * dao????/*from   w w w  . jav  a  2s .  co m*/
 */
@Override
public long getCountByName(String name) throws DaoException {
    int count = 0;
    try {
        String jpql = "SELECT count(*) FROM member 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.member.impl.MemberDAOImpl.java

/**
 * ?/*from  w  w w. j  ava 2 s . c  o m*/
  * @author LongXianZhen   2015/05/06
 */
@Override
public boolean judgeMemberOrgModify(Long organization) throws DaoException {
    try {
        String sql = " SELECT COUNT(*) FROM lead_member_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("MemberDAOImpl.judgeMemberOrgModify()-->> ?", e);
    }
}

From source file:com.gettec.fsnip.fsn.dao.member.impl.MemberDAOImpl.java

/**
 * ??//w w  w.j  a va 2  s.  co  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 member, nutri_rpt" + " WHERE member.organization = "
                + organization + " AND member.id = nutri_rpt.member_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:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private byte[] generateLineChart(String siteId, CategoryDataset dataset, int width, int height,
        boolean render3d, float transparency, boolean itemLabelsVisible, boolean smallFontInDomainAxis) {
    JFreeChart chart = null;//  w  w  w  . jav a  2  s  .  c o  m
    if (render3d)
        chart = ChartFactory.createLineChart3D(null, null, null, dataset, PlotOrientation.VERTICAL, true, false,
                false);
    else
        chart = ChartFactory.createLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, false,
                false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set transparency
    plot.setForegroundAlpha(transparency);

    // set background
    chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // set antialias
    chart.setAntiAlias(true);

    // set domain axis font size
    if (smallFontInDomainAxis && !canUseNormalFontSize(width)) {
        plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 8));
        plot.getDomainAxis().setCategoryMargin(0.05);
    }

    // set outline
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setDrawOutlines(true);

    // item labels
    if (itemLabelsVisible) {
        plot.getRangeAxis().setUpperMargin(0.2);
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator() {
            private static final long serialVersionUID = 1L;

            @Override
            public String generateLabel(CategoryDataset dataset, int row, int column) {
                Number n = dataset.getValue(row, column);
                if (n.intValue() != 0)
                    //return n.intValue()+"";
                    return n.toString();
                return "";
            }
        });
        renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 8));
        renderer.setItemLabelsVisible(true);
    }

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        LOG.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}

From source file:org.sakaiproject.sitestats.impl.chart.ChartServiceImpl.java

private byte[] generateBarChart(String siteId, CategoryDataset dataset, int width, int height, boolean render3d,
        float transparency, boolean itemLabelsVisible, boolean smallFontInDomainAxis) {
    JFreeChart chart = null;//from   www.j a v  a2 s  . c o m
    if (render3d)
        chart = ChartFactory.createBarChart3D(null, null, null, dataset, PlotOrientation.VERTICAL, true, false,
                false);
    else
        chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, false,
                false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // set transparency
    plot.setForegroundAlpha(transparency);

    // set background
    chart.setBackgroundPaint(parseColor(M_sm.getChartBackgroundColor()));

    // set chart border
    chart.setPadding(new RectangleInsets(10, 5, 5, 5));
    chart.setBorderVisible(true);
    chart.setBorderPaint(parseColor("#cccccc"));

    // allow longer legends (prevent truncation)
    plot.getDomainAxis().setMaximumCategoryLabelLines(50);
    plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(1.0f);

    // set antialias
    chart.setAntiAlias(true);

    // set domain axis font size
    if (smallFontInDomainAxis && !canUseNormalFontSize(width)) {
        plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 8));
        plot.getDomainAxis().setCategoryMargin(0.05);
    }

    // set bar outline
    BarRenderer barrenderer = (BarRenderer) plot.getRenderer();
    barrenderer.setDrawBarOutline(true);
    if (smallFontInDomainAxis && !canUseNormalFontSize(width))
        barrenderer.setItemMargin(0.05);
    else
        barrenderer.setItemMargin(0.10);

    // item labels
    if (itemLabelsVisible) {
        plot.getRangeAxis().setUpperMargin(0.2);
        barrenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator() {
            private static final long serialVersionUID = 1L;

            @Override
            public String generateLabel(CategoryDataset dataset, int row, int column) {
                Number n = dataset.getValue(row, column);
                if (n.doubleValue() != 0) {
                    if ((double) n.intValue() == n.doubleValue())
                        return Integer.toString(n.intValue());
                    else
                        return Double.toString(Util.round(n.doubleValue(), 1));
                }
                return "";
            }
        });
        barrenderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 8));
        barrenderer.setItemLabelsVisible(true);
    }

    BufferedImage img = chart.createBufferedImage(width, height);
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    try {
        ImageIO.write(img, "png", out);
    } catch (IOException e) {
        LOG.warn("Error occurred while generating SiteStats chart image data", e);
    }
    return out.toByteArray();
}

From source file:lib.JdbcTemplate.java

@Override
@Deprecated//  w  w  w  .  jav a  2  s  .  co  m
public int queryForInt(String sql) throws DataAccessException {
    Number number = queryForObject(sql, Integer.class);
    return (number != null ? number.intValue() : 0);
}