Object sourceRef = jp.getTokenLocation().getSourceRef(); if (sourceRef instanceof byte[]) { validateChecksum((byte[]) sourceRef, start, end, context);
@Override public String getSystemId() { if (location.getSourceRef() instanceof File) { return ((File)location.getSourceRef()).toURI().toASCIIString(); } if (location.getSourceRef() instanceof URL) { return ((URL)location.getSourceRef()).toExternalForm(); } return null; } }
@Override public String getPublicId() { Object sourceRef = jsonParser.getCurrentLocation().getSourceRef(); if (sourceRef != null) { return sourceRef.toString(); } else { return ""; } }
public String getPublicId() { Object sourceRef = jsonParser.getCurrentLocation().getSourceRef(); if (sourceRef != null) { return sourceRef.toString(); } else { return ""; } }
public static void toStringLocation(StringBuilder buf, JsonLocation location) { Object sourceRef = location.getSourceRef(); if (sourceRef instanceof File) { File f = (File) sourceRef; buf.append(f.getPath()); buf.append(": "); } buf.append(location.getLineNr()); buf.append("."); buf.append(location.getColumnNr()); }
public class MessageDeserializer extends JsonDeserializer<Message> { private final Pattern NAME_PATTERN = Pattern.compile(".*?(\"?)name(\"?)[\\s]*:[\\s]*(\".*\").*?"); private final Pattern DATE_PATTERN = Pattern.compile(".*?TxnDateUTC:\"?([A-Za-z0-9\\-:]{20}).*?"); @Override public Message deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException { JsonLocation currentLocation = jp.getCurrentLocation(); String jsonString = (String) currentLocation.getSourceRef(); Matcher nameMatcher = NAME_PATTERN.matcher(jsonString); String name = ""; if ( nameMatcher.matches() && nameMatcher.groupCount() == 3 ){ name = nameMatcher.group(3); } Matcher dateMatcher = DATE_PATTERN.matcher(jsonString); String date = ""; if ( dateMatcher.matches() && dateMatcher.groupCount() == 1 ){ date = dateMatcher.group(1); } return new Message(name, date); } }
default SourceMap toSourceMap(YamlStep step, String description) { JsonLocation l = step.getLocation(); return new SourceMap(Significance.HIGH, String.valueOf(l.getSourceRef()), l.getLineNr(), l.getColumnNr(), description); }
@SuppressWarnings("unchecked") private static List<Trigger> convertTriggers(List<YamlTrigger> triggers) { if (triggers == null || triggers.isEmpty()) { return null; } List<Trigger> result = new ArrayList<>(); for (YamlTrigger t : triggers) { String name = t.getName(); Map<String, Object> opts = (Map<String, Object>) StepConverter.deepConvert(t.getOptions()); List<String> activeProfiles = (List<String>) opts.remove(Constants.Request.ACTIVE_PROFILES_KEY); Map<String, Object> arguments = (Map<String, Object>) opts.remove(Constants.Request.ARGUMENTS_KEY); Map<String, Object> cfg = new HashMap<>(); for (String key : TRIGGER_CONFIG_KEYS) { cfg.put(key, opts.remove(key)); } JsonLocation l = t.getLocation(); SourceMap sourceMap = new SourceMap(SourceMap.Significance.HIGH, String.valueOf(l.getSourceRef()), l.getLineNr(), l.getColumnNr(), "Trigger: " + name); result.add(new Trigger(name, activeProfiles, arguments, opts, cfg, sourceMap)); } return result; }
String jsonSubString = endLocation.getSourceRef().toString().substring((int)charOffsetStart - 1, (int)charOffsetEnd); logger.info(strWalkStep);
@Override public T fromBytes(final byte[] bytes) { try { try { return mapper.readValue(bytes, clazz); } catch (final JsonParseException ex) { final JsonLocation location = ex.getLocation(); Object src = location.getSourceRef(); if (src instanceof ByteBuffer) { src = ((ByteBuffer) src).asCharBuffer(); } else if (src instanceof byte[]) { src = new String((byte[]) src); } else if (src instanceof char[]) { src = new String((char[]) src); } throw new JsonParseException( ex.getMessage(), new JsonLocation( src, location.getByteOffset(), location.getCharOffset(), location.getLineNr(), location.getColumnNr()), ex.getCause()); } } catch (final IOException ex) { throw new RuntimeException(ex); } } }