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:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreter.java

private AbstractInsnNode handleXOr(final int opcode, final Number one, final Number two) {
    final Number number;
    if (opcode == IXOR) {
        number = Integer.valueOf(one.intValue() ^ two.intValue());
    } else {//w w  w.  java  2  s  . c o m
        number = Long.valueOf(one.longValue() ^ two.longValue());
    }
    return NodeHelper.getInsnNodeFor(number);
}

From source file:com.aw.core.dao.DAOSql.java

/**
 * Helper method used to retrieve the select count(*)
 *
 * @param sqlFromWhereClause SQL query without the SELECT section: "FROM x where X=y"
 * @param filterKeys         key used to restrict the search
 * @return number of rows that return the query
 *//*from  w ww  .j a  v a2  s . c o m*/
public int findCountRows(String sqlFromWhereClause, Object[] filterKeys) {
    String sql = "SELECT count(*) " + sqlFromWhereClause;
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("Executing:" + AWQueryRunner.buildSQLLog(sql, filterKeys));
        }
        Number num = (Number) new QueryRunner().query(getHibernateConnection(), sql, filterKeys,
                new ScalarHandler());
        return num.intValue();
    } catch (SQLException e) {
        throw AWBusinessException.wrapUnhandledException(logger, e);
    }
}

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

/**
 * Set the component1 from a Number object.
 * <br />/* ww w  .  j  av  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 setComponent1(String) 
 * method.
 * 
 * @see #setComponent1(String)
 *
 * @param component1 the Number with the component1 content to set
 */
public Field28E setComponent1(java.lang.Number component1) {
    if (component1 != null) {
        setComponent(1, "" + component1.intValue());
    }
    return this;
}

From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreter.java

private AbstractInsnNode handleLogicalShiftRight(final int opcode, final Number one, final Number two) {
    final Number number;
    if (opcode == IUSHR) {
        number = Integer.valueOf(one.intValue() >>> two.intValue());
    } else {/*  w  w  w.  j a v a2 s. c  om*/
        number = Long.valueOf(one.longValue() >>> two.longValue());
    }
    return NodeHelper.getInsnNodeFor(number);
}

From source file:nl.edia.sakai.tool.skinmanager.impl.SkinArchiveServiceImpl.java

@Override
public SkinArchive createSkinArchive(final String name, final InputStream file, final Date time,
        final String comment) {
    return (SkinArchive) getHibernateTemplate().execute(new HibernateCallback() {
        @Override//from  w  w  w  .  j av  a 2s. c o m
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            int myVersion = 0;
            Number myHighestVersion = (Number) session.createCriteria(SkinArchive.class)
                    .add(Restrictions.eq("name", name)).setProjection(Projections.max("version"))
                    .uniqueResult();
            if (myHighestVersion != null) {
                myVersion = myHighestVersion.intValue() + 1;
            }

            SkinArchive mySkinArchive = new SkinArchive();
            mySkinArchive.setActive(true);
            mySkinArchive.setLastModified(new Timestamp(time.getTime()));
            mySkinArchive.setName(name);
            mySkinArchive.setVersion(myVersion);
            mySkinArchive.setComment(comment);
            try {
                mySkinArchive.setFile(Hibernate.createBlob(file));
            } catch (IOException e) {
                throw new HibernateException(e);
            }
            session.save(mySkinArchive);
            setSkinStatus(name, true);
            return mySkinArchive;
        }
    });
}

From source file:com.haulmont.cuba.core.app.FoldersServiceBean.java

protected boolean loadFolderQuantity(Binding binding, AppFolder folder) {
    if (!StringUtils.isBlank(folder.getQuantityScript())) {
        binding.setVariable("folder", folder);

        String styleVariable = "style";
        binding.setVariable(styleVariable, null);

        try {//from w  w w . j  a  v a2s  . com
            Number qty = runScript(folder.getQuantityScript(), binding);
            folder.setItemStyle((String) binding.getVariable(styleVariable));
            folder.setQuantity(qty == null ? null : qty.intValue());
        } catch (Exception e) {
            log.warn("Unable to evaluate AppFolder quantity script for folder: id: {} , name: {}",
                    folder.getId(), folder.getName(), e);
            return false;
        }
    }

    return true;
}

From source file:de.innovationgate.webgate.api.jdbc.PortletRegistryImplV4.java

private boolean isRootPortletKey(String key) {

    if (key.equals("")) {
        return true;
    }//from   w ww  . j  av a  2  s. com

    if (key.length() == 6) {
        try {
            String indexStr = key.substring(3);
            Number index = PORTLETINDEX_FORMAT.parse(indexStr);
            if (index.intValue() == 0) {
                return true;
            }
        } catch (Exception e) {
        }
    }

    return false;
}

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

/**
 * Set the component2 from a Number object.
 * <br />/*w  w  w  . j  a  va2  s  . c o  m*/
 * <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 setComponent2(String) 
 * method.
 * 
 * @see #setComponent2(String)
 *
 * @param component2 the Number with the component2 content to set
 */
public Field405 setComponent2(java.lang.Number component2) {
    if (component2 != null) {
        setComponent(2, "" + component2.intValue());
    }
    return this;
}

From source file:io.coala.random.impl.RandomDistributionFactoryImpl.java

@Override
public RandomNumberDistribution<Integer> getPascal(final RandomNumberStream rng, final Number r,
        final Number p) {
    final IntegerDistribution dist = new PascalDistribution(
            RandomNumberStream.Util.asCommonsRandomGenerator(rng), r.intValue(), p.doubleValue());
    return new RandomNumberDistribution<Integer>() {
        @Override/*from  ww  w  .  j  a  v a2 s . c  om*/
        public Integer draw() {
            return dist.sample();
        }
    };
}

From source file:com.hortonworks.streamline.streams.cluster.register.impl.StormServiceRegistrar.java

private Pair<Component, List<ComponentProcess>> createStormUIServerComponent(Config config,
        Map<String, String> flattenConfigMap) {
    if (!config.contains(PARAM_UI_HOST)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " not present.");
    }/*from ww  w .  j  a v  a  2 s.c o  m*/

    if (!config.contains(PARAM_UI_PORT)) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_PORT + " not present.");
    }

    String stormUiServerHost;
    try {
        stormUiServerHost = config.getString(PARAM_UI_HOST);
    } catch (ClassCastException e) {
        throw new IllegalArgumentException("Required parameter " + PARAM_UI_HOST + " should be a string.");
    }

    Number stormUiServerPort = readNumberFromConfig(config, PARAM_UI_PORT);

    Component stormUiServer = new Component();
    stormUiServer.setName(COMPONENT_STORM_UI_SERVER);

    ComponentProcess uiProcess = new ComponentProcess();
    uiProcess.setHost(stormUiServerHost);
    uiProcess.setPort(stormUiServerPort.intValue());

    return new Pair<>(stormUiServer, Collections.singletonList(uiProcess));
}