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:MutableInt.java

/**
 * Subtracts a value./* w ww.j av a 2 s  .com*/
 * 
 * @param operand
 *            the value to add
 * @throws NullPointerException
 *             if the object is null
 *
 * @since Commons Lang 2.2
 */
public void subtract(Number operand) {
    this.value -= operand.intValue();
}

From source file:de.hs.mannheim.modUro.controller.diagram.SimulationDiagramController.java

public void init(Simulation simulation) {
    this.simulation = simulation;
    this.simulationDiagram = new SimulationDiagram(simulation);

    if (leftLastSelectedIndex == null || rightLastSelectedIndex == null) {
        initializeChoiceboxContent();//  www.j  av a 2s .c  o  m
    } else {
        if (simulationContainsMetricType()) {
            setChoiceBoxContent();
            setLeftChartContent(leftLastSelectedIndex);
            setRightChartContent(rightLastSelectedIndex);
        } else {
            Alert alert = new Alert(Alert.AlertType.WARNING);
            alert.setTitle("Warning");
            alert.setHeaderText("Metrictype Warning");
            alert.setContentText("Simulation does not have Metrictype: " + leftLastSelectedMetrictypename);
            alert.showAndWait();

            initializeChoiceboxContent();
        }

    }

    /*ChangeListerners for selected items in choicebox.*/
    leftMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            setLeftChartContent(newValue.intValue());
            leftLastSelectedIndex = newValue.intValue();
            leftLastSelectedMetrictypename = choiceBoxMetrictypeNames().get(leftLastSelectedIndex);

        }
    });

    rightMetricType.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
            setRightChartContent(newValue.intValue());
            rightLastSelectedIndex = newValue.intValue();
            rightLastSelectedMetrictypename = choiceBoxMetrictypeNames().get(rightLastSelectedIndex);
        }
    });
}

From source file:bhl.pages.handler.PagesListHandler.java

public void handle(HttpServletRequest request, HttpServletResponse response, String urn)
        throws MissingDocumentException {
    try {/*from w  w w .  j  a va 2 s  .  c o m*/
        String docid = request.getParameter(Params.DOCID);
        if (docid != null) {
            Connection conn = Connector.getConnection();
            String[] keys = new String[2];
            keys[0] = JSONKeys.BHL_PAGE_ID;
            keys[1] = JSONKeys.PAGE_SEQUENCE;
            String[] pages = conn.listCollectionBySubKey(Database.PAGES, JSONKeys.IA_IDENTIFIER, docid, keys);
            JSONArray list = new JSONArray();
            for (int i = 0; i < pages.length; i++) {
                JSONObject jobj = (JSONObject) JSONValue.parse(pages[i]);
                Number pageNo = (Number) jobj.get(JSONKeys.PAGE_SEQUENCE);
                Number pageId = (Number) jobj.get(JSONKeys.BHL_PAGE_ID);
                System.out.println("pageNo=" + pageNo + " pageId=" + pageId);
                PageDesc ps = new PageDesc(new Integer(pageNo.intValue()).toString(),
                        new Integer(pageId.intValue()).toString());
                list.add(ps.toJSONObject());
            }
            PagesGetHandler.sortList(list);
            response.setContentType("application/json");
            response.getWriter().print(list.toJSONString());
        } else
            throw new Exception("Must specify document identifier");
    } catch (Exception e) {
        throw new MissingDocumentException(e);
    }
}

From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java

/**
 * Gets the boolean value.//from   w  w  w  . j  a v a 2  s  . c  o  m
 * 
 * @param node
 *          the node
 * @return the boolean value
 * @throws NotANumberException
 *           the not a number exception
 */
public static boolean getBooleanValue(final AbstractInsnNode node) throws NotANumberException {
    if (node == null) {
        throw new NotANumberException();
    }
    final Number numberValue = getNumberValue(node);
    if (numberValue == null) {
        throw new NotANumberException();
    }
    final int bool = numberValue.intValue();
    return Boolean.valueOf(bool == 1);
}

From source file:de.codesourcery.flocking.ui.NumberInputField.java

protected String numberToString(Number n) {
    if (onlyIntValues) {
        return n == null ? "0" : Long.toString(n.intValue());
    }//  w w  w. j a va  2s  . co m
    final DecimalFormat DF = new DecimalFormat("########0.0###");
    return n == null ? "0.0" : DF.format(n.doubleValue());
}

From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java

