List of utility methods to do Integer Create
long[] | toIntegerArray(String text, String delimiter) split a text into array of integers if (text == null || text.length() == 0) { return new long[0]; String[] textArray = text.split(delimiter); long[] arr = new long[textArray.length]; for (int i = 0; i < arr.length; i++) { try { arr[i] = Long.parseLong(textArray[i]); ... |
Integer[] | toIntegerArray(String... values) to Integer Array if (values == null) { return new Integer[0]; Integer[] casted = new Integer[values.length]; for (int i = 0; i < casted.length; i++) { casted[i] = Integer.parseInt(values[i]); return casted; ... |
Integer | toIntegerByObject(Object obj) to Integer By Object try { return Integer.valueOf(toStringByObject(obj, true)); } catch (Exception e) { return 0; |
Integer | toIntegerFromObj(Object obj) Tenta transformar um obj em inteiro, caso nao consiga retorna null try { return obj != null ? new Integer(obj.toString()) : null; } catch (Exception e) { return null; |
Integer | toIntegerObject(boolean bool) Converts a boolean to an Integer using the convention that BooleanUtils.toIntegerObject(true) = new Integer(1) BooleanUtils.toIntegerObject(false) = new Integer(0) return (bool ? INTEGER_ONE : INTEGER_ZERO);
|
Integer | toIntegerObject(Boolean bool, Integer trueValue, Integer falseValue, Integer nullValue) Converts a Boolean to an Integer specifying the conversion values. BooleanUtils.toIntegerObject(Boolean.TRUE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(1) BooleanUtils.toIntegerObject(Boolean.FALSE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(0) BooleanUtils.toIntegerObject(null, new Integer(1), new Integer(0), new Integer(2)) = new Integer(2) if (bool == null) { return nullValue; return bool.booleanValue() ? trueValue : falseValue; |
Integer | toIntegerOrNull(String s) to Integer Or Null return s == null ? null : Integer.valueOf(s);
|
Integer[] | toIntegers(String[] values) to Integers return toIntegers(values, null);
|
int | toIntegerValue(byte... bytes) to Integer Value return toIntegerValue(bytes, 0, bytes.length);
|
int | toIntegerValue(String value) to Integer Value try { return Float.valueOf(value).intValue(); } catch (NumberFormatException e) { e.printStackTrace(); finally { return 0; ... |