Example #1
0
void RangeTokenMap::addKeywordMap(const XMLCh* const keyword,
                                 const XMLCh* const categoryName) {

	unsigned int categId = fCategories->getId(categoryName);

	if (categId == 0) {
		ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_InvalidCategoryName, categoryName, fTokenRegistry->getMemoryManager());
	}

    if (fTokenRegistry->containsKey(keyword)) {

        RangeTokenElemMap* elemMap = fTokenRegistry->get(keyword);

		if (elemMap->getCategoryId() != categId)
			elemMap->setCategoryId(categId);

		return;
	}

	fTokenRegistry->put((void*) keyword, new RangeTokenElemMap(categId));
}
Example #2
0
// ---------------------------------------------------------------------------
//  RangeTokenMap: Getter methods
// ---------------------------------------------------------------------------
RangeToken* RangeTokenMap::getRange(const XMLCh* const keyword,
								    const bool complement) {

    if (fTokenRegistry == 0 || fRangeMap == 0 || fCategories == 0)
        return 0;

    if (!fTokenRegistry->containsKey(keyword))
        return 0;

    RangeTokenElemMap* elemMap = fTokenRegistry->get(keyword);
    RangeToken* rangeTok = elemMap->getRangeToken(complement);

    if (!rangeTok)
    {
        XMLMutexLock lockInit(&fMutex);

        // make sure that it was not created while we were locked
        rangeTok = elemMap->getRangeToken(complement);

        if (!rangeTok)
        {
            rangeTok = elemMap->getRangeToken();
            if (!rangeTok)
            {
                unsigned int categId = elemMap->getCategoryId();
                const XMLCh* categName = fCategories->getValueForId(categId);
                RangeFactory* rangeFactory = fRangeMap->get(categName);

                if (rangeFactory == 0)
                    return 0;

                rangeFactory->buildRanges();
                rangeTok = elemMap->getRangeToken();
            }

            if (complement)
            {
                rangeTok = (RangeToken*) RangeToken::complementRanges(rangeTok, fTokenFactory, fTokenRegistry->getMemoryManager());
                elemMap->setRangeToken(rangeTok , complement);
            }
        }
    }

    return rangeTok;
}