Example usage for java.lang Integer valueOf

List of usage examples for java.lang Integer valueOf

Introduction

In this page you can find the example usage for java.lang Integer valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Integer valueOf(int i) 

Source Link

Document

Returns an Integer instance representing the specified int value.

Usage

From source file:Main.java

public static Integer getIntegerAttr(Element element, String name) {
    String attr = element.getAttribute(name);
    if (!attr.isEmpty()) {
        Integer ret = Integer.valueOf(attr);
        return ret;
    }/*from  w w w .  ja  v  a2 s .c o m*/
    return null;
}

From source file:Main.java

public static ArrayList<Integer> asList(int... arr) {
    ArrayList<Integer> list = new ArrayList<Integer>(arr.length);
    for (int i = 0; i < arr.length; i++) {
        list.add(Integer.valueOf(arr[i]));
    }/*from   w  w w.  ja  v a  2s .c o  m*/
    return list;

}

From source file:Main.java

/**
 * see http://habrahabr.ru/post/144547//*from  w  w  w .j a v a 2s .c  o m*/
 */
public static BluetoothSocket createRfcommSocket(BluetoothDevice device) {
    BluetoothSocket tmp = null;
    try {
        Class class1 = device.getClass();
        Class aclass[] = new Class[1];
        aclass[0] = Integer.TYPE;
        Method method = class1.getMethod("createRfcommSocket", aclass);
        Object aobj[] = new Object[1];
        aobj[0] = Integer.valueOf(1);

        tmp = (BluetoothSocket) method.invoke(device, aobj);
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "createRfcommSocket() failed", e);
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "createRfcommSocket() failed", e);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        if (D)
            Log.e(TAG, "createRfcommSocket() failed", e);
    }
    return tmp;
}

From source file:Main.java

public static Integer getColorFromRgb(String rgb) {
    String[] rgbArray = rgb.split("\\s+");
    return Color.rgb(Integer.valueOf(rgbArray[0]), Integer.valueOf(rgbArray[1]), Integer.valueOf(rgbArray[2]));
}

From source file:Main.java

public static Integer getIntValue(byte[] value, int format, int position) {
    if (value == null || (format & 15) + position > value.length) {
        return null;
    }/*  w  w w.  jav  a2 s .  c  o m*/
    switch (format) {
    case FORMAT_UINT8 /*17*/:
        return Integer.valueOf(value[position] & 255);
    case FORMAT_UINT16 /*18*/:
        return Integer.valueOf(add(value[position], value[position + FIRST_BITMASK]));
    case FORMAT_UINT32 /*20*/:
        return Integer.valueOf(add(value[position], value[position + FIRST_BITMASK],
                value[position + SECOND_BITMASK], value[position + 3]));
    case FORMAT_SINT8 /*33*/:
        return Integer.valueOf(signed(value[position] & 255, FOURTH_BITMASK));
    case FORMAT_SINT16 /*34*/:
        return Integer.valueOf(signed(add(value[position], value[position + FIRST_BITMASK]), FIFTH_BITMASK));
    case FORMAT_SINT32 /*36*/:
        return Integer.valueOf(signed(add(value[position], value[position + FIRST_BITMASK],
                value[position + SECOND_BITMASK], value[position + 3]), SIXTH_BITMASK));
    default:
        return null;
    }
}

From source file:com.livinglogic.ul4.FunctionInt.java

public static Object call(Object obj) {
    if (obj instanceof String) {
        try {//  www  .j  a  v  a 2s  .  c  o m
            return Integer.valueOf((String) obj);
        } catch (NumberFormatException ex1) {
            try {
                return Long.valueOf((String) obj);
            } catch (NumberFormatException ex2) {
                return new BigInteger((String) obj);
            }
        }
    } else if (obj instanceof Integer || obj instanceof Byte || obj instanceof Short || obj instanceof Long)
        return obj;
    else if (obj instanceof BigInteger)
        return Utils.narrowBigInteger((BigInteger) obj);
    else if (obj instanceof Boolean)
        return ((Boolean) obj).booleanValue() ? NumberUtils.INTEGER_ONE : NumberUtils.INTEGER_ZERO;
    else if (obj instanceof Float || obj instanceof Double)
        return ((Number) obj).intValue();
    else if (obj instanceof BigDecimal)
        return ((BigDecimal) obj).toBigInteger();
    throw new ArgumentTypeMismatchException("int({})", obj);
}

From source file:Main.java

public static int getOdometerInt(EditText text) {
    int value = 0;
    try {// w  ww. j  a v a2s. c  o m
        value = Integer.valueOf(text.getText().toString().trim());
    } catch (NumberFormatException e) {
    }
    return value;
}

From source file:Main.java

public static Integer getColorFromRgb(String rgb) {
    String[] rgbArray = rgb.split("\\s+");
    int color = Color.rgb(Integer.valueOf(rgbArray[0]), Integer.valueOf(rgbArray[1]),
            Integer.valueOf(rgbArray[2]));
    return color;
}

From source file:net.jakobnielsen.imagga.convert.ConverterTools.java

public static Integer getInteger(String key, Object o) {
    return Integer.valueOf(getString(key, o));
}

From source file:Main.java

public static Integer getAttributeInteger(Node node, String attributeName) {
    String value = getAttribute(node, attributeName, null);
    return (value == null ? null : Integer.valueOf(value));
}