@Test public void test_fromAlpha(@Values("DATA") Pair<String, Integer> data) { assertThat(AlphaIndex.fromAlpha(data.a), is(data.b.longValue())); }
public static long fromAlpha(String s) { s = s.trim().toUpperCase(); if (s.isEmpty()) throw new IllegalArgumentException( "Empty string not allowed"); long result = 0; for (char c: s.toCharArray()) { if (c < 'A' || c > 'Z') throw new IllegalArgumentException( "Invalid character '" + c + "'"); result = result*26 + (c - 'A' + 1); if (result < 0) throw new IllegalArgumentException( "\"" + s + "\" is too large."); } return result-1; }
AlphaIndex { public static long fromAlpha(String s) { s = s.trim().toUpperCase(); if (s.isEmpty()) throw new IllegalArgumentException( "Empty string not allowed"); long result = 0; for (char c: s.toCharArray()) { if (c < 'A' || c > 'Z') throw new IllegalArgumentException( "Invalid character '" + c + "'"); result = result*26 + (c - 'A' + 1); if (result < 0) throw new IllegalArgumentException( "\"" + s + "\" is too large."); } return result-1; } }
AlphaIndex { public static long fromAlpha(String s) { s = s.trim().toUpperCase(); if (s.isEmpty()) throw new IllegalArgumentException( "Empty string not allowed"); long result = 0; for (char c: s.toCharArray()) { if (c < 'A' || c > 'Z') throw new IllegalArgumentException( "Invalid character '" + c + "'"); result = result*26 + (c - 'A' + 1); if (result < 0) throw new IllegalArgumentException( "\"" + s + "\" is too large."); } return result-1; }  }
AlphaIndex { public static long fromAlpha(String s) { s = s.trim().toUpperCase(); if (s.isEmpty()) throw new IllegalArgumentException( "Empty string not allowed"); long result = 0; for (char c: s.toCharArray()) { if (c < 'A' || c > 'Z') throw new IllegalArgumentException( "Invalid character '" + c + "'"); result = result*26 + (c - 'A' + 1); if (result < 0) throw new IllegalArgumentException( "\"" + s + "\" is too large."); } return result-1; }  static String toAlpha(long i); static String toAlpha(long i, boolean uppercase); static long fromAlpha(String s); static String toAlpha1(long i); static String toAlpha1(long i, boolean uppercase); static long fromAlpha1(String s); }
AlphaIndex { public static long fromAlpha(String s) { s = s.trim().toUpperCase(); if (s.isEmpty()) throw new IllegalArgumentException( "Empty string not allowed"); long result = 0; for (char c: s.toCharArray()) { if (c < 'A' || c > 'Z') throw new IllegalArgumentException( "Invalid character '" + c + "'"); result = result*26 + (c - 'A' + 1); if (result < 0) throw new IllegalArgumentException( "\"" + s + "\" is too large."); } return result-1; }  static String toAlpha(long i); static String toAlpha(long i, boolean uppercase); static long fromAlpha(String s); static String toAlpha1(long i); static String toAlpha1(long i, boolean uppercase); static long fromAlpha1(String s);  }