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

/**
 * Calculate modulo 10 checksom of GTIN//from  w  ww.  j a  v  a 2  s.c o m
 *
 * @param gtin GTIN
 * @return Checksum
 */
private static Integer calculateChecksum(String gtin) {
    Integer sum = 0;
    for (int i = 0; i < gtin.length(); i++) {
        Integer temp = Integer.valueOf(gtin.substring(gtin.length() - i - 1, gtin.length() - i));
        if ((i % 2) == 0) {
            sum += (temp * 3);
        } else {
            sum += (temp);
        }
    }
    return (sum % 10);
}

From source file:Main.java

public static Uri getSongUri(int id) {
    String albumId = String.valueOf(id);
    Uri sArtworkUri = Uri.parse("content://media/external/audio/albumart");
    Uri albumArtUri = ContentUris.withAppendedId(sArtworkUri, Integer.valueOf(albumId));
    return albumArtUri;
}

From source file:Main.java

public static int convertToInteger(String data) {
    BigDecimal num = new BigDecimal(data).setScale(NUM_AFTER_COM, BigDecimal.ROUND_HALF_UP);
    String res = num.toString().replace(".", "");
    return Integer.valueOf(res);
}

From source file:Main.java

public static void addStars(String creditworthiness, LinearLayout container, Activity activity,
        int drawableResId) {
    int cre = Integer.valueOf(creditworthiness);
    addStars(cre, container, activity, drawableResId);

}

From source file:Main.java

private static List<Integer> getElement(int number) {
    List<Integer> result = new ArrayList();
    for (int i = 0; i < 32; i++) {
        int b = 1 << i;
        if ((number & b) > 0) {
            result.add(Integer.valueOf(b));
        }//  w w  w  . j  a va 2s .c om
    }
    return result;
}

From source file:Main.java

public static int[] getAntennaTestData(String rotation, String funCode) {
    List<Integer> dateItem = new ArrayList();
    dateItem.add(Integer.valueOf(funCode));
    int intStep = Integer.valueOf(rotation) * 10;
    String hexStep = Integer.toHexString(intStep);

    if (hexStep.length() < 4) {
        switch (hexStep.length()) {
        case 1:/*from w w w .j  a v  a  2 s.  c  o m*/
            hexStep = "000" + hexStep;
            break;
        case 2:
            hexStep = "00" + hexStep;
            break;
        case 3:
            hexStep = "0" + hexStep;
            break;
        }
    }
    dateItem.add(Integer.valueOf(hexStep.substring(2, 4), 16));
    dateItem.add(Integer.valueOf(hexStep.substring(0, 2), 16));
    for (int i = 0; i < 6; i++) {
        dateItem.add(0);
    }

    int[] message = new int[dateItem.size()];
    for (int i = 0; i < dateItem.size(); i++) {
        message[i] = dateItem.get(i);
    }

    return message;

}

From source file:Main.java

public static List<Integer> convertStringNumberToList(String stringNumber) {
    List<Integer> rtn = new ArrayList<>();
    String[] splitString = stringNumber.split("[^0-9]+");
    for (String str : splitString) {
        rtn.add(Integer.valueOf(str));
    }//from   ww  w.  j ava  2  s  . co m
    return rtn;
}

From source file:Main.java

/**
 * Creates an integer range 0,1,2,...,n-1.
 *
 * @param n the length of the range//from  w ww . ja v  a 2 s . co m
 * @return the range
 */
public static Integer[] createIntegerRange(final int n) {
    final Integer[] range = new Integer[n];
    for (int i = 0; i < n; i++) {
        range[i] = Integer.valueOf(i);
    }
    return range;
}

From source file:Main.java

public static void addErrorMap(String mes) {
    if (errorMap == null) {
        errorMap = new HashMap<String, String>();
    }//from  w w  w .  j  a v  a 2 s. co m

    if (errorMap.containsKey(mes)) {
        int count = Integer.valueOf(errorMap.get(mes));

        errorMap.remove(mes);
        errorMap.put(mes, String.valueOf(++count));
    } else {
        errorMap.put(mes, "1");
    }
}

From source file:Main.java

public static ArrayList<Calendar> formatTimesForObject(String string) {
    ArrayList<Calendar> times = new ArrayList<>();
    for (String s : string.split(" ")) {
        int hour = Integer.valueOf(s.split(":")[0]);
        int minute = Integer.valueOf(s.split(":")[1]);

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.HOUR_OF_DAY, hour);
        calendar.set(Calendar.MINUTE, minute);
        times.add(calendar);/*w w  w. j a  v a 2 s.  c  o m*/
    }
    return times;
}