GeneralUtils { public static long toPositiveLong(CharSequence seq, int pos, int length) { long n = 0; int i = pos; while (i < length) { char c = seq.charAt(i); if (c >= '0' && c <= '9') { n *= 10; n += (int)(c - '0'); } else { break; } i++; } return n; } private  GeneralUtils(); static long toPositiveLong(CharSequence seq, int pos, int length); static Decimal nodeToDecimal(JsonNode node); static BigDecimal nodeToBigDecimal(JsonNode node); static JsonNode executeTemplate(Context ctx, Instruction inst, JsonNode node, boolean privateContext); static JsonNode executeTemplate(Context ctx, Instruction inst, JsonNode node, boolean privateContext,
        ObjectNode argvar); static String loadResource(Class<?> cls, String path); static List<Path> listResources(Class<?> cls, String pattern); static V getOrDefault(Map<K, V> map, K key, V defaultValue); static String localizeOrDefault(JsonNode localizedStrings, String key, String defaultValue); static boolean isJsonStart(String raw); static JsonNode getFirstMatchingNode(JsonNode parent, String... keys); static String jsonPretty(JsonNode node); static Object[] splitVariable(String name); static String urlEncode(String val); static boolean isTruthy(JsonNode node); static String ifString(JsonNode node, String defaultString); static double ifDouble(JsonNode node, double defaultValue); static String eatNull(JsonNode node);  }
@Test public void testToLong() { assertEquals(toPositiveLong("12345", 0, 5), 12345); assertEquals(toPositiveLong("12345xyz", 0, 8), 12345); assertEquals(toPositiveLong("xyz", 0, 3), 0); assertEquals(toPositiveLong(" ", 0, 3), 0); }