@Test public void testConvertLinkFromLongValue() { Number number = Random.getLong(); String value = MessageFormat.format("{0}{1}", "@", number.toString()); Link link = (Link) Convert.stringToJava(value); Assert.assertEquals(number.longValue(), link.longValue()); }
public static Object stringToJava(String value) { if(value.isEmpty()) { return value; } char first = value.charAt(0); char last = value.charAt(value.length() - 1); Long record; if(AnyStrings.isWithinQuotes(value, TAG_MARKER)) { return value.substring(1, value.length() - 1); } else if(first == '@' && (record = Longs .tryParse(value.substring(1, value.length()))) != null) { return Link.to(record); } else if(first == '@' && last == '@' && STRING_RESOLVABLE_LINK_REGEX.matcher(value).matches()) { String ccl = value.substring(1, value.length() - 1); return ResolvableLink.create(ccl); } else if(value.equalsIgnoreCase("true")) { return true; } else if(value.equalsIgnoreCase("false")) { return false; } else if(first == TAG_MARKER && last == TAG_MARKER) { return Tag.create(value.substring(1, value.length() - 1)); } else if(first == '|' && last == '|') { value = value.substring(1, value.length() - 1); String[] toks = value.split("\\|"); Timestamp timestamp; if(toks.length == 1) { timestamp = Timestamp .fromMicros(NaturalLanguage.parseMicros(value)); } else { DateTimeFormatter formatter = DateTimeFormat .forPattern(toks[1]); timestamp = Timestamp.parse(toks[0], formatter); } return timestamp; } else { if(last == ')') { try { FunctionTree tree = (FunctionTree) ConcourseCompiler.get() .parse(value); FunctionValueSymbol symbol = (FunctionValueSymbol) tree .root(); return symbol.function(); } catch (Exception e) {} } try { return MoreObjects .firstNonNull(AnyStrings.tryParseNumber(value), value); } catch (NumberFormatException e) { return value; } } }
Convert { public static Object stringToJava(String value) { if(value.isEmpty()) { return value; } char first = value.charAt(0); char last = value.charAt(value.length() - 1); Long record; if(AnyStrings.isWithinQuotes(value, TAG_MARKER)) { return value.substring(1, value.length() - 1); } else if(first == '@' && (record = Longs .tryParse(value.substring(1, value.length()))) != null) { return Link.to(record); } else if(first == '@' && last == '@' && STRING_RESOLVABLE_LINK_REGEX.matcher(value).matches()) { String ccl = value.substring(1, value.length() - 1); return ResolvableLink.create(ccl); } else if(value.equalsIgnoreCase("true")) { return true; } else if(value.equalsIgnoreCase("false")) { return false; } else if(first == TAG_MARKER && last == TAG_MARKER) { return Tag.create(value.substring(1, value.length() - 1)); } else if(first == '|' && last == '|') { value = value.substring(1, value.length() - 1); String[] toks = value.split("\\|"); Timestamp timestamp; if(toks.length == 1) { timestamp = Timestamp .fromMicros(NaturalLanguage.parseMicros(value)); } else { DateTimeFormatter formatter = DateTimeFormat .forPattern(toks[1]); timestamp = Timestamp.parse(toks[0], formatter); } return timestamp; } else { if(last == ')') { try { FunctionTree tree = (FunctionTree) ConcourseCompiler.get() .parse(value); FunctionValueSymbol symbol = (FunctionValueSymbol) tree .root(); return symbol.function(); } catch (Exception e) {} } try { return MoreObjects .firstNonNull(AnyStrings.tryParseNumber(value), value); } catch (NumberFormatException e) { return value; } } } }
Convert { public static Object stringToJava(String value) { if(value.isEmpty()) { return value; } char first = value.charAt(0); char last = value.charAt(value.length() - 1); Long record; if(AnyStrings.isWithinQuotes(value, TAG_MARKER)) { return value.substring(1, value.length() - 1); } else if(first == '@' && (record = Longs .tryParse(value.substring(1, value.length()))) != null) { return Link.to(record); } else if(first == '@' && last == '@' && STRING_RESOLVABLE_LINK_REGEX.matcher(value).matches()) { String ccl = value.substring(1, value.length() - 1); return ResolvableLink.create(ccl); } else if(value.equalsIgnoreCase("true")) { return true; } else if(value.equalsIgnoreCase("false")) { return false; } else if(first == TAG_MARKER && last == TAG_MARKER) { return Tag.create(value.substring(1, value.length() - 1)); } else if(first == '|' && last == '|') { value = value.substring(1, value.length() - 1); String[] toks = value.split("\\|"); Timestamp timestamp; if(toks.length == 1) { timestamp = Timestamp .fromMicros(NaturalLanguage.parseMicros(value)); } else { DateTimeFormatter formatter = DateTimeFormat .forPattern(toks[1]); timestamp = Timestamp.parse(toks[0], formatter); } return timestamp; } else { if(last == ')') { try { FunctionTree tree = (FunctionTree) ConcourseCompiler.get() .parse(value); FunctionValueSymbol symbol = (FunctionValueSymbol) tree .root(); return symbol.function(); } catch (Exception e) {} } try { return MoreObjects .firstNonNull(AnyStrings.tryParseNumber(value), value); } catch (NumberFormatException e) { return value; } } } private  Convert(); }
Convert { public static Object stringToJava(String value) { if(value.isEmpty()) { return value; } char first = value.charAt(0); char last = value.charAt(value.length() - 1); Long record; if(AnyStrings.isWithinQuotes(value, TAG_MARKER)) { return value.substring(1, value.length() - 1); } else if(first == '@' && (record = Longs .tryParse(value.substring(1, value.length()))) != null) { return Link.to(record); } else if(first == '@' && last == '@' && STRING_RESOLVABLE_LINK_REGEX.matcher(value).matches()) { String ccl = value.substring(1, value.length() - 1); return ResolvableLink.create(ccl); } else if(value.equalsIgnoreCase("true")) { return true; } else if(value.equalsIgnoreCase("false")) { return false; } else if(first == TAG_MARKER && last == TAG_MARKER) { return Tag.create(value.substring(1, value.length() - 1)); } else if(first == '|' && last == '|') { value = value.substring(1, value.length() - 1); String[] toks = value.split("\\|"); Timestamp timestamp; if(toks.length == 1) { timestamp = Timestamp .fromMicros(NaturalLanguage.parseMicros(value)); } else { DateTimeFormatter formatter = DateTimeFormat .forPattern(toks[1]); timestamp = Timestamp.parse(toks[0], formatter); } return timestamp; } else { if(last == ')') { try { FunctionTree tree = (FunctionTree) ConcourseCompiler.get() .parse(value); FunctionValueSymbol symbol = (FunctionValueSymbol) tree .root(); return symbol.function(); } catch (Exception e) {} } try { return MoreObjects .firstNonNull(AnyStrings.tryParseNumber(value), value); } catch (NumberFormatException e) { return value; } } } private  Convert(); static List<Multimap<String, Object>> anyJsonToJava(String json); static TObject javaToThrift(Object object); static Multimap<String, Object> jsonToJava(String json); @SuppressWarnings("unchecked") static String mapsToJson(Collection<Multimap<String, Object>> list); static String mapToJson(Map<String, ?> map); static String mapToJson(Multimap<String, Object> map); static String operatorToString(Operator operator); @SuppressWarnings("unchecked") static T possibleThriftToJava(Object tobject); static Object stringToJava(String value); static Operator stringToOperator(String symbol); static String stringToResolvableLinkInstruction(String ccl); @Deprecated static String stringToResolvableLinkSpecification(String key,
            String rawValue); static Object thriftToJava(TObject object); static Object toFunctionOrUnescapedValueIfPossible(Object value); }
