in src/cas/xmideserializer_handler.cpp [575:658]
void XmiDeserializerHandler::readFS(lowlevel::TyFS addr, const Attributes & attrs, bool toIndex) {
// Hang on address for setting content feature
currentAddr = addr;
int id = -1;
// int sofaRef = -1; // 0 ==> baseCas indexRepository
////vector<int>* sofaRef = new vector<int>;
icu::UnicodeString attrName;
icu::UnicodeString attrValue;
bool nameMapping = false;
UChar ubuff[256];
UErrorCode errorCode = U_ZERO_ERROR;
int thisSofaNum;
lowlevel::TyFS heapValue = iv_casimpl.getHeap().getType(addr);
if (sofaTypeCode == heapValue) {
int extsz = icu::UnicodeString(CAS::FEATURE_BASE_NAME_SOFAID).extract(ubuff, 256, errorCode);
if (extsz > 256) {
cout << "ACK!" << endl;
}
const UChar* sofaID = attrs.getValue(ubuff);
if (0==UnicodeStringRef(sofaID).compare(icu::UnicodeString("_DefaultTextSofaName"))) {
// initial view Sofa always has sofaNum = 1
thisSofaNum = 1;
} else if (0==UnicodeStringRef(sofaID).compare(icu::UnicodeString(CAS::NAME_DEFAULT_SOFA))) {
thisSofaNum = 1;
} else {
thisSofaNum = this->nextSofaNum++;
}
}
Type type = uima::internal::FSPromoter::promoteType(heapValue, iv_cas->getTypeSystem().getLowlevelTypeSystem());
for (size_t i = 0; i < attrs.getLength(); i++) {
assertWithMsg( sizeof(XMLCh) == sizeof(UChar), "Port required!");
attrName = (UChar*)attrs.getQName(i);
attrValue = (UChar*)attrs.getValue(i);
if (attrName.compare(icu::UnicodeString(XMI_ID_ATTR_NAME)) == 0) {
id = atoi(UnicodeStringRef(attrValue).asUTF8().c_str());
//cout << "got " << XMI_ID_ATTR_NAME << " " << id << endl;
} else {
if (sofaTypeCode == heapValue && attrName.compare(CAS::FEATURE_BASE_NAME_SOFAID)==0) {
if (attrValue.compare(icu::UnicodeString("_DefaultTextSofaName"))==0 ) {
// First change old default Sofa name into the new one
attrValue = icu::UnicodeString(CAS::NAME_DEFAULT_SOFA);
}
} else if (sofaTypeCode == heapValue
&& attrName.compare(icu::UnicodeString(CAS::FEATURE_BASE_NAME_SOFANUM))==0) {
stringstream str;
str << thisSofaNum << endl;
attrValue = icu::UnicodeString(str.str().c_str());
}
//cout << "readFS calling handleFeature " << attrName << " attrvalue= "
// << attrValue << endl;
handleFeature(addr, attrName, attrValue, true);
}
}
if (sofaTypeCode == heapValue) {
// If a Sofa, create CAS view to get new indexRepository
SofaFS sofa = (SofaFS) uima::internal::FSPromoter::promoteFS(addr, *iv_cas);
//also add to indexes so we can retrieve the Sofa later
iv_cas->getBaseIndexRepository().addFS(sofa);
CAS * tcas = iv_cas->getView(sofa);
assert ( EXISTS(tcas) );
if (sofa.getSofaRef() == 1) {
iv_cas->registerInitialSofa();
} else {
// add indexRepo for views other than the initial view
lowlevel::IndexRepository * indexRep = iv_cas->getIndexRepositoryForSofa(sofa);
assert ( EXISTS(indexRep) );
indexRepositories.push_back(indexRep);
}
tcasInstances.push_back(tcas);
}
deserializedFsAddrs.push_back(addr);
if (id > 0) {
sharedData->addIdMapping(addr, id);
}
}