Java Object to Float objectToInt(Object val)

Here you can find the source of objectToInt(Object val)

Description

get the value contained in the object.

License

Open Source License

Parameter

Parameter Description
val returns the value of Shorts and Integers as an int. VPF null values get returned as Integer.MIN_VALUE, as do all other types

Return

the value contained in val

Declaration

public static final int objectToInt(Object val) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  www  .j a va 2s  . co m
     * get the value contained in the object.
     * 
     * @param val returns the value of Shorts and Integers as an int. VPF null
     *        values get returned as Integer.MIN_VALUE, as do all other types
     * @return the value contained in val
     */
    public static final int objectToInt(Object val) {
        int v = Integer.MIN_VALUE;
        if (val instanceof Integer) {
            v = ((Integer) val).intValue();
            if (v == Integer.MIN_VALUE + 1) {
                v = Integer.MIN_VALUE;
            }
        } else if (val instanceof Short) {
            v = ((Short) val).shortValue();
            if (v == Short.MIN_VALUE + 1) {
                v = Integer.MIN_VALUE;
            }
        }
        return v;
    }
}

Related

  1. objectToInt(Object o)
  2. objectToInt(Object obj)
  3. objectToInt(Object Obj)
  4. objectToInt(Object obj)
  5. objectToInt(Object p1)