Convert { public static Object stringToJava(String value) { if(value.isEmpty()) { return value; } char first = value.charAt(0); char last = value.charAt(value.length() - 1); Long record; if(AnyStrings.isWithinQuotes(value, TAG_MARKER)) { return value.substring(1, value.length() - 1); } else if(first == '@' && (record = Longs .tryParse(value.substring(1, value.length()))) != null) { return Link.to(record); } else if(first == '@' && last == '@' && STRING_RESOLVABLE_LINK_REGEX.matcher(value).matches()) { String ccl = value.substring(1, value.length() - 1); return ResolvableLink.create(ccl); } else if(value.equalsIgnoreCase("true")) { return true; } else if(value.equalsIgnoreCase("false")) { return false; } else if(first == TAG_MARKER && last == TAG_MARKER) { return Tag.create(value.substring(1, value.length() - 1)); } else if(first == '|' && last == '|') { value = value.substring(1, value.length() - 1); String[] toks = value.split("\\|"); Timestamp timestamp; if(toks.length == 1) { timestamp = Timestamp .fromMicros(NaturalLanguage.parseMicros(value)); } else { DateTimeFormatter formatter = DateTimeFormat .forPattern(toks[1]); timestamp = Timestamp.parse(toks[0], formatter); } return timestamp; } else { if(last == ')') { try { FunctionTree tree = (FunctionTree) ConcourseCompiler.get() .parse(value); FunctionValueSymbol symbol = (FunctionValueSymbol) tree .root(); return symbol.function(); } catch (Exception e) {} } try { return MoreObjects .firstNonNull(AnyStrings.tryParseNumber(value), value); } catch (NumberFormatException e) { return value; } } } private  Convert(); static List<Multimap<String, Object>> anyJsonToJava(String json); static TObject javaToThrift(Object object); static Multimap<String, Object> jsonToJava(String json); @SuppressWarnings("unchecked") static String mapsToJson(Collection<Multimap<String, Object>> list); static String mapToJson(Map<String, ?> map); static String mapToJson(Multimap<String, Object> map); static String operatorToString(Operator operator); @SuppressWarnings("unchecked") static T possibleThriftToJava(Object tobject); static Object stringToJava(String value); static Operator stringToOperator(String symbol); static String stringToResolvableLinkInstruction(String ccl); @Deprecated static String stringToResolvableLinkSpecification(String key,
            String rawValue); static Object thriftToJava(TObject object); static Object toFunctionOrUnescapedValueIfPossible(Object value);  }