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

/**
 * Calls getTextValue and returns a int value
 */// w ww  . j a  va 2  s .  c om

public static boolean isInteger(String string) {
    try {
        Integer.valueOf(string);
        return true;
    } catch (NumberFormatException e) {
        return false;
    }
}

From source file:Main.java

private static int getResponseErrorCode(Throwable throwable) {
    try {//from w w  w . j  av  a 2s.  c  o  m
        String s = "{ \"success\": \"false\", \"destinations\":[ { \"id\": \"5025:125:1\",  \"destinationSet\": \"5025:125:1\", \"HTTPCode\": \"401\", \"code\": \"100077\" }] }";
        JSONObject object = new JSONObject(s);

        String code = object.getJSONArray("destinations").getJSONObject(0).optString("code");

        return Integer.valueOf(code);
    } catch (JSONException e1) {
        System.out.println("error parse error response, message: ");
        return -1;
    } catch (NumberFormatException e2) {
        System.out.println("error parse error response, invalid error code(non integer)!");
        //                Ln.w("error parse error response, invalid error code(non integer)! %s", e2.getMessage());
        return -1;
    }

}

From source file:Main.java

private static Object[] toArrayByString(String str) {
    List<Object> result = new ArrayList<Object>();
    str = str.substring(1, str.length() - 1);
    String type = str.substring(0, str.indexOf("@"));
    String[] values = str.substring(str.indexOf("@") + 1).split(",");
    for (int i = 0; i < values.length; i++) {
        String value = unesc(values[i]);
        if (LONG.equals(type)) {
            result.add(Long.valueOf(value));
        } else if (INTEGER.equals(type)) {
            result.add(Integer.valueOf(value));
        } else {/*w ww . j a  v a  2 s .  c  o  m*/
            result.add(value);
        }
    }
    return result.toArray();
}

From source file:Main.java

private static int getResponseErrorCode(Throwable throwable) {
    try {//from  w w  w .  j  a  v  a 2 s .  c  o  m
        String s = "{ \"success\": \"false\", \"destinations\":[ { \"id\": \"5025:125:1\",  \"destinationSet\": \"5025:125:1\", \"HTTPCode\": \"401\", \"code\": \"100077\" }] }";
        JSONObject object = new JSONObject(s);

        String code = object.getJSONArray("destinations").getJSONObject(0).optString("code");

        return Integer.valueOf(code);
    } catch (JSONException e1) {
        System.out.println("error parse error response, message: ");
        return -1;
    } catch (NumberFormatException e2) {
        System.out.println("error parse error response, invalid error code(non integer)!");
        return -1;
    }

}

From source file:com.hackathon.gavin.account.MyAccountGenerator.java

public static MyAccount createMyAccount() {
    JSONArray jSONArray = MyAccountParser.httpGetCall(urlString, jsonArrayName);
    ArrayList arrayList = MyAccountParser.convertToArrayList(jSONArray);

    int ID = Integer.valueOf(arrayList.get(0).toString());
    int UNITS = Integer.valueOf(arrayList.get(1).toString());
    String INSTRUMENT = arrayList.get(2).toString();
    double PRICE = Double.valueOf(arrayList.get(3).toString());
    MyAccount myAccount = new MyAccount(ID, UNITS, INSTRUMENT, PRICE);
    return myAccount;
}

From source file:Main.java

/**
 * /*from w  w w. j  a  v a  2 s  .  co  m*/
 * @param array
 * @return List<Integer>
 */
public static List<Integer> toList(final int[] array) {
    final List<Integer> list = new ArrayList<>();

    for (final int value : array) {
        list.add(Integer.valueOf(value));
    }

    return list;
}

From source file:Main.java

public static int[] getArgbValue(String color) {
    String[] colors = color.split(",");
    int[] icolors = new int[colors.length];
    if (icolors.length > 1)
        for (int i = 0; i < colors.length; i++) {
            icolors[i] = Integer.valueOf(colors[i].trim());
        }//  ww w  .jav  a2  s . c o  m
    return icolors;
}

From source file:Main.java

public static String getTotalMemory(Context context) {
    String str1 = "/proc/meminfo";
    String str2;//  www .  j  av  a 2s.  c  o  m
    String[] arrayOfString;
    long initial_memory = 0;
    try {
        FileReader localFileReader = new FileReader(str1);
        BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192);
        str2 = localBufferedReader.readLine();
        arrayOfString = str2.split("\\s+");
        //            for (String num : arrayOfString) {
        //                Log.i(str2, num + "\t");
        //            }
        initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024;
        localBufferedReader.close();
    } catch (IOException e) {
    }
    return Formatter.formatFileSize(context, initial_memory);
}

From source file:Main.java

private static boolean getBooleanFromDatabase(String isSolved) {
    // json stores booleans as true/false strings, whereas SQLite stores them as 0/1 values
    return null != isSolved && isSolved.length() == 1 && Integer.valueOf(isSolved) == 1;
}

From source file:Main.java

public static ArrayList<Integer> asList(int... arr) {
    ArrayList<Integer> list = new ArrayList<>(arr.length);
    for (int i = 0; i < arr.length; i++) {
        list.add(Integer.valueOf(arr[i]));
    }//from  w ww  . jav a2 s  . c  om
    return list;

}