/**
 * Gets the char value./*  ww w  . j a  v a 2s . c  o  m*/
 * 
 * @param node
 *          the node
 * @return the char value
 * @throws NotANumberException
 *           the not a number exception
 */
public static char getCharValue(final AbstractInsnNode node) throws NotANumberException {
    if (node == null) {
        throw new NotANumberException();
    }
    final Number numberValue = getNumberValue(node);
    if (numberValue == null) {
        throw new NotANumberException();
    }
    final int charValue = numberValue.intValue();
    return Character.valueOf((char) charValue);
}

From source file:MutableInt.java

/**
 * Constructs a new MutableInt with the specified value.
 * //w  w  w  .j  a v a  2 s. com
 * @param value
 *                  a value.
 * @throws NullPointerException
 *                  if the object is null
 */
public MutableInt(Number value) {
    super();
    this.value = value.intValue();
}

From source file:com.opengamma.financial.analytics.volatility.surface.BloombergBondFuturePriceCurveInstrumentProvider.java

@Override
/**// www .j  a  va2 s  . com
 * Provides ExternalID for Bloomberg ticker, eg RXZ3 Comdty,
 * given a reference date and an integer offset, the n'th subsequent future
 * The format is _futurePrefix + month + year + _postfix
 * @param futureNumber n'th future following curve date
 * @param curveDate date of curve validity; valuation date
 */
public ExternalId getInstrument(final Number futureNumber, final LocalDate curveDate) {
    final StringBuffer ticker = new StringBuffer();
    ticker.append(_futurePrefix);
    ticker.append(BloombergFutureUtils.getQuarterlyExpiryCodeForFutures(_futurePrefix, futureNumber.intValue(),
            curveDate));
    ticker.append(" ");
    ticker.append(_postfix);
    return ExternalId.of(ExternalScheme.of(_tickerScheme), ticker.toString());
}

From source file:net.duckling.ddl.service.resource.dao.TagItemDAOImpl.java

@Override
public int create(final TagItem tagItem) {
    GeneratedKeyHolder keyHolder = new GeneratedKeyHolder();
    this.getJdbcTemplate().update(new PreparedStatementCreator() {

        @Override/*w  ww  .j a va2  s . com*/
        public PreparedStatement createPreparedStatement(Connection conn) throws SQLException {
            PreparedStatement ps = null;
            ps = conn.prepareStatement(SQL_CREATE, PreparedStatement.RETURN_GENERATED_KEYS);
            int i = 0;
            ps.setInt(++i, tagItem.getTid());
            ps.setInt(++i, tagItem.getTgid());
            ps.setInt(++i, tagItem.getRid());
            ps.setInt(++i, tagItem.getTid());
            ps.setInt(++i, tagItem.getTgid());
            ps.setInt(++i, tagItem.getRid());
            return ps;
        }

    }, keyHolder);
    Number key = keyHolder.getKey();
    return (key == null) ? -1 : key.intValue();
}

From source file:com.sun.faces.el.impl.Coercions.java

/**
 * Coerces a Number to the given primitive number class
 *//*  w ww  .  j a va  2 s .  co m*/
static Number coerceToPrimitiveNumber(Number pValue, Class pClass) throws ElException {
    if (pClass == Byte.class || pClass == Byte.TYPE) {
        return PrimitiveObjects.getByte(pValue.byteValue());
    } else if (pClass == Short.class || pClass == Short.TYPE) {
        return PrimitiveObjects.getShort(pValue.shortValue());
    } else if (pClass == Integer.class || pClass == Integer.TYPE) {
        return PrimitiveObjects.getInteger(pValue.intValue());
    } else if (pClass == Long.class || pClass == Long.TYPE) {
        return PrimitiveObjects.getLong(pValue.longValue());
    } else if (pClass == Float.class || pClass == Float.TYPE) {
        return PrimitiveObjects.getFloat(pValue.floatValue());
    } else if (pClass == Double.class || pClass == Double.TYPE) {
        return PrimitiveObjects.getDouble(pValue.doubleValue());
    } else if (pClass == BigInteger.class) {
        if (pValue instanceof BigDecimal)
            return ((BigDecimal) pValue).toBigInteger();
        else
            return BigInteger.valueOf(pValue.longValue());
    } else if (pClass == BigDecimal.class) {
        if (pValue instanceof BigInteger)
            return new BigDecimal((BigInteger) pValue);
        else
            return new BigDecimal(pValue.doubleValue());
    } else {
        return PrimitiveObjects.getInteger(0);
    }
}