private String[] getTags(String tagsPart) { String[] tags = tagsPart.split(","); for (int i = 0; i < tags.length; i++) tags[i] = sanitizeValue(tags[i]); return tags; }
void storeHeaderValue(String inputKey, String inputValue, Map<String, Object> content) { String key = sanitizeKey(inputKey); String value = sanitizeValue(inputValue); if (key.equalsIgnoreCase(Crawler.Attributes.DATE)) { DateFormat df = new SimpleDateFormat(configuration.getDateFormat()); try { Date date = df.parse(value); content.put(key, date); } catch (ParseException e) { LOGGER.error("unable to parse date {}", value); } } else if (key.equalsIgnoreCase(Crawler.Attributes.TAGS)) { content.put(key, getTags(value)); } else if (isJson(value)) { content.put(key, JSONValue.parse(value)); } else { content.put(key, value); } }
private void sanitizeTags(ParserContext context) { if (context.getTags() != null) { String[] tags = (String[]) context.getTags(); for (int i = 0; i < tags.length; i++) { tags[i] = sanitizeValue(tags[i]); if (context.getConfig().getSanitizeTag()) { tags[i] = tags[i].replace(" ", "-"); } } context.setTags(tags); } }
private String[] getTags(String tagsPart) { String[] tags = tagsPart.split(","); for (int i = 0; i < tags.length; i++) tags[i] = sanitizeValue(tags[i]); return tags; }
void storeHeaderValue(String inputKey, String inputValue, Map<String, Object> content) { String key = sanitizeKey(inputKey); String value = sanitizeValue(inputValue); if (key.equalsIgnoreCase(Crawler.Attributes.DATE)) { DateFormat df = new SimpleDateFormat(configuration.getDateFormat()); try { Date date = df.parse(value); content.put(key, date); } catch (ParseException e) { LOGGER.error("unable to parse date {}", value); } } else if (key.equalsIgnoreCase(Crawler.Attributes.TAGS)) { content.put(key, getTags(value)); } else if (isJson(value)) { content.put(key, JSONValue.parse(value)); } else { content.put(key, value); } }
private void sanitizeTags(ParserContext context) { if (context.getTags() != null) { String[] tags = (String[]) context.getTags(); for (int i = 0; i < tags.length; i++) { tags[i] = sanitizeValue(tags[i]); if (context.getConfig().getSanitizeTag()) { tags[i] = tags[i].replace(" ", "-"); } } context.setTags(tags); } }