* vocabulary tables for multiple serializations.
* @return a new {@link StAXDocumentSerializer} instance.
*/
/* package */ static StAXDocumentSerializer createNewStreamWriter(OutputStream out,
boolean retainState, int indexedStringSizeLimit, int stringsMemoryLimit) {
StAXDocumentSerializer serializer = new StAXDocumentSerializer(out);
if (retainState) {
/**
* Create a serializer vocabulary external to the serializer.
* This will ensure that the vocabulary will never be cleared
* for each serialization and will be retained (and will grow)
* for each serialization
*/
SerializerVocabulary vocabulary = new SerializerVocabulary();
serializer.setVocabulary(vocabulary);
serializer.setMinAttributeValueSize(0);
serializer.setMaxAttributeValueSize(indexedStringSizeLimit);
serializer.setMinCharacterContentChunkSize(0);
serializer.setMaxCharacterContentChunkSize(indexedStringSizeLimit);
serializer.setAttributeValueMapMemoryLimit(stringsMemoryLimit);
serializer.setCharacterContentChunkMapMemoryLimit(stringsMemoryLimit);
}
return serializer;
}