int p = 0;
if (queryHistory.size() > 20) {
p = queryHistory.size() - 20;
}
final AttributesImpl attrs = new AttributesImpl();
serializer.startDocument();
serializer.startElement("", "history", "history", attrs);
for(final ListIterator<String> i = queryHistory.listIterator(p); i.hasNext(); ) {
serializer.startElement("", "query", "query", attrs);
final String next = i.next();
serializer.characters(next.toCharArray(), 0, next.length());