List of usage examples for java.lang Integer valueOf
@HotSpotIntrinsicCandidate public static Integer valueOf(int i)
From source file:Main.java
public static int[] splitToIntArray(String s) { int ai1[];/*from w w w. ja v a2s . c om*/ if (s == null) { ai1 = null; } else { String as[] = s.split(":"); ArrayList arraylist = new ArrayList(); int i = as.length; int j = 0; do { if (j >= i) break; String s1 = as[j]; if (s1 != null && s1.length() > 0) try { arraylist.add(Integer.valueOf(Integer.valueOf(s1).intValue())); } catch (Exception exception) { exception.printStackTrace(); Log.e("MicroMsg.Util", "invalid port num, ignore"); } j++; } while (true); int ai[] = new int[arraylist.size()]; for (int k = 0; k < ai.length; k++) ai[k] = ((Integer) arraylist.get(k)).intValue(); ai1 = ai; } return ai1; }
From source file:Main.java
public static int selectIntElement(Element parent, String elementName) { String result = selectStringElement(parent, elementName, "0"); return Integer.valueOf(result); }
From source file:Main.java
@SuppressWarnings("unchecked") public static <T> T getPref(Context _context, String prefKey, T defValue, Class<T> clazz) { final SharedPreferences pref = getDefaultSharedPreferences(_context); if (Long.class == clazz) { return (T) (Long.valueOf(pref.getLong(prefKey, (Long) defValue))); } else if (Integer.class == clazz) { return (T) (Integer.valueOf(pref.getInt(prefKey, (Integer) defValue))); } else if (defValue instanceof String) { return (T) (pref.getString(prefKey, String.valueOf(defValue))); } else if (defValue instanceof Boolean) { return (T) (Boolean.valueOf(pref.getBoolean(prefKey, (Boolean) defValue))); }/*from w w w . j av a 2s . c o m*/ throw new UnsupportedOperationException("Class " + clazz + " not supported"); }
From source file:Main.java
public static long getTotalMemoryPreJB() { String str1 = "/proc/meminfo"; String str2;//from w w w .j a v a 2 s .co m String[] arrayOfString; long initial_memory = 0; try { FileReader localFileReader = new FileReader(str1); BufferedReader localBufferedReader = new BufferedReader(localFileReader, 8192); str2 = localBufferedReader.readLine();//meminfo arrayOfString = str2.split("\\s+"); initial_memory = Integer.valueOf(arrayOfString[1]).intValue() * 1024; localBufferedReader.close(); return initial_memory; } catch (IOException e) { return -1; } }
From source file:Main.java
private static int readLineNumber(String line) { int start = line.indexOf("line="); //$NON-NLS-1$ return Integer.valueOf(line.substring(start + 5)); }
From source file:Main.java
/** * <p>Extract integer values from an array of strings into an array of int.</p> * * <p>Exceptions in the format of the string are trapped and 0 value(s) returned.</p> * * @param src an array of strings, each of which should be an integer numeric value * @return an array of int/* w w w. java2 s . c o m*/ */ static public int[] copyStringToIntArray(String[] src) { if (src == null) return null; int n = src.length; int[] dst = new int[n]; for (int j = 0; j < n; ++j) { int value = 0; try { value = Integer.valueOf(src[j]).intValue(); } catch (NumberFormatException e) { } catch (NullPointerException e) { } dst[j] = value; } return dst; }
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 ("java.lang.Long".equals(type)) result.add(Long.valueOf(value)); else if ("java.lang.Integer".equals(type)) result.add(Integer.valueOf(value)); else {//w ww .ja va2s .c o m result.add(value); } } return result.toArray(); }
From source file:Main.java
public static ArrayList<Integer> asIntegerList(String[] stringArray) { ArrayList<Integer> result = new ArrayList<Integer>(); if (stringArray != null) { for (String string : stringArray) { result.add(Integer.valueOf(string)); }/*from w w w . j av a 2 s . c om*/ } return result; }
From source file:Main.java
public static int[] parseIntegerList(String list, int minValue, int maxValue) { ArrayList tmpList = new ArrayList(); Pattern p = Pattern.compile("(\\d*)-(\\d*)"); String[] a = list.replace(',', ' ').split("\\s+"); int i = a.length; for (int i$ = 0; i$ < i; ++i$) { String token = a[i$];//from w ww. j a va 2 s . c om try { if (token.matches("\\d+")) { tmpList.add(Integer.valueOf(Integer.parseInt(token))); } else { Matcher e = p.matcher(token); if (e.matches()) { String a1 = e.group(1); String b = e.group(2); int min = a1.equals("") ? minValue : Integer.parseInt(a1); int max = b.equals("") ? maxValue : Integer.parseInt(b); for (int i1 = min; i1 <= max; ++i1) { tmpList.add(Integer.valueOf(i1)); } } } } catch (NumberFormatException var15) { ; } } if (minValue <= maxValue) { int var16 = 0; while (var16 < tmpList.size()) { if (((Integer) tmpList.get(var16)).intValue() >= minValue && ((Integer) tmpList.get(var16)).intValue() <= maxValue) { ++var16; } else { tmpList.remove(var16); } } } int[] var17 = new int[tmpList.size()]; for (i = 0; i < var17.length; ++i) { var17[i] = ((Integer) tmpList.get(i)).intValue(); } return var17; }
From source file:Main.java
/** * Set the text component in which only numerics (positive decimal integers * with character 0-9)./*ww w .j a v a 2 s . c o m*/ * * @param c * the specified text component */ public static void setTextComponetIntegerValid(final JTextComponent c) { c.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if (e.getKeyChar() != KeyEvent.VK_BACK_SPACE) try { Integer.valueOf(c.getText() + e.getKeyChar()); } catch (NumberFormatException nfe) { e.consume(); Toolkit.getDefaultToolkit().beep(); } } }); }