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); } }
boolean typeFound = false; if (!headerSeparatorDemarcatesHeader(contents)) { return false; if (hasHeaderSeparator(line)) { LOGGER.debug("Header separator found"); break; if (isTypeProperty(line)) { LOGGER.debug("Type property found"); typeFound = true; if (isStatusProperty(line)) { LOGGER.debug("Status property found"); statusFound = true; return headerValid && (statusFound || hasDefaultStatus()) && (typeFound || hasDefaultType());
boolean hasHeader = hasHeader(fileContents); ParserContext context = new ParserContext( file, processDefaultHeader(context); processHeader(context); setModelDefaultsIfNotSetInHeader(context); sanitizeTags(context); processDefaultBody(context); if (validate(context)) { processBody(context); } else { LOGGER.error("Incomplete source file ({}) for markup engine: {}", file, getClass().getSimpleName());
/** * Process the header of the file. * * @param context the parser context */ private void processDefaultHeader(ParserContext context) { for (String line : context.getFileLines()) { if (hasHeaderSeparator(line)) { break; } processHeaderLine(line, context.getDocumentModel()); } }
@Override public Map<String, Object> parse(Configuration config, File file, String contentPath) { return parse(new DefaultJBakeConfiguration((CompositeConfiguration) config), file); }
/** * Process the header of the file. * * @param context the parser context */ private void processDefaultHeader(ParserContext context) { for (String line : context.getFileLines()) { if (hasHeaderSeparator(line)) { break; } processHeaderLine(line, context.getDocumentModel()); } }
@Override public Map<String, Object> parse(Configuration config, File file, String contentPath) { return parse(new DefaultJBakeConfiguration((CompositeConfiguration) config), file); }
boolean hasHeader = hasHeader(fileContents); ParserContext context = new ParserContext( file, processDefaultHeader(context); processHeader(context); setModelDefaultsIfNotSetInHeader(context); sanitizeTags(context); processDefaultBody(context); if (validate(context)) { processBody(context); } else { LOGGER.error("Incomplete source file ({}) for markup engine: {}", file, getClass().getSimpleName());
boolean typeFound = false; if (!headerSeparatorDemarcatesHeader(contents)) { return false; if (hasHeaderSeparator(line)) { LOGGER.debug("Header separator found"); break; if (isTypeProperty(line)) { LOGGER.debug("Type property found"); typeFound = true; if (isStatusProperty(line)) { LOGGER.debug("Status property found"); statusFound = true; return headerValid && (statusFound || hasDefaultStatus()) && (typeFound || hasDefaultType());
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); } }