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

public static void main(String[] args) throws Exception {
    XPathFactory factory = XPathFactory.newInstance();
    XPath xPath = factory.newXPath();

    Number shows = (Number) xPath.evaluate("count(/schedule/show)", new InputSource(new FileReader("tds.xml")),
            XPathConstants.NUMBER);
    System.out.println("Document has " + shows.intValue() + " shows.");
}

From source file:Main.java

public static void main(String[] args) {

    // get a number as float
    Number x = new Float(123456f);

    // get a number as double
    Number y = new Double(9876);

    // print their value as int
    System.out.println("x as float:" + x + ", x as Integer:" + x.intValue());
    System.out.println("y as double:" + y + ", y as Integer:" + y.intValue());

}

From source file:com.pinterest.secor.main.TestLogMessageProducerMain.java

public static void main(String[] args) {
    try {/*from  w  w  w.  ja v a  2s  .  co m*/
        CommandLine commandLine = parseArgs(args);
        String topic = commandLine.getOptionValue("topic");
        int messages = ((Number) commandLine.getParsedOptionValue("messages")).intValue();
        int producers = ((Number) commandLine.getParsedOptionValue("producers")).intValue();
        String broker = commandLine.getOptionValue("broker");
        String type = commandLine.getOptionValue("type");
        Number timeshiftNumber = ((Number) commandLine.getParsedOptionValue("timeshift"));
        int timeshift = timeshiftNumber == null ? 0 : timeshiftNumber.intValue();
        for (int i = 0; i < producers; ++i) {
            TestLogMessageProducer producer = new TestLogMessageProducer(topic, messages, type, broker,
                    timeshift);
            producer.start();
        }
    } catch (Throwable t) {
        LOG.error("Log message producer failed", t);
        System.exit(1);
    }
}

From source file:Main.java

public static int[] toIntArray(Collection<? extends Number> c) {
    int arr[] = new int[c.size()];
    int i = 0;/* w  w w .  j ava2 s  .co  m*/
    for (Number item : c)
        arr[i++] = item.intValue();
    return arr;
}

From source file:Main.java

static public int[] toIntArray(ArrayList list) {
    int[] result = new int[list.size()];

    for (int i = 0; i < list.size(); i++) {
        Number n = (Number) list.get(i);
        result[i] = n.intValue();
    }//w ww  . j a v  a2  s  . c o m

    return result;
}

From source file:Main.java

/**
 * Convert a Collection of Numbers to an array of primitive ints
 * Null values will be skipped in the array 
 * @param items/*from   w ww . ja  v  a 2  s  .co m*/
 * @return
 */
public static int[] toIntArray(Collection<? extends Number> items) {
    int ret[] = new int[items.size()];
    int idx = 0;
    for (Number n : items) {
        if (n != null)
            ret[idx] = n.intValue();
        idx += 1;
    } // FOR
    return (ret);
}

From source file:Main.java

public static int evalXPathAsInt(Object item, String xpath, XPathFactory factory)
        throws XPathExpressionException {
    XPath path = factory.newXPath();
    XPathExpression expr = path.compile(xpath);
    Number result = (Number) expr.evaluate(item, XPathConstants.NUMBER);
    return result == null ? 0 : result.intValue();
}

From source file:com.shenit.commons.utils.AvatarUtils.java

/**
 * /* w w w. ja v a 2 s. c  om*/
 * 
 * @param width
 * @return
 */
private static int calHeight(Number width) {
    return (int) AVATAR_RATIO * width.intValue();
}

From source file:example.app.geode.server.GeodeServerApplication.java

protected static int intValue(Number value) {
    return value.intValue();
}

From source file:com.aregner.pandora.XmlRpc.java

public static String value(Number v) {
    return value(v.intValue());
}