void TermBuffer::set(TermPtr term)
 {
     if (!term)
     {
         reset();
         return;
     }
     String termText(term->text());
     int32_t termLen = termText.length();
     text->setLength(termLen);
     MiscUtils::arrayCopy(termText.begin(), 0, text->result.get(), 0, termLen);
     field = term->field();
     this->term = term;
 }
double QueryTermScorer::getTokenScore() {
    String termText(termAtt->term());

    WeightedTermPtr queryTerm(termsToFind.get(termText));
    if (!queryTerm) {
        return 0.0;    // not a query term - return
    }

    // found a query term - is it unique in this doc?
    if (!uniqueTermsInFragment.contains(termText)) {
        totalScore += queryTerm->getWeight();;
        uniqueTermsInFragment.add(termText);
    }

    return queryTerm->getWeight();
}