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:com.editor.SkillEditor.java

@Override
public void setAsText(String text) {
    Skill s = this.skillService.getSkill(Integer.valueOf(text));
    this.setValue(s);
}

From source file:Main.java

/**
 * Tries to parse the given string into an int, returning
 * <code>defaultValue</code> if the string can not be parsed.
 * //from  w w  w. jav  a  2  s  .  co m
 * @param value
 *            The string to parse
 * @param defaultValue
 *            The value to return if the string can not be parsed.
 * @return The parsed int, or <code>defaultValue</code>
 */
public static int safeParseInt(String value, int defaultValue) {
    try {
        return Integer.valueOf(value);
    } catch (NumberFormatException nfe1) {
        return defaultValue;
    }
}

From source file:Main.java

public static int getVersion(Context context) {

    int ver = -1;
    String str = Build.DISPLAY;/*from www  .  ja  v  a 2  s .  c o  m*/
    if (TextUtils.isEmpty(str) || !str.toLowerCase().contains("flyme")) {
        return -1;
    }
    try {
        String[] split = str.replaceAll(" ", "").toLowerCase().split("\\.");
        if (split.length < 2) {
            return -1;
        }
        try {
            return (Integer.valueOf(split[0].substring(split[0].length() - 1)).intValue() * 10)
                    + Integer.valueOf(split[1].substring(0, 1)).intValue();
        } catch (Exception e) {

            ver = -1;
            return ver;
        }
    } catch (Exception e2) {
        return ver;
    }
}

From source file:Main.java

/**
 * Tries to parse the given string into an long, returning
 * <code>defaultValue</code> if the string can not be parsed.
 * /*from   www  . j  ava  2  s .c o  m*/
 * @param value
 *            The string to parse
 * @param defaultValue
 *            The value to return if the string can not be parsed.
 * @return The parsed long, or <code>defaultValue</code>
 */
public static long safeParseLong(String value, long defaultValue) {
    try {
        return Integer.valueOf(value);
    } catch (NumberFormatException nfe1) {
        return defaultValue;
    }
}

From source file:com.editor.CompanyEditor.java

@Override
public void setAsText(String text) {
    Company c = this.companyService.getCompany(Integer.valueOf(text));
    this.setValue(c);
}

From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java

/**
 * ?,?,/*from w ww .  ja  v a 2 s.c  o  m*/
 * 
 * @param clazz
 * @return
 */
@SuppressWarnings("unchecked")
private static <T> T getInternalDefaultValue(Class<T> clazz) {
    if (!clazz.isPrimitive()) {
        return null;
    }
    if (Short.TYPE.equals(clazz)) {
        return (T) Short.valueOf((short) 0);
    }
    if (Integer.TYPE.equals(clazz)) {
        return (T) Integer.valueOf(0);
    }
    if (Long.TYPE.equals(clazz)) {
        return (T) Long.valueOf(0);
    }
    if (Boolean.TYPE.equals(clazz)) {
        return (T) Boolean.valueOf(false);
    }
    if (Float.TYPE.equals(clazz)) {
        return (T) Float.valueOf(0);
    }
    if (Double.TYPE.equals(clazz)) {
        return (T) Double.valueOf(0);
    }
    if (Byte.TYPE.equals(clazz)) {
        return (T) Byte.valueOf((byte) 0);
    }
    if (Character.TYPE.equals(clazz)) {
        return (T) Character.valueOf('\0');
    }
    return null;
}

From source file:uk.ac.ebi.eva.utils.ConnectionHelper.java

public static List<ServerAddress> parseServerAddresses(String hosts) throws UnknownHostException {
    List<ServerAddress> serverAddresses = new LinkedList<>();
    for (String hostPort : hosts.split(",")) {
        if (hostPort.contains(":")) {
            String[] split = hostPort.split(":");
            Integer port = Integer.valueOf(split[1]);
            serverAddresses.add(new ServerAddress(split[0], port));
        } else {//from ww  w. j ava 2 s  . c o m
            serverAddresses.add(new ServerAddress(hostPort, 27017));
        }
    }
    return serverAddresses;
}

From source file:Main.java

private SortedSet<Integer> getSet(String str) {
    SortedSet<Integer> result = new TreeSet<Integer>();
    StringTokenizer st = new StringTokenizer(str, " ");
    while (st.hasMoreTokens()) {
        result.add(Integer.valueOf(st.nextToken()));
    }/*from w  ww  .  java2s .co  m*/
    return result;
}

From source file:com.editor.EmployeeEditor.java

@Override
public void setAsText(String text) {
    Employee employee = this.employeeService.getEmployee(Integer.valueOf(text));
    this.setValue(employee);
}

From source file:gov.nyc.doitt.gis.geoclient.service.domain.Borough.java

public static int parseInt(String boroughString) {
    if (NumberUtils.isNumber(boroughString)) {
        return Integer.valueOf(boroughString);
    }/*ww w .ja  v a2 s .c  om*/

    for (Map.Entry<String, Integer> entry : NAMES.entrySet()) {
        if (entry.getKey().equalsIgnoreCase(boroughString)) {
            return entry.getValue();
        }
    }

    return 0;
}