/* package */void TypeExtensionManager::LoadTesters( std::vector<IPropertyTester::Pointer>& result, const std::string& typeName) { if (fConfigurationElementMap == 0) { fConfigurationElementMap = new std::map<std::string, std::vector<IConfigurationElement::Pointer> >(); IExtensionPointService::Pointer registry(Platform::GetExtensionPointService()); IConfigurationElement::vector ces( registry->GetConfigurationElementsFor("org.blueberry.core.expressions." + fExtensionPoint)); for (unsigned int i= 0; i < ces.size(); i++) { IConfigurationElement::Pointer config(ces[i]); std::string typeAttr; config->GetAttribute(TYPE, typeAttr); std::vector<IConfigurationElement::Pointer> typeConfigs = (*fConfigurationElementMap)[typeAttr]; typeConfigs.push_back(config); } } //std::string typeName= type.getName(); std::vector<IConfigurationElement::Pointer> typeConfigs = (*fConfigurationElementMap)[typeName]; for (unsigned int i= 0; i < typeConfigs.size(); i++) { IConfigurationElement::Pointer config(typeConfigs[i]); try { IPropertyTester::Pointer descr(new PropertyTesterDescriptor(config)); result.push_back(descr); } catch (CoreException e) { //TODO //ExpressionPlugin.getDefault().getLog().log(e.getStatus()); IPropertyTester::Pointer nullTester(new NULL_PROPERTY_TESTER_()); result.push_back(nullTester); } } fConfigurationElementMap->erase(typeName); }
BucketList *AlphabeticIndex::createBucketList(UErrorCode &errorCode) const { // Initialize indexCharacters. UVector indexCharacters(errorCode); indexCharacters.setDeleter(uprv_deleteUObject); initLabels(indexCharacters, errorCode); if (U_FAILURE(errorCode)) { return NULL; } // Variables for hasMultiplePrimaryWeights(). UVector64 ces(errorCode); uint32_t variableTop; if (collatorPrimaryOnly_->getAttribute(UCOL_ALTERNATE_HANDLING, errorCode) == UCOL_SHIFTED) { variableTop = collatorPrimaryOnly_->getVariableTop(errorCode); } else { variableTop = 0; } UBool hasInvisibleBuckets = FALSE; // Helper arrays for Chinese Pinyin collation. Bucket *asciiBuckets[26] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; Bucket *pinyinBuckets[26] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; UBool hasPinyin = FALSE; LocalPointer<UVector> bucketList(new UVector(errorCode), errorCode); if (U_FAILURE(errorCode)) { return NULL; } bucketList->setDeleter(uprv_deleteUObject); // underflow bucket Bucket *bucket = new Bucket(getUnderflowLabel(), emptyString_, U_ALPHAINDEX_UNDERFLOW); if (bucket == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucketList->addElement(bucket, errorCode); if (U_FAILURE(errorCode)) { return NULL; } UnicodeString temp; // fix up the list, adding underflow, additions, overflow // Insert inflow labels as needed. int32_t scriptIndex = -1; const UnicodeString *scriptUpperBoundary = &emptyString_; for (int32_t i = 0; i < indexCharacters.size(); ++i) { UnicodeString ¤t = *getString(indexCharacters, i); if (collatorPrimaryOnly_->compare(current, *scriptUpperBoundary, errorCode) >= 0) { // We crossed the script boundary into a new script. const UnicodeString &inflowBoundary = *scriptUpperBoundary; UBool skippedScript = FALSE; for (;;) { scriptUpperBoundary = getString(*firstCharsInScripts_, ++scriptIndex); if (collatorPrimaryOnly_->compare(current, *scriptUpperBoundary, errorCode) < 0) { break; } skippedScript = TRUE; } if (skippedScript && bucketList->size() > 1) { // We are skipping one or more scripts, // and we are not just getting out of the underflow label. bucket = new Bucket(getInflowLabel(), inflowBoundary, U_ALPHAINDEX_INFLOW); if (bucket == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucketList->addElement(bucket, errorCode); } } // Add a bucket with the current label. bucket = new Bucket(fixLabel(current, temp), current, U_ALPHAINDEX_NORMAL); if (bucket == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucketList->addElement(bucket, errorCode); // Remember ASCII and Pinyin buckets for Pinyin redirects. UChar c; if (current.length() == 1 && 0x41 <= (c = current.charAt(0)) && c <= 0x5A) { // A-Z asciiBuckets[c - 0x41] = bucket; } else if (current.length() == BASE_LENGTH + 1 && current.startsWith(BASE, BASE_LENGTH) && 0x41 <= (c = current.charAt(BASE_LENGTH)) && c <= 0x5A) { pinyinBuckets[c - 0x41] = bucket; hasPinyin = TRUE; } // Check for multiple primary weights. if (!current.startsWith(BASE, BASE_LENGTH) && hasMultiplePrimaryWeights(*collatorPrimaryOnly_, variableTop, current, ces, errorCode) && current.charAt(current.length() - 1) != 0xFFFF /* !current.endsWith("\uffff") */) { // "AE-ligature" or "Sch" etc. for (int32_t i = bucketList->size() - 2;; --i) { Bucket *singleBucket = getBucket(*bucketList, i); if (singleBucket->labelType_ != U_ALPHAINDEX_NORMAL) { // There is no single-character bucket since the last // underflow or inflow label. break; } if (singleBucket->displayBucket_ == NULL && !hasMultiplePrimaryWeights(*collatorPrimaryOnly_, variableTop, singleBucket->lowerBoundary_, ces, errorCode)) { // Add an invisible bucket that redirects strings greater than the expansion // to the previous single-character bucket. // For example, after ... Q R S Sch we add Sch\uFFFF->S // and after ... Q R S Sch Sch\uFFFF St we add St\uFFFF->S. bucket = new Bucket(emptyString_, UnicodeString(current).append((UChar)0xFFFF), U_ALPHAINDEX_NORMAL); if (bucket == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucket->displayBucket_ = singleBucket; bucketList->addElement(bucket, errorCode); hasInvisibleBuckets = TRUE; break; } } } } if (U_FAILURE(errorCode)) { return NULL; } if (bucketList->size() == 1) { // No real labels, show only the underflow label. BucketList *bl = new BucketList(bucketList.getAlias(), bucketList.getAlias()); if (bl == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucketList.orphan(); return bl; } // overflow bucket bucket = new Bucket(getOverflowLabel(), *scriptUpperBoundary, U_ALPHAINDEX_OVERFLOW); if (bucket == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucketList->addElement(bucket, errorCode); // final if (hasPinyin) { // Redirect Pinyin buckets. Bucket *asciiBucket = NULL; for (int32_t i = 0; i < 26; ++i) { if (asciiBuckets[i] != NULL) { asciiBucket = asciiBuckets[i]; } if (pinyinBuckets[i] != NULL && asciiBucket != NULL) { pinyinBuckets[i]->displayBucket_ = asciiBucket; hasInvisibleBuckets = TRUE; } } } if (U_FAILURE(errorCode)) { return NULL; } if (!hasInvisibleBuckets) { BucketList *bl = new BucketList(bucketList.getAlias(), bucketList.getAlias()); if (bl == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucketList.orphan(); return bl; } // Merge inflow buckets that are visually adjacent. // Iterate backwards: Merge inflow into overflow rather than the other way around. int32_t i = bucketList->size() - 1; Bucket *nextBucket = getBucket(*bucketList, i); while (--i > 0) { bucket = getBucket(*bucketList, i); if (bucket->displayBucket_ != NULL) { continue; // skip invisible buckets } if (bucket->labelType_ == U_ALPHAINDEX_INFLOW) { if (nextBucket->labelType_ != U_ALPHAINDEX_NORMAL) { bucket->displayBucket_ = nextBucket; continue; } } nextBucket = bucket; } LocalPointer<UVector> publicBucketList(new UVector(errorCode), errorCode); if (U_FAILURE(errorCode)) { return NULL; } // Do not call publicBucketList->setDeleter(): // This vector shares its objects with the bucketList. for (int32_t i = 0; i < bucketList->size(); ++i) { bucket = getBucket(*bucketList, i); if (bucket->displayBucket_ == NULL) { publicBucketList->addElement(bucket, errorCode); } } if (U_FAILURE(errorCode)) { return NULL; } BucketList *bl = new BucketList(bucketList.getAlias(), publicBucketList.getAlias()); if (bl == NULL) { errorCode = U_MEMORY_ALLOCATION_ERROR; return NULL; } bucketList.orphan(); publicBucketList.orphan(); return bl; }