private final void processText(MemTreeBuilder builder, NodeProxy proxy, Sequence result,
FunctionReference callback, Sequence extraArgs)
throws DOMException, XPathException {
final TextImpl text = (TextImpl) proxy.getNode();
final Match match = proxy.getMatches();
int nodeNr;
if (match == null) {
nodeNr = builder.characters(text.getXMLString());
result.add(builder.getDocument().getNode(nodeNr));
} else {
List<Match.Offset> offsets = null;
Match next = match;
while (next != null) {
if (next.getNodeId().equals(text.getNodeId())) {
if (offsets == null)
{offsets = new ArrayList<Match.Offset>();}
final int freq = next.getFrequency();
for (int i = 0; i < freq; i++) {
offsets.add(next.getOffset(i));
}
}
next = next.getNextMatch();
}
if (offsets != null) {
FastQSort.sort(offsets, 0, offsets.size() - 1);