コード例 #1
0
 void FilteredTermEnum::setEnum(TermEnumPtr actualEnum)
 {
     this->actualEnum = actualEnum;
     // Find the first term that matches
     TermPtr term(actualEnum->term());
     if (term && termCompare(term))
         currentTerm = term;
     else
         next();
 }
コード例 #2
0
bool NumericRangeTermEnum::next() {
    // if a current term exists, the actual enum is initialized: try change to next term, if no
    // such term exists, fall-through
    if (currentTerm) {
        BOOST_ASSERT(actualEnum);
        if (actualEnum->next()) {
            currentTerm = actualEnum->term();
            if (termCompare(currentTerm)) {
                return true;
            }
        }
    }

    // if all above fails, we go forward to the next enum, if one is available
    currentTerm.reset();
    while (rangeBounds.size() >= 2) {
        BOOST_ASSERT(rangeBounds.size() % 2 == 0);
        // close the current enum and read next bounds
        if (actualEnum) {
            actualEnum->close();
            actualEnum.reset();
        }
        String lowerBound(rangeBounds.removeFirst());
        currentUpperBound = rangeBounds.removeFirst();
        // create a new enum
        actualEnum = reader->terms(termTemplate->createTerm(lowerBound));
        currentTerm = actualEnum->term();
        if (currentTerm && termCompare(currentTerm)) {
            return true;
        }
        // clear the current term for next iteration
        currentTerm.reset();
    }

    // no more sub-range enums available
    BOOST_ASSERT(rangeBounds.empty() && !currentTerm);
    return false;
}
コード例 #3
0
	void FilteredTermEnum::setEnum(TermEnum* actualEnum) {
	//Func - Sets the actual Enumeration
	//Pre  - actualEnum != NULL
	//Post - The instance has been created

		CND_PRECONDITION(actualEnum != NULL,"actualEnum is NULL");

		_CLLDELETE(this->actualEnum);
        this->actualEnum = actualEnum;

        // Find the first term that matches
        //Ordered term not to return reference ownership here.
        Term* term = actualEnum->term(false);
        if (term != NULL && termCompare(term)){
            _CLDECDELETE(currentTerm);
            currentTerm = _CL_POINTER(term);
        }else{
            next();
		}
    }
コード例 #4
0
    bool FilteredTermEnum::next() {
    //Func - Increments the enumeration to the next element.  
	//Pre  - true
	//Post - Returns True if the enumeration has been moved to the next element otherwise false

		//The actual enumerator is not initialized!
		if (actualEnum == NULL){
			return false; 
		    }

		//Finalize the currentTerm and reset it to NULL
        currentTerm->finalize();
        currentTerm = NULL;

		//Iterate through the enumeration
        while (currentTerm == NULL) {
            if (EndEnum()) 
				return false;
            if (actualEnum->next()) {
                //Order getTerm not to return reference ownership here. */
                Term* term = actualEnum->getTerm(false);
				//Compare the retrieved term
                if (termCompare(term)){
					//Matched so finalize the current
                    currentTerm->finalize();
					//Get a reference to the matched term
                    currentTerm = term->pointer();
                    return true;
                    }
                }
            else 
                return false;
        }
        currentTerm->finalize();
        currentTerm = NULL;

        return false;
    }
コード例 #5
0
 bool FilteredTermEnum::next()
 {
     if (!actualEnum)
         return false; // the actual enumerator is not initialized
     currentTerm.reset();
     while (!currentTerm)
     {
         if (endEnum())
             return false;
         if (actualEnum->next())
         {
             TermPtr term(actualEnum->term());
             if (termCompare(term))
             {
                 currentTerm = term;
                 return true;
             }
         }
         else
             return false;
     }
     currentTerm.reset();
     return false;
 }