* @param retainState if true the parser should retain the state of
* vocabulary tables for multiple parses.
* @return a new recyclable {@link StAXDocumentParser} instance.
*/
/* package */ static StAXDocumentParser createNewStreamReaderRecyclable(InputStream in, boolean retainState) {
StAXDocumentParser parser = new FastInfosetStreamReaderRecyclable(in);
parser.setStringInterning(true);
parser.setForceStreamClose(true);
if (retainState) {
/**
* Create a parser vocabulary external to the parser.
* This will ensure that the vocabulary will never be cleared
* for each parse and will be retained (and will grow)
* for each parse.
*/
ParserVocabulary vocabulary = new ParserVocabulary();
parser.setVocabulary(vocabulary);
}
return parser;
}