protected Parser createFixedParser(String resourceUri, Reader bodyReader) throws IOException { InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream( getCamelContext().getClassResolver(), resourceUri); InputStreamReader reader = new InputStreamReader(is); Parser parser = getParserFactory().newFixedLengthParser(reader, bodyReader); if (allowShortLines) { parser.setHandlingShortLines(true); parser.setIgnoreParseWarnings(true); } if (ignoreExtraColumns) { parser.setIgnoreExtraColumns(true); parser.setIgnoreParseWarnings(true); } return parser; }
public Parser createDelimitedParser(Exchange exchange) throws InvalidPayloadException, IOException { Reader bodyReader = exchange.getIn().getMandatoryBody(Reader.class); if (ObjectHelper.isEmpty(getResourceUri())) { return getParserFactory().newDelimitedParser(bodyReader, delimiter, textQualifier); } else { InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream( getCamelContext().getClassResolver(), resourceUri); InputStreamReader reader = new InputStreamReader(is, IOHelper.getCharsetName(exchange)); Parser parser = getParserFactory() .newDelimitedParser(reader, bodyReader, delimiter, textQualifier, ignoreFirstRecord); if (isAllowShortLines()) { parser.setHandlingShortLines(true); parser.setIgnoreParseWarnings(true); } if (isIgnoreExtraColumns()) { parser.setIgnoreExtraColumns(true); parser.setIgnoreParseWarnings(true); } return parser; } }