@Test public void testGetImapRangeValues() { String[] expected; List<String> actual; expected = new String[] {"1", "2", "3"}; actual = ImapUtility.getImapRangeValues("1:3"); assertArrayEquals(expected, actual.toArray()); expected = new String[] {"16", "15", "14"}; actual = ImapUtility.getImapRangeValues("16:14"); assertArrayEquals(expected, actual.toArray()); expected = new String[0]; actual = ImapUtility.getImapRangeValues(""); assertArrayEquals(expected, actual.toArray()); expected = new String[0]; actual = ImapUtility.getImapRangeValues(null); assertArrayEquals(expected, actual.toArray()); expected = new String[0]; actual = ImapUtility.getImapRangeValues("a"); assertArrayEquals(expected, actual.toArray()); expected = new String[0]; actual = ImapUtility.getImapRangeValues("6"); assertArrayEquals(expected, actual.toArray()); expected = new String[0]; actual = ImapUtility.getImapRangeValues("1:3,6"); assertArrayEquals(expected, actual.toArray()); expected = new String[0]; actual = ImapUtility.getImapRangeValues("1:x"); assertArrayEquals(expected, actual.toArray()); expected = new String[0]; actual = ImapUtility.getImapRangeValues("1:*"); assertArrayEquals(expected, actual.toArray()); }
public static List<String> getImapRangeValues(String range) { List<String> list = new ArrayList<String>(); try { if (range != null) { int colonPos = range.indexOf(':'); if (colonPos > 0) { long first = Long.parseLong(range.substring(0, colonPos)); long second = Long.parseLong(range.substring(colonPos + 1)); if (is32bitValue(first) && is32bitValue(second)) { if (first < second) { for (long i = first; i <= second; i++) { list.add(Long.toString(i)); } } else { for (long i = first; i >= second; i--) { list.add(Long.toString(i)); } } } else { Timber.d("Invalid range: %s", range); } } } } catch (NumberFormatException e) { Timber.d(e, "Invalid range value: %s", range); } return list; }
ImapUtility { public static List<String> getImapRangeValues(String range) { List<String> list = new ArrayList<String>(); try { if (range != null) { int colonPos = range.indexOf(':'); if (colonPos > 0) { long first = Long.parseLong(range.substring(0, colonPos)); long second = Long.parseLong(range.substring(colonPos + 1)); if (is32bitValue(first) && is32bitValue(second)) { if (first < second) { for (long i = first; i <= second; i++) { list.add(Long.toString(i)); } } else { for (long i = first; i >= second; i--) { list.add(Long.toString(i)); } } } else { Timber.d("Invalid range: %s", range); } } } } catch (NumberFormatException e) { Timber.d(e, "Invalid range value: %s", range); } return list; } }
ImapUtility { public static List<String> getImapRangeValues(String range) { List<String> list = new ArrayList<String>(); try { if (range != null) { int colonPos = range.indexOf(':'); if (colonPos > 0) { long first = Long.parseLong(range.substring(0, colonPos)); long second = Long.parseLong(range.substring(colonPos + 1)); if (is32bitValue(first) && is32bitValue(second)) { if (first < second) { for (long i = first; i <= second; i++) { list.add(Long.toString(i)); } } else { for (long i = first; i >= second; i--) { list.add(Long.toString(i)); } } } else { Timber.d("Invalid range: %s", range); } } } } catch (NumberFormatException e) { Timber.d(e, "Invalid range value: %s", range); } return list; }  }
ImapUtility { public static List<String> getImapRangeValues(String range) { List<String> list = new ArrayList<String>(); try { if (range != null) { int colonPos = range.indexOf(':'); if (colonPos > 0) { long first = Long.parseLong(range.substring(0, colonPos)); long second = Long.parseLong(range.substring(colonPos + 1)); if (is32bitValue(first) && is32bitValue(second)) { if (first < second) { for (long i = first; i <= second; i++) { list.add(Long.toString(i)); } } else { for (long i = first; i >= second; i--) { list.add(Long.toString(i)); } } } else { Timber.d("Invalid range: %s", range); } } } } catch (NumberFormatException e) { Timber.d(e, "Invalid range value: %s", range); } return list; }  static List<String> getImapSequenceValues(String set); static List<String> getImapRangeValues(String range); static String encodeString(String str); static ImapResponse getLastResponse(List<ImapResponse> responses); }
ImapUtility { public static List<String> getImapRangeValues(String range) { List<String> list = new ArrayList<String>(); try { if (range != null) { int colonPos = range.indexOf(':'); if (colonPos > 0) { long first = Long.parseLong(range.substring(0, colonPos)); long second = Long.parseLong(range.substring(colonPos + 1)); if (is32bitValue(first) && is32bitValue(second)) { if (first < second) { for (long i = first; i <= second; i++) { list.add(Long.toString(i)); } } else { for (long i = first; i >= second; i--) { list.add(Long.toString(i)); } } } else { Timber.d("Invalid range: %s", range); } } } } catch (NumberFormatException e) { Timber.d(e, "Invalid range value: %s", range); } return list; }  static List<String> getImapSequenceValues(String set); static List<String> getImapRangeValues(String range); static String encodeString(String str); static ImapResponse getLastResponse(List<ImapResponse> responses);  }