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 getComboBoxIntegerValue(ComboBox<String> comboBox) {
    return comboBox.getValue() == null ? Integer.valueOf(comboBox.getPromptText())
            : Integer.valueOf(comboBox.getSelectionModel().getSelectedItem());
}

From source file:Main.java

public static boolean verifyIntegerTextField(JTextField field) {
    try {//from  w  ww .  j  a  va 2  s.  co  m
        Integer.valueOf(field.getText());
        field.setBackground(Color.WHITE);
    } catch (NumberFormatException e) {
        field.setBackground(Color.LIGHT_GRAY);
        return false;
    }

    return true;
}

From source file:Main.java

public static <T extends Comparable<T>> int compareLists(List<? extends T> a, List<? extends T> b) {
    int cmp = Integer.valueOf(a.size()).compareTo(Integer.valueOf(b.size()));
    if (cmp != 0) {
        return cmp;
    }//w w w .j  ava  2s  .  c o  m

    for (int i = 0; i < a.size(); ++i) {
        cmp = a.get(i).compareTo(b.get(i));
        if (cmp != 0) {
            return cmp;
        }
    }

    return 0;
}

From source file:Main.java

public static int getIntValue(Element paramElement) {
    return Integer.valueOf(getText(paramElement)).intValue();
}

From source file:Main.java

private static Integer transformToInt(String v) {
    if (v != null) {
        try {// w  w w  .java2  s  .  c  o  m
            return Integer.valueOf(v);
        } catch (NumberFormatException e) {
            return 0;
        }
    } else {
        return 0;
    }
}

From source file:Main.java

private static boolean isAllNum(String str) {
    if (!TextUtils.isEmpty(str)) {
        try {//from  ww w.  j  a  va  2  s  .  com
            Integer.valueOf(str);
            return true;
        } catch (Exception e) {

        }
    }

    return false;
}

From source file:Main.java

public static Integer getInt(String orgin, Integer def) {
    if (orgin == null || orgin.equals(""))
        return null;
    try {// w  w w .ja  v  a 2  s  .c  o  m
        return Integer.valueOf(orgin);
    } catch (Exception e) {
        return def;
    }
}

From source file:Main.java

public static boolean isSdkVersionValid() {
    int sdkVersion = 0;
    try {/*from w  w  w.j ava 2s .  c o m*/
        sdkVersion = Integer.valueOf(android.os.Build.VERSION.SDK);
    } catch (NumberFormatException e) {
    }
    if (sdkVersion <= MIN_SDK_VERSION)
        return false;
    else
        return true;
}

From source file:Main.java

public static int getValueByInt(String value) {
    int result = 0;
    if (value != null && !value.equals("")) {
        try {/*w  w w.j av  a  2  s  . co  m*/
            result = Integer.valueOf(value);
        } catch (NumberFormatException e) {

        }
    }
    return result;
}

From source file:Main.java

private static int createKeyOfMid(String mid) {
    //String midNum = DownloadHelper.changeHashidToNumStr(mid);
    int key = -1;
    try {/*from   ww  w.  j a  v  a2s .  c o  m*/
        key = Integer.valueOf(mid);
    } catch (NumberFormatException e) {
        key = -1;
    }
    return key;
}