List of usage examples for java.lang Integer valueOf
@HotSpotIntrinsicCandidate public static Integer valueOf(int i)
From source file:Main.java
public static Integer asInteger(Object value, int def) { if (value instanceof Number) { return Integer.valueOf(((Number) value).intValue()); } else {//from ww w . j a v a 2 s . c om try { return Integer.valueOf(value.toString()); } catch (NumberFormatException ex) { return Integer.valueOf(def); } } }
From source file:Main.java
public static Integer getInt(String key, int defVal) { return Integer.valueOf(sp.getInt(key, defVal)); }
From source file:Main.java
public static List<String> getLettersFromMotId(String motId) { List<String> res = new ArrayList<String>(); for (int i = 0; i < motId.length(); i = i + 2) { int nbLetters = Integer.valueOf(String.valueOf(motId.charAt(i))); for (int k = 0; k < nbLetters; k++) { res.add(String.valueOf(motId.charAt(i + 1))); }//from w w w . j a va 2s . co m } return res; }
From source file:Main.java
public static boolean isSystemLayoutId(int id) { return sSystemLayoutResIds.containsKey(Integer.valueOf(id)); }
From source file:Main.java
/** * Converts a byte to an int, preserving the sign. * * For example, FF will be converted to 255 and not -1. * * @param bite the bite//from w w w . j a v a2s. co m * @return the int from byte */ public static int getIntFromByte(final byte bite) { return Integer.valueOf(bite & 0xFF); }
From source file:Main.java
public static String padWithZerosToMaxIntWidth(int paramInt) { if (paramInt < 0) { throw new IllegalArgumentException("value must be zero or greater"); }/*w w w .ja v a 2s. co m*/ return String.format(Locale.US, "%1$10s", new Object[] { Integer.valueOf(paramInt) }).replace(' ', '0'); }
From source file:Main.java
/** * Helper method used to get default value for wrappers used for primitive types * (0 for Integer etc)/* ww w .ja v a2 s. c om*/ */ public static Object defaultValue(Class<?> cls) { if (cls == Integer.TYPE) { return Integer.valueOf(0); } if (cls == Long.TYPE) { return Long.valueOf(0L); } if (cls == Boolean.TYPE) { return Boolean.FALSE; } if (cls == Double.TYPE) { return Double.valueOf(0.0); } if (cls == Float.TYPE) { return Float.valueOf(0.0f); } if (cls == Byte.TYPE) { return Byte.valueOf((byte) 0); } if (cls == Short.TYPE) { return Short.valueOf((short) 0); } if (cls == Character.TYPE) { return '\0'; } throw new IllegalArgumentException("Class " + cls.getName() + " is not a primitive type"); }
From source file:Main.java
public static String encodeHexString(byte abyte0[]) { StringBuilder stringbuilder = new StringBuilder(""); if (abyte0 != null) { for (int i = 0; i < abyte0.length; i++) { Object aobj[] = new Object[1]; aobj[0] = Integer.valueOf(0xff & abyte0[i]); stringbuilder.append(String.format("%02x", aobj)); }//from w w w. j a va 2 s . co m } return stringbuilder.toString(); }
From source file:Main.java
public static int getArgInteger(final NodeList args, final String strName) { final String strValue = getArg(args, strName, null); return Integer.valueOf(strValue); }
From source file:Main.java
public static int[] getStepData(String step, String funCode) { List<Integer> dateItem = new ArrayList(); dateItem.add(Integer.valueOf(funCode)); int intStep = Integer.valueOf(step) * 100; String hexStep = Integer.toHexString(intStep); if (hexStep.length() < 4) { switch (hexStep.length()) { case 1:/*from www .j a va2 s . com*/ 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; }