boolean rootWritten = false;
int delta = atomicReader.maxDoc() / 100;
if (delta == 0) delta = 1;
int cnt = 0;
bw = new BufferedWriter(new OutputStreamWriter(output, "UTF-8"));
Bits live = atomicReader.getLiveDocs();
try {
// write out XML preamble
if (preamble) {
bw.write("<?xml version='1.0' encoding='UTF-8'?>\n");
}
bw.write("<" + rootElementName + ">\n");
rootWritten = true;
if (info) {
// write out some statistics
writeIndexInfo(bw);
}
Document doc = null;
int i = -1;
if (ranges == null) {
ranges = new Ranges();
ranges.set(0, atomicReader.maxDoc());
}
if (ranges.cardinality() > 0) {
while ( (i = ranges.nextSetBit(++i)) != -1) {
if (i >= atomicReader.maxDoc()) {
break;
}
if (abort) {
pn.message = "User requested abort.";
pn.aborted = true;
running = false;
setChanged();
notifyObservers(pn);
break;
}
if (live != null && !live.get(i)) continue; // skip deleted docs
doc = atomicReader.document(i);
// write out fields
writeDoc(bw, i, doc, decode, live);
pn.curValue = i + 1;
cnt++;