| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#include "CDataLiteralNormalizerPreProcess.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Preprocess { |
| 29 |
|
| 30 |
|
| 31 |
bool CDataLiteralNormalizerPreProcess::mConvArraysInitialized = false; |
| 32 |
cint64* CDataLiteralNormalizerPreProcess::mHexStringBinaryDataConvArray = nullptr; |
| 33 |
cint64* CDataLiteralNormalizerPreProcess::mBase64StringBinaryDataConvArray = nullptr; |
| 34 |
|
| 35 |
CDataLiteralNormalizerPreProcess::CDataLiteralNormalizerPreProcess() { |
| 36 |
mLastConceptId = 0; |
| 37 |
if (!mConvArraysInitialized) { |
| 38 |
cint64* tmpHexStringBinaryDataConvArray = new cint64[127]; |
| 39 |
for (cint64 i = 0; i < 127; ++i) { |
| 40 |
tmpHexStringBinaryDataConvArray[i] = -1; |
| 41 |
} |
| 42 |
for (cint64 i = '0'; i <= '9'; ++i) { |
| 43 |
tmpHexStringBinaryDataConvArray[i] = i - '0'; |
| 44 |
} |
| 45 |
for (cint64 i = 'A'; i <= 'F'; ++i) { |
| 46 |
tmpHexStringBinaryDataConvArray[i] = i - 'A' + 10; |
| 47 |
} |
| 48 |
for (cint64 i = 'a'; i <= 'f'; ++i) { |
| 49 |
tmpHexStringBinaryDataConvArray[i] = i - 'a' + 10; |
| 50 |
} |
| 51 |
mHexStringBinaryDataConvArray = tmpHexStringBinaryDataConvArray; |
| 52 |
|
| 53 |
|
| 54 |
cint64* tmpBase64StringBinaryDataConvArray = new cint64[127]; |
| 55 |
for (cint64 i = 0; i < 127; ++i) { |
| 56 |
tmpBase64StringBinaryDataConvArray[i] = -1; |
| 57 |
} |
| 58 |
for (cint64 i = 'A'; i <= 'Z'; ++i) { |
| 59 |
tmpBase64StringBinaryDataConvArray[i] = i - 'A'; |
| 60 |
} |
| 61 |
for (cint64 i = 'a'; i <= 'z'; ++i) { |
| 62 |
tmpBase64StringBinaryDataConvArray[i] = i - 'a' + 26; |
| 63 |
} |
| 64 |
for (cint64 i = '0'; i <= '9'; ++i) { |
| 65 |
tmpBase64StringBinaryDataConvArray[i] = i - '0' + 52; |
| 66 |
} |
| 67 |
tmpBase64StringBinaryDataConvArray['+'] = 62; |
| 68 |
tmpBase64StringBinaryDataConvArray['/'] = 63; |
| 69 |
tmpBase64StringBinaryDataConvArray['-'] = 62; |
| 70 |
tmpBase64StringBinaryDataConvArray['_'] = 63; |
| 71 |
mBase64StringBinaryDataConvArray = tmpBase64StringBinaryDataConvArray; |
| 72 |
|
| 73 |
mConvArraysInitialized = true; |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
CDataLiteralNormalizerPreProcess::~CDataLiteralNormalizerPreProcess() { |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
CConcept *CDataLiteralNormalizerPreProcess::preprocessDataConcept(CConcept* dataConcept, CConcreteOntology *ontology, CPreProcessContext* context) { |
| 83 |
if (ontology) { |
| 84 |
mTBox = ontology->getDataBoxes()->getTBox(); |
| 85 |
mABox = ontology->getDataBoxes()->getABox(); |
| 86 |
mRBox = ontology->getDataBoxes()->getRBox(); |
| 87 |
mMBox = ontology->getDataBoxes()->getMBox(); |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
mRolesVector = mRBox->getRoleVector(); |
| 92 |
mConceptVector = mTBox->getConceptVector(); |
| 93 |
mIndiVec = mABox->getIndividualVector(); |
| 94 |
|
| 95 |
|
| 96 |
mOntology = ontology; |
| 97 |
mBoxContext = mOntology->getDataBoxes()->getBoxContext(); |
| 98 |
mMemMan = mBoxContext->getMemoryAllocationManager(); |
| 99 |
|
| 100 |
cint64 conceptCount = mConceptVector->getItemCount(); |
| 101 |
if (dataConcept) { |
| 102 |
CDataLiteral* dataLiteral = dataConcept->getDataLiteral(); |
| 103 |
if (dataLiteral) { |
| 104 |
CDataLiteralValue* dataLiteralValue = dataLiteral->getDataLiteralValue(); |
| 105 |
if (!dataLiteralValue) { |
| 106 |
dataLiteralValue = createDataLiteralValue(dataLiteral, context); |
| 107 |
dataLiteral->setDataLiteralValue(dataLiteralValue); |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
if (dataConcept->getOperatorCode() == CCDATARESTRICTION) { |
| 112 |
if (normalizeDatatypeRestriction(dataConcept, context)) { |
| 113 |
conceptCount = mConceptVector->getItemCount(); |
| 114 |
} |
| 115 |
} |
| 116 |
else if (dataConcept->getOperatorCode() == CCDATALITERAL) { |
| 117 |
normalizeDataLiteral(dataConcept, context); |
| 118 |
} |
| 119 |
} |
| 120 |
} |
| 121 |
return dataConcept; |
| 122 |
} |
| 123 |
|
| 124 |
|
| 125 |
CConcreteOntology *CDataLiteralNormalizerPreProcess::preprocess(CConcreteOntology *ontology, CPreProcessContext* context) { |
| 126 |
mOntology = ontology; |
| 127 |
mContext = context; |
| 128 |
mLastConceptId = 0; |
| 129 |
if (ontology) { |
| 130 |
mTBox = ontology->getDataBoxes()->getTBox(); |
| 131 |
mABox = ontology->getDataBoxes()->getABox(); |
| 132 |
mRBox = ontology->getDataBoxes()->getRBox(); |
| 133 |
mMBox = ontology->getDataBoxes()->getMBox(); |
| 134 |
|
| 135 |
|
| 136 |
mRolesVector = mRBox->getRoleVector(); |
| 137 |
mConceptVector = mTBox->getConceptVector(); |
| 138 |
mIndiVec = mABox->getIndividualVector(); |
| 139 |
|
| 140 |
|
| 141 |
mOntology = ontology; |
| 142 |
mBoxContext = mOntology->getDataBoxes()->getBoxContext(); |
| 143 |
mMemMan = mBoxContext->getMemoryAllocationManager(); |
| 144 |
|
| 145 |
|
| 146 |
} |
| 147 |
|
| 148 |
return continuePreprocessing(); |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
CConcreteOntology* CDataLiteralNormalizerPreProcess::continuePreprocessing() { |
| 154 |
if (mOntology) { |
| 155 |
cint64 conceptCount = mConceptVector->getItemCount(); |
| 156 |
for (cint64 i = mLastConceptId; i < conceptCount; ++i) { |
| 157 |
CConcept* concept = mConceptVector->getLocalData(i); |
| 158 |
if (concept) { |
| 159 |
CDataLiteral* dataLiteral = concept->getDataLiteral(); |
| 160 |
if (dataLiteral) { |
| 161 |
CDataLiteralValue* dataLiteralValue = dataLiteral->getDataLiteralValue(); |
| 162 |
if (!dataLiteralValue) { |
| 163 |
dataLiteralValue = createDataLiteralValue(dataLiteral, mContext); |
| 164 |
dataLiteral->setDataLiteralValue(dataLiteralValue); |
| 165 |
} |
| 166 |
} |
| 167 |
|
| 168 |
if (concept->getOperatorCode() == CCDATARESTRICTION) { |
| 169 |
if (normalizeDatatypeRestriction(concept, mContext)) { |
| 170 |
conceptCount = mConceptVector->getItemCount(); |
| 171 |
} |
| 172 |
} else if (concept->getOperatorCode() == CCDATALITERAL) { |
| 173 |
normalizeDataLiteral(concept, mContext); |
| 174 |
} |
| 175 |
} |
| 176 |
} |
| 177 |
mLastConceptId = conceptCount; |
| 178 |
|
| 179 |
cint64 indiCount = mIndiVec->getItemCount(); |
| 180 |
for (cint64 i = mLastIndiId; i < indiCount; ++i) { |
| 181 |
CIndividual* indi = mIndiVec->getLocalData(i); |
| 182 |
if (indi) { |
| 183 |
for (CDataAssertionLinker* dataAssLinkerIt = indi->getAssertionDataLinker(); dataAssLinkerIt; dataAssLinkerIt = dataAssLinkerIt->getNext()) { |
| 184 |
CDataLiteral* dataLiteral = dataAssLinkerIt->getDataLiteral(); |
| 185 |
if (dataLiteral) { |
| 186 |
CDataLiteralValue* dataLiteralValue = dataLiteral->getDataLiteralValue(); |
| 187 |
if (!dataLiteralValue) { |
| 188 |
dataLiteralValue = createDataLiteralValue(dataLiteral, mContext); |
| 189 |
dataLiteral->setDataLiteralValue(dataLiteralValue); |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
} |
| 194 |
} |
| 195 |
} |
| 196 |
mLastIndiId = indiCount; |
| 197 |
} |
| 198 |
return mOntology; |
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::createPreprocessedDataLiteralValue(CDataLiteral* dataLiteral, CPreProcessContext* context, CContext* boxContext) { |
| 203 |
mOntology = context->getOntology(); |
| 204 |
mMemMan = context->getMemoryAllocationManager(); |
| 205 |
mContext = context; |
| 206 |
mBoxContext = boxContext; |
| 207 |
|
| 208 |
|
| 209 |
CDataLiteralValue* dataLiteralValue = dataLiteral->getDataLiteralValue(); |
| 210 |
if (!dataLiteralValue) { |
| 211 |
dataLiteralValue = createDataLiteralValue(dataLiteral, context); |
| 212 |
dataLiteral->setDataLiteralValue(dataLiteralValue); |
| 213 |
} |
| 214 |
return dataLiteralValue; |
| 215 |
} |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
bool CDataLiteralNormalizerPreProcess::normalizeDataLiteral(CConcept* dataLiteralConcept, CPreProcessContext* context) { |
| 221 |
bool dataLiteralNormalized = false; |
| 222 |
CDatatype* datatype = dataLiteralConcept->getDatatype(); |
| 223 |
if (!datatype) { |
| 224 |
} |
| 225 |
return dataLiteralNormalized; |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
bool CDataLiteralNormalizerPreProcess::normalizeDatatypeRestriction(CConcept* datatypeRestrictionConcept, CPreProcessContext* context) { |
| 230 |
bool datatypeRestrictionNormalized = false; |
| 231 |
cint64 restrictionCode = datatypeRestrictionConcept->getParameter(); |
| 232 |
CDatatype* datatype = datatypeRestrictionConcept->getDatatype(); |
| 233 |
if (datatype && !datatype->isBasicDatatype()) { |
| 234 |
CDatatype* basicDatatype = datatype->getBasicDatatype(); |
| 235 |
CConcept* datatypeConcept = datatype->getDatatypeConcept(); |
| 236 |
if (datatypeConcept && basicDatatype) { |
| 237 |
CDataLiteral* dataLiteral = datatypeRestrictionConcept->getDataLiteral(); |
| 238 |
|
| 239 |
datatypeRestrictionConcept->setDatatype(nullptr); |
| 240 |
datatypeRestrictionConcept->setOperatorCode(CCAND); |
| 241 |
datatypeRestrictionConcept->setDataLiteral(nullptr); |
| 242 |
datatypeRestrictionConcept->setParameter(0); |
| 243 |
datatypeRestrictionConcept->setOperandCount(0); |
| 244 |
|
| 245 |
CConcept* newRestrictionConcept = createConcept(); |
| 246 |
newRestrictionConcept->setDataLiteral(dataLiteral); |
| 247 |
newRestrictionConcept->setOperatorCode(CCDATARESTRICTION); |
| 248 |
newRestrictionConcept->setParameter(restrictionCode); |
| 249 |
newRestrictionConcept->setDatatype(basicDatatype); |
| 250 |
addConceptOperand(datatypeRestrictionConcept,newRestrictionConcept,false); |
| 251 |
addConceptOperand(datatypeRestrictionConcept,datatypeConcept,false); |
| 252 |
|
| 253 |
datatypeRestrictionNormalized = true; |
| 254 |
} |
| 255 |
} else { |
| 256 |
if (restrictionCode == CDFC_LENGTH) { |
| 257 |
CConcept* datatypeConcept = datatype->getDatatypeConcept(); |
| 258 |
CDataLiteral* dataLiteral = datatypeRestrictionConcept->getDataLiteral(); |
| 259 |
|
| 260 |
datatypeRestrictionConcept->setDatatype(nullptr); |
| 261 |
datatypeRestrictionConcept->setOperatorCode(CCAND); |
| 262 |
datatypeRestrictionConcept->setDataLiteral(nullptr); |
| 263 |
datatypeRestrictionConcept->setParameter(0); |
| 264 |
datatypeRestrictionConcept->setOperandCount(0); |
| 265 |
|
| 266 |
CConcept* minLengthRestrictionConcept = createConcept(); |
| 267 |
minLengthRestrictionConcept->setDataLiteral(dataLiteral); |
| 268 |
minLengthRestrictionConcept->setOperatorCode(CCDATARESTRICTION); |
| 269 |
minLengthRestrictionConcept->setParameter(CDFC_MIN_LENGTH_INCLUSIVE); |
| 270 |
minLengthRestrictionConcept->setDatatype(datatype); |
| 271 |
addConceptOperand(datatypeRestrictionConcept,minLengthRestrictionConcept,false); |
| 272 |
|
| 273 |
CConcept* maxLengthRestrictionConcept = createConcept(); |
| 274 |
maxLengthRestrictionConcept->setDataLiteral(dataLiteral); |
| 275 |
maxLengthRestrictionConcept->setOperatorCode(CCDATARESTRICTION); |
| 276 |
maxLengthRestrictionConcept->setParameter(CDFC_MAX_LENGTH_INCLUSIVE); |
| 277 |
maxLengthRestrictionConcept->setDatatype(datatype); |
| 278 |
addConceptOperand(datatypeRestrictionConcept,maxLengthRestrictionConcept,false); |
| 279 |
|
| 280 |
datatypeRestrictionNormalized = true; |
| 281 |
|
| 282 |
|
| 283 |
} else if (restrictionCode == CDFC_MIN_LENGTH_INCLUSIVE) { |
| 284 |
CDataLiteral* dataLiteral = datatypeRestrictionConcept->getDataLiteral(); |
| 285 |
dataLiteral = getNormalizedDataLiteralForLengthRestriction(datatype,dataLiteral,true,context); |
| 286 |
datatypeRestrictionConcept->setParameter(CDFC_MIN_INCLUSIVE); |
| 287 |
datatypeRestrictionConcept->setDataLiteral(dataLiteral); |
| 288 |
datatypeRestrictionNormalized = true; |
| 289 |
|
| 290 |
} else if (restrictionCode == CDFC_MAX_LENGTH_INCLUSIVE) { |
| 291 |
CDataLiteral* dataLiteral = datatypeRestrictionConcept->getDataLiteral(); |
| 292 |
dataLiteral = getNormalizedDataLiteralForLengthRestriction(datatype,dataLiteral,false,context); |
| 293 |
datatypeRestrictionConcept->setParameter(CDFC_MAX_EXCLUSIVE); |
| 294 |
datatypeRestrictionConcept->setDataLiteral(dataLiteral); |
| 295 |
datatypeRestrictionNormalized = true; |
| 296 |
} |
| 297 |
} |
| 298 |
return datatypeRestrictionNormalized; |
| 299 |
} |
| 300 |
|
| 301 |
|
| 302 |
CDataLiteral* CDataLiteralNormalizerPreProcess::getNormalizedDataLiteralForLengthRestriction(CDatatype* datatype, CDataLiteral* dataLiteral, bool roundUp, CPreProcessContext* context) { |
| 303 |
CDataLiteral* adaptedDataLiteral = dataLiteral; |
| 304 |
if (dataLiteral->getDatatype() != datatype) { |
| 305 |
adaptedDataLiteral = nullptr; |
| 306 |
|
| 307 |
CDataLiteralValue* dataLiteralValue = dataLiteral->getDataLiteralValue(); |
| 308 |
if (!dataLiteralValue) { |
| 309 |
dataLiteralValue = createDataLiteralValue(dataLiteral,context); |
| 310 |
dataLiteral->setDataLiteralValue(dataLiteralValue); |
| 311 |
} |
| 312 |
|
| 313 |
bool lengthParsed = false; |
| 314 |
bool infinite = false; |
| 315 |
cint64 length = 0; |
| 316 |
CDataLiteralRealValue* realDataLiteralValue = dynamic_cast<CDataLiteralRealValue*>(dataLiteralValue); |
| 317 |
if (realDataLiteralValue && !realDataLiteralValue->isNegative()) { |
| 318 |
if (realDataLiteralValue->isInfinite()) { |
| 319 |
infinite = true; |
| 320 |
lengthParsed = true; |
| 321 |
} else { |
| 322 |
length = realDataLiteralValue->getInteger(); |
| 323 |
lengthParsed = true; |
| 324 |
if (roundUp && realDataLiteralValue->getNumerator() != 0) { |
| 325 |
++length; |
| 326 |
} |
| 327 |
if (!roundUp) { |
| 328 |
++length; |
| 329 |
} |
| 330 |
} |
| 331 |
} |
| 332 |
|
| 333 |
if (lengthParsed) { |
| 334 |
|
| 335 |
if (datatype->getBasicDatatypeType() == CDatatype::DBT_STRING) { |
| 336 |
CDataLiteralStringValue* dataLitStringValue = CObjectParameterizingAllocator<CDataLiteralStringValue, CContext*>::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 337 |
if (infinite) { |
| 338 |
dataLitStringValue->initValueFromInfiniteLength(); |
| 339 |
} else { |
| 340 |
dataLitStringValue->initValueFromLength(length); |
| 341 |
} |
| 342 |
CDataLiteral* dataLitString = CObjectParameterizingAllocator<CDataLiteral, CContext*>::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 343 |
dataLitString->initDataLiteral("",datatype); |
| 344 |
dataLitString->setDataLiteralValue(dataLitStringValue); |
| 345 |
adaptedDataLiteral = dataLitString; |
| 346 |
|
| 347 |
|
| 348 |
} else if (datatype->getBasicDatatypeType() == CDatatype::DBT_IRI) { |
| 349 |
CDataLiteralIRIValue* dataLitIRIValue = CObjectAllocator<CDataLiteralIRIValue>::allocateAndConstruct(mMemMan); |
| 350 |
if (infinite) { |
| 351 |
dataLitIRIValue->initValueFromInfiniteLength(); |
| 352 |
} else { |
| 353 |
dataLitIRIValue->initValueFromLength(length); |
| 354 |
} |
| 355 |
CDataLiteral* dataLitIRI = CObjectParameterizingAllocator<CDataLiteral, CContext*>::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 356 |
dataLitIRI->initDataLiteral("",datatype); |
| 357 |
dataLitIRI->setDataLiteralValue(dataLitIRIValue); |
| 358 |
adaptedDataLiteral = dataLitIRI; |
| 359 |
|
| 360 |
} else if (datatype->getBasicDatatypeType() == CDatatype::DBT_HEXBINARY) { |
| 361 |
CDataLiteralBinaryHexDataValue* dataLitHexBinaryValue = CObjectParameterizingAllocator< CDataLiteralBinaryHexDataValue,CContext* >::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 362 |
if (infinite) { |
| 363 |
dataLitHexBinaryValue->initValueFromInfiniteLength(); |
| 364 |
} else { |
| 365 |
dataLitHexBinaryValue->initValueFromLength(length); |
| 366 |
} |
| 367 |
CDataLiteral* dataLitIRI = CObjectParameterizingAllocator<CDataLiteral, CContext*>::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 368 |
dataLitIRI->initDataLiteral("", datatype); |
| 369 |
dataLitIRI->setDataLiteralValue(dataLitHexBinaryValue); |
| 370 |
adaptedDataLiteral = dataLitIRI; |
| 371 |
|
| 372 |
} else if (datatype->getBasicDatatypeType() == CDatatype::DBT_BASE64BINARY) { |
| 373 |
CDataLiteralBinaryBase64DataValue* dataLitBase64BinaryValue = CObjectParameterizingAllocator< CDataLiteralBinaryBase64DataValue,CContext* >::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 374 |
if (infinite) { |
| 375 |
dataLitBase64BinaryValue->initValueFromInfiniteLength(); |
| 376 |
} else { |
| 377 |
dataLitBase64BinaryValue->initValueFromLength(length); |
| 378 |
} |
| 379 |
CDataLiteral* dataLitIRI = CObjectParameterizingAllocator<CDataLiteral, CContext*>::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 380 |
dataLitIRI->initDataLiteral("",datatype); |
| 381 |
dataLitIRI->setDataLiteralValue(dataLitBase64BinaryValue); |
| 382 |
adaptedDataLiteral = dataLitIRI; |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
} |
| 387 |
return adaptedDataLiteral; |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
CConcept* CDataLiteralNormalizerPreProcess::createConcept() { |
| 393 |
CConcept* concept = CObjectAllocator<CConcept>::allocateAndConstruct(mMemMan); |
| 394 |
cint64 nextConTag = mTBox->getNextConceptID(); |
| 395 |
concept->initConcept(); |
| 396 |
concept->setTag(nextConTag); |
| 397 |
mConceptVector->setData(nextConTag,concept); |
| 398 |
return concept; |
| 399 |
} |
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
CConcept* CDataLiteralNormalizerPreProcess::addConceptOperand(CConcept* concept, CConcept* operand, bool negated) { |
| 404 |
CSortedNegLinker<CConcept*>* opConLinker = CObjectAllocator< CSortedNegLinker<CConcept*> >::allocateAndConstruct(mMemMan); |
| 405 |
opConLinker->init(operand,negated); |
| 406 |
concept->addOperandLinker(opConLinker); |
| 407 |
concept->incOperandCount(); |
| 408 |
return concept; |
| 409 |
} |
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseBooleanValue(const QString& valueString, CPreProcessContext* context) { |
| 414 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 415 |
bool parsingSuccessfull = false; |
| 416 |
bool booleanValue = false; |
| 417 |
if (valueString.toUpper().contains("TRUE")) { |
| 418 |
booleanValue = true; |
| 419 |
parsingSuccessfull = true; |
| 420 |
} else if (valueString.toUpper().contains("FALSE")) { |
| 421 |
booleanValue = false; |
| 422 |
parsingSuccessfull = true; |
| 423 |
} |
| 424 |
if (parsingSuccessfull) { |
| 425 |
CDataLiteralBooleanValue* dataLitBooleanValue = CObjectAllocator<CDataLiteralBooleanValue>::allocateAndConstruct(mMemMan); |
| 426 |
dataLitBooleanValue->initValueFromBoolean(booleanValue); |
| 427 |
dataLiteralValue = dataLitBooleanValue; |
| 428 |
} |
| 429 |
return dataLiteralValue; |
| 430 |
} |
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseDoubleValue(const QString& valueString, CPreProcessContext* context) { |
| 437 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 438 |
bool parsingSuccessfull = false; |
| 439 |
double doubleDataValue = valueString.toDouble(&parsingSuccessfull); |
| 440 |
if (parsingSuccessfull) { |
| 441 |
CDataLiteralDoubleValue* dataLitDoubleValue = CObjectAllocator<CDataLiteralDoubleValue>::allocateAndConstruct(mMemMan); |
| 442 |
dataLitDoubleValue->initValueFromDouble(doubleDataValue); |
| 443 |
dataLiteralValue = dataLitDoubleValue; |
| 444 |
} |
| 445 |
return dataLiteralValue; |
| 446 |
} |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseFloatValue(const QString& valueString, CPreProcessContext* context) { |
| 451 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 452 |
bool parsingSuccessfull = false; |
| 453 |
float floatDataValue = valueString.toFloat(&parsingSuccessfull); |
| 454 |
if (parsingSuccessfull) { |
| 455 |
CDataLiteralFloatValue* dataLitFloatValue = CObjectAllocator<CDataLiteralFloatValue>::allocateAndConstruct(mMemMan); |
| 456 |
dataLitFloatValue->initValueFromFloat(floatDataValue); |
| 457 |
dataLiteralValue = dataLitFloatValue; |
| 458 |
} |
| 459 |
return dataLiteralValue; |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseIntegerValue(const QString& valueString, CPreProcessContext* context) { |
| 464 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 465 |
bool parsingSuccessfull = false; |
| 466 |
QString tmpValueString(valueString); |
| 467 |
bool negative = tmpValueString.contains("-"); |
| 468 |
tmpValueString = tmpValueString.replace("-",""); |
| 469 |
cuint64 integerDataValue = tmpValueString.toULongLong(&parsingSuccessfull); |
| 470 |
if (parsingSuccessfull) { |
| 471 |
CDataLiteralRealValue* dataLitRatValue = CObjectAllocator<CDataLiteralRealValue>::allocateAndConstruct(mMemMan); |
| 472 |
dataLitRatValue->initRationalValueFromInteger(integerDataValue,negative); |
| 473 |
dataLiteralValue = dataLitRatValue; |
| 474 |
} else { |
| 475 |
if (tmpValueString.toUpper().contains("INF")) { |
| 476 |
CDataLiteralRealValue* dataLitRatValue = CObjectAllocator<CDataLiteralRealValue>::allocateAndConstruct(mMemMan); |
| 477 |
dataLitRatValue->initRationalValueFromInfinite(negative); |
| 478 |
dataLiteralValue = dataLitRatValue; |
| 479 |
} |
| 480 |
} |
| 481 |
return dataLiteralValue; |
| 482 |
} |
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseDecimalValue(const QString& valueString, CPreProcessContext* context) { |
| 487 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 488 |
bool parsingSuccessfull = false; |
| 489 |
cuint64 integerValue = 0; |
| 490 |
cuint64 decimalValue = 0; |
| 491 |
QString tmpValueString(valueString); |
| 492 |
bool negative = tmpValueString.contains("-"); |
| 493 |
tmpValueString = tmpValueString.replace("-",""); |
| 494 |
QStringList dataValueStringList = tmpValueString.split("."); |
| 495 |
if (dataValueStringList.size() < 2) { |
| 496 |
dataValueStringList = tmpValueString.split(","); |
| 497 |
} |
| 498 |
int precedingZerors = 0; |
| 499 |
if (dataValueStringList.size() >= 2) { |
| 500 |
bool integerParsingSuccessfull = false; |
| 501 |
bool decimalParsingSuccessfull = false; |
| 502 |
QString firstDataValueString = dataValueStringList.takeFirst().trimmed(); |
| 503 |
QString secondDataValueString = dataValueStringList.takeFirst().trimmed(); |
| 504 |
if (firstDataValueString.isEmpty()) { |
| 505 |
integerValue = 0; |
| 506 |
integerParsingSuccessfull = true; |
| 507 |
} else { |
| 508 |
integerValue = firstDataValueString.toULongLong(&integerParsingSuccessfull); |
| 509 |
} |
| 510 |
if (secondDataValueString.isEmpty()) { |
| 511 |
decimalValue = 0; |
| 512 |
decimalParsingSuccessfull = true; |
| 513 |
} else { |
| 514 |
decimalValue = secondDataValueString.toULongLong(&decimalParsingSuccessfull); |
| 515 |
if (secondDataValueString.startsWith("0") && secondDataValueString.size() > 1) { |
| 516 |
++precedingZerors; |
| 517 |
while (secondDataValueString.size() > precedingZerors && secondDataValueString.at(precedingZerors) == '0') { |
| 518 |
++precedingZerors; |
| 519 |
} |
| 520 |
} |
| 521 |
} |
| 522 |
parsingSuccessfull = integerParsingSuccessfull & decimalParsingSuccessfull; |
| 523 |
} |
| 524 |
if (parsingSuccessfull) { |
| 525 |
CDataLiteralRealValue* dataLitRatValue = CObjectAllocator<CDataLiteralRealValue>::allocateAndConstruct(mMemMan); |
| 526 |
dataLitRatValue->initRationalValueFromDecimal(integerValue,decimalValue,negative,precedingZerors); |
| 527 |
dataLiteralValue = dataLitRatValue; |
| 528 |
} |
| 529 |
if (!dataLiteralValue) { |
| 530 |
dataLiteralValue = parseIntegerValue(valueString,context); |
| 531 |
} |
| 532 |
return dataLiteralValue; |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseRationalValue(const QString& valueString, CPreProcessContext* context) { |
| 538 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 539 |
bool parsingSuccessfull = false; |
| 540 |
cuint64 numeratorValue = 0; |
| 541 |
cuint64 denominatorValue = 0; |
| 542 |
QString tmpValueString(valueString); |
| 543 |
bool negative = tmpValueString.contains("-"); |
| 544 |
tmpValueString = tmpValueString.replace("-",""); |
| 545 |
QStringList dataValueStringList = tmpValueString.split("/"); |
| 546 |
if (dataValueStringList.size() >= 2) { |
| 547 |
bool numeratorParsingSuccessfull = false; |
| 548 |
bool denominatorParsingSuccessfull = false; |
| 549 |
QString firstDataValueString = dataValueStringList.takeFirst().trimmed(); |
| 550 |
QString secondDataValueString = dataValueStringList.takeFirst().trimmed(); |
| 551 |
numeratorValue = firstDataValueString.toULongLong(&numeratorParsingSuccessfull); |
| 552 |
denominatorValue = secondDataValueString.toULongLong(&denominatorParsingSuccessfull); |
| 553 |
parsingSuccessfull = numeratorParsingSuccessfull & denominatorParsingSuccessfull; |
| 554 |
} |
| 555 |
if (parsingSuccessfull) { |
| 556 |
CDataLiteralRealValue* dataLitRatValue = CObjectAllocator<CDataLiteralRealValue>::allocateAndConstruct(mMemMan); |
| 557 |
dataLitRatValue->initRationalValueFromFraction(numeratorValue,denominatorValue,negative); |
| 558 |
dataLiteralValue = dataLitRatValue; |
| 559 |
} |
| 560 |
if (!dataLiteralValue) { |
| 561 |
dataLiteralValue = parseDecimalValue(valueString,context); |
| 562 |
} |
| 563 |
return dataLiteralValue; |
| 564 |
} |
| 565 |
|
| 566 |
|
| 567 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseRealValue(const QString& valueString, CPreProcessContext* context) { |
| 568 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 569 |
if (!dataLiteralValue) { |
| 570 |
dataLiteralValue = parseRationalValue(valueString,context); |
| 571 |
} |
| 572 |
return dataLiteralValue; |
| 573 |
} |
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseStringValue(const QString& valueString, bool parseLanguageString, CPreProcessContext* context) { |
| 578 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 579 |
if (!dataLiteralValue) { |
| 580 |
QString stringValueString = valueString; |
| 581 |
QString languageValueString; |
| 582 |
if (parseLanguageString) { |
| 583 |
cint64 lastLanguageSep = valueString.lastIndexOf("@"); |
| 584 |
if (lastLanguageSep > 0) { |
| 585 |
stringValueString = valueString.mid(0,lastLanguageSep); |
| 586 |
if (!stringValueString.trimmed().isEmpty()) { |
| 587 |
languageValueString = valueString.mid(lastLanguageSep + 1); |
| 588 |
bool validLanguageTag = true; |
| 589 |
bool firstBindOccurred = false; |
| 590 |
for (cint64 i = 0; i < languageValueString.length() && validLanguageTag; ++i) { |
| 591 |
QChar ch = languageValueString.at(i); |
| 592 |
if (!firstBindOccurred && i > 3) { |
| 593 |
validLanguageTag = false; |
| 594 |
} |
| 595 |
if (ch == QChar('-')) { |
| 596 |
firstBindOccurred = true; |
| 597 |
} |
| 598 |
if (!ch.isLetterOrNumber() && ch != QChar('-')) { |
| 599 |
validLanguageTag = false; |
| 600 |
} |
| 601 |
} |
| 602 |
|
| 603 |
if (!validLanguageTag) { |
| 604 |
stringValueString = valueString; |
| 605 |
languageValueString = ""; |
| 606 |
} |
| 607 |
} else { |
| 608 |
stringValueString = valueString; |
| 609 |
languageValueString = ""; |
| 610 |
} |
| 611 |
} |
| 612 |
} |
| 613 |
|
| 614 |
languageValueString = languageValueString.toLower(); |
| 615 |
CDataLiteralStringValue* dataLitStringValue = CObjectParameterizingAllocator<CDataLiteralStringValue,CContext*>::allocateAndConstructAndParameterize(mMemMan, mBoxContext); |
| 616 |
dataLitStringValue->initValueFromString(stringValueString,languageValueString); |
| 617 |
dataLiteralValue = dataLitStringValue; |
| 618 |
|
| 619 |
} |
| 620 |
return dataLiteralValue; |
| 621 |
} |
| 622 |
|
| 623 |
|
| 624 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseDateTimeValue(const QString& valueString, CPreProcessContext* context) { |
| 625 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 626 |
if (!dataLiteralValue) { |
| 627 |
QString dateTimeValueString = valueString; |
| 628 |
QString timeZoneOffsetValueString; |
| 629 |
|
| 630 |
if (valueString.contains("-") || valueString.contains("+")) { |
| 631 |
cint64 lastZoneMinusSep = valueString.lastIndexOf("-"); |
| 632 |
cint64 lastZonePlusSep = valueString.lastIndexOf("+"); |
| 633 |
cint64 lastZoneSep = qMax(lastZonePlusSep,lastZoneMinusSep); |
| 634 |
if (lastZoneSep >= 12) { |
| 635 |
dateTimeValueString = valueString.mid(0,lastZoneSep); |
| 636 |
timeZoneOffsetValueString = valueString.mid(lastZoneSep+1); |
| 637 |
} |
| 638 |
} |
| 639 |
|
| 640 |
QDateTime dateTime = QDateTime::fromString(dateTimeValueString,Qt::ISODate); |
| 641 |
if (dateTime.isValid()) { |
| 642 |
QDate tmpDate(dateTime.date()); |
| 643 |
QTime tmpTime(dateTime.time()); |
| 644 |
QDateTime tmpDateTime(tmpDate,tmpTime,Qt::UTC); |
| 645 |
|
| 646 |
if (dateTime.timeSpec() == Qt::LocalTime) { |
| 647 |
dateTime = tmpDateTime; |
| 648 |
} |
| 649 |
cuint64 timeZoneOffset = 0; |
| 650 |
if (dateTime.timeSpec() == Qt::OffsetFromUTC) { |
| 651 |
QDateTime utcDateTime = dateTime.toUTC(); |
| 652 |
timeZoneOffset = utcDateTime.secsTo(tmpDateTime); |
| 653 |
dateTime = utcDateTime; |
| 654 |
} |
| 655 |
|
| 656 |
CDataLiteralDateTimeValue* dataLitDateTimeValue = CObjectAllocator<CDataLiteralDateTimeValue>::allocateAndConstruct(mMemMan); |
| 657 |
dataLitDateTimeValue->initValueFromDataTime(dateTime,timeZoneOffset); |
| 658 |
dataLiteralValue = dataLitDateTimeValue; |
| 659 |
|
| 660 |
} |
| 661 |
} |
| 662 |
return dataLiteralValue; |
| 663 |
} |
| 664 |
|
| 665 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseIRIValue(const QString& valueString, CPreProcessContext* context) { |
| 666 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 667 |
if (!dataLiteralValue) { |
| 668 |
CDataLiteralIRIValue* dataLitIRIValue = CObjectAllocator<CDataLiteralIRIValue>::allocateAndConstruct(mMemMan); |
| 669 |
dataLitIRIValue->initValueFromIRIString(valueString.trimmed()); |
| 670 |
dataLiteralValue = dataLitIRIValue; |
| 671 |
|
| 672 |
} |
| 673 |
return dataLiteralValue; |
| 674 |
} |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseXMLValue(const QString& valueString, CPreProcessContext* context) { |
| 680 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 681 |
if (!dataLiteralValue) { |
| 682 |
QDomDocument domDocument; |
| 683 |
if (domDocument.setContent(valueString,true)) { |
| 684 |
QString xmlValueString = domDocument.toString(); |
| 685 |
if (!xmlValueString.isEmpty()) { |
| 686 |
CDataLiteralXMLValue* dataLitXMLValue = CObjectAllocator<CDataLiteralXMLValue>::allocateAndConstruct(mMemMan); |
| 687 |
dataLitXMLValue->initValueFromXMLString(valueString.trimmed()); |
| 688 |
dataLiteralValue = dataLitXMLValue; |
| 689 |
} |
| 690 |
} |
| 691 |
} |
| 692 |
return dataLiteralValue; |
| 693 |
} |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
cint64 CDataLiteralNormalizerPreProcess::getBinaryFromHex(QChar character) { |
| 698 |
cint64 unicode = character.unicode(); |
| 699 |
if (unicode > 127) { |
| 700 |
return -1; |
| 701 |
} |
| 702 |
return mHexStringBinaryDataConvArray[unicode]; |
| 703 |
} |
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
cint64 CDataLiteralNormalizerPreProcess::getBinaryFromBase64(QChar character) { |
| 708 |
cint64 unicode = character.unicode(); |
| 709 |
if (unicode > 127) { |
| 710 |
return -1; |
| 711 |
} |
| 712 |
return mBase64StringBinaryDataConvArray[unicode]; |
| 713 |
} |
| 714 |
|
| 715 |
|
| 716 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseBinaryHexValue(const QString& valueString, CPreProcessContext* context) { |
| 717 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 718 |
if (!dataLiteralValue) { |
| 719 |
QString dataValueString(valueString); |
| 720 |
int dataValueStringLength = dataValueString.length(); |
| 721 |
unsigned char* tmpByteData = new unsigned char[dataValueStringLength/2+1]; |
| 722 |
cint64 byteDataLength = 0; |
| 723 |
|
| 724 |
|
| 725 |
cint64 byteParts[2]; |
| 726 |
cint64 currentBytePart = 0; |
| 727 |
|
| 728 |
for (int i = 0; i < dataValueStringLength; ++i) { |
| 729 |
QChar dataChar = dataValueString[i]; |
| 730 |
cint64 dataBytePart = getBinaryFromHex(dataChar); |
| 731 |
if (dataBytePart != -1) { |
| 732 |
byteParts[currentBytePart++] = dataBytePart; |
| 733 |
if (currentBytePart >= 2) { |
| 734 |
currentBytePart = 0; |
| 735 |
cint64 nextDataByte = byteParts[0]<<4 + byteParts[1]; |
| 736 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte; |
| 737 |
} |
| 738 |
} |
| 739 |
} |
| 740 |
|
| 741 |
if (currentBytePart == 1) { |
| 742 |
cint64 nextDataByte = byteParts[0]<<4; |
| 743 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte; |
| 744 |
} |
| 745 |
|
| 746 |
|
| 747 |
CDataLiteralBinaryHexDataValue* dataLitHexBinaryValue = CObjectParameterizingAllocator< CDataLiteralBinaryHexDataValue,CContext* >::allocateAndConstructAndParameterize(mMemMan,mBoxContext); |
| 748 |
dataLitHexBinaryValue->initValueFromData(tmpByteData,byteDataLength); |
| 749 |
delete [] tmpByteData; |
| 750 |
dataLiteralValue = dataLitHexBinaryValue; |
| 751 |
|
| 752 |
} |
| 753 |
return dataLiteralValue; |
| 754 |
} |
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::parseBinaryBase64Value(const QString& valueString, CPreProcessContext* context) { |
| 763 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 764 |
if (!dataLiteralValue) { |
| 765 |
QString dataValueString(valueString); |
| 766 |
int dataValueStringLength = dataValueString.length(); |
| 767 |
unsigned char* tmpByteData = new unsigned char[dataValueStringLength*3/4+1]; |
| 768 |
cint64 byteDataLength = 0; |
| 769 |
|
| 770 |
|
| 771 |
cint64 byteParts[4]; |
| 772 |
cint64 currentBytePart = 0; |
| 773 |
|
| 774 |
for (int i = 0; i < dataValueStringLength; ++i) { |
| 775 |
QChar dataChar = dataValueString[i]; |
| 776 |
cint64 dataBytePart = getBinaryFromBase64(dataChar); |
| 777 |
if (dataBytePart != -1) { |
| 778 |
byteParts[currentBytePart++] = dataBytePart; |
| 779 |
if (currentBytePart >= 4) { |
| 780 |
currentBytePart = 0; |
| 781 |
cint64 nextDataByte1 = byteParts[0]<<2 + byteParts[1]>>4; |
| 782 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte1; |
| 783 |
cint64 nextDataByte2 = byteParts[1]<<4 + byteParts[2]>>2; |
| 784 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte2; |
| 785 |
cint64 nextDataByte3 = byteParts[2]<<6 + byteParts[3]; |
| 786 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte3; |
| 787 |
} |
| 788 |
} |
| 789 |
} |
| 790 |
|
| 791 |
if (currentBytePart == 3) { |
| 792 |
cint64 nextDataByte1 = byteParts[0]<<2 + byteParts[1]>>4; |
| 793 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte1; |
| 794 |
cint64 nextDataByte2 = byteParts[1]<<4 + byteParts[2]>>2; |
| 795 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte2; |
| 796 |
cint64 nextDataByte3 = byteParts[2]<<6; |
| 797 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte3; |
| 798 |
} |
| 799 |
if (currentBytePart == 2) { |
| 800 |
cint64 nextDataByte1 = byteParts[0]<<2 + byteParts[1]>>4; |
| 801 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte1; |
| 802 |
cint64 nextDataByte2 = byteParts[1]<<4; |
| 803 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte2; |
| 804 |
} |
| 805 |
if (currentBytePart == 1) { |
| 806 |
cint64 nextDataByte1 = byteParts[0]<<2; |
| 807 |
tmpByteData[byteDataLength++] = (unsigned char)nextDataByte1; |
| 808 |
} |
| 809 |
|
| 810 |
|
| 811 |
CDataLiteralBinaryBase64DataValue* dataLitBase64BinaryValue = CObjectParameterizingAllocator< CDataLiteralBinaryBase64DataValue,CContext* >::allocateAndConstructAndParameterize(mMemMan,mBoxContext); |
| 812 |
dataLitBase64BinaryValue->initValueFromData(tmpByteData,byteDataLength); |
| 813 |
delete [] tmpByteData; |
| 814 |
dataLiteralValue = dataLitBase64BinaryValue; |
| 815 |
|
| 816 |
} |
| 817 |
return dataLiteralValue; |
| 818 |
} |
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
CDataLiteralValue* CDataLiteralNormalizerPreProcess::createDataLiteralValue(CDataLiteral* dataLiteral, CPreProcessContext* context) { |
| 823 |
CDataLiteralValue* dataLiteralValue = nullptr; |
| 824 |
CDatatype* datatype = dataLiteral->getDatatype(); |
| 825 |
if (datatype) { |
| 826 |
QString dataLexicalValueString = dataLiteral->getLexicalDataLiteralValueString(); |
| 827 |
QString datatypeIRI = datatype->getDatatypeIRI(); |
| 828 |
if (datatypeIRI == PREFIX_XML_INTEGER_DATATYPE) { |
| 829 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 830 |
} else if (datatypeIRI == PREFIX_XML_DECIMAL_DATATYPE) { |
| 831 |
dataLiteralValue = parseDecimalValue(dataLexicalValueString,context); |
| 832 |
} else if (datatypeIRI == PREFIX_OWL_RATIONAL_DATATYPE) { |
| 833 |
dataLiteralValue = parseRationalValue(dataLexicalValueString,context); |
| 834 |
} else if (datatypeIRI == PREFIX_OWL_REAL_DATATYPE) { |
| 835 |
dataLiteralValue = parseRealValue(dataLexicalValueString,context); |
| 836 |
|
| 837 |
} else if (datatypeIRI == PREFIX_XML_NONNEGATIVEINTEGER_DATATYPE) { |
| 838 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 839 |
} else if (datatypeIRI == PREFIX_XML_POSITIVEINTEGER_DATATYPE) { |
| 840 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 841 |
} else if (datatypeIRI == PREFIX_XML_NONPOSITIVEINTEGER_DATATYPE) { |
| 842 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 843 |
} else if (datatypeIRI == PREFIX_XML_NEGATIVEINTEGER_DATATYPE) { |
| 844 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 845 |
} else if (datatypeIRI == PREFIX_XML_LONG_DATATYPE) { |
| 846 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 847 |
} else if (datatypeIRI == PREFIX_XML_INT_DATATYPE) { |
| 848 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 849 |
} else if (datatypeIRI == PREFIX_XML_SHORT_DATATYPE) { |
| 850 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 851 |
} else if (datatypeIRI == PREFIX_XML_BYTE_DATATYPE) { |
| 852 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 853 |
} else if (datatypeIRI == PREFIX_XML_UNSIGNEDLONG_DATATYPE) { |
| 854 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 855 |
} else if (datatypeIRI == PREFIX_XML_UNSIGNEDINT_DATATYPE) { |
| 856 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 857 |
} else if (datatypeIRI == PREFIX_XML_UNSIGNEDSHORT_DATATYPE) { |
| 858 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 859 |
} else if (datatypeIRI == PREFIX_XML_UNSIGNEDBYTE_DATATYPE) { |
| 860 |
dataLiteralValue = parseIntegerValue(dataLexicalValueString,context); |
| 861 |
|
| 862 |
|
| 863 |
} else if (datatypeIRI == PREFIX_XML_PLAINLITERAL_DATATYPE) { |
| 864 |
dataLiteralValue = parseStringValue(dataLexicalValueString,true,context); |
| 865 |
} else if (datatypeIRI == PREFIX_XML_STRING_DATATYPE) { |
| 866 |
dataLiteralValue = parseStringValue(dataLexicalValueString,false,context); |
| 867 |
} else if (datatypeIRI == PREFIX_XML_NORMALIZEDSTRING_DATATYPE) { |
| 868 |
dataLiteralValue = parseStringValue(dataLexicalValueString,false,context); |
| 869 |
} else if (datatypeIRI == PREFIX_XML_TOKEN_DATATYPE) { |
| 870 |
dataLiteralValue = parseStringValue(dataLexicalValueString,false,context); |
| 871 |
} else if (datatypeIRI == PREFIX_XML_NAME_DATATYPE) { |
| 872 |
dataLiteralValue = parseStringValue(dataLexicalValueString,false,context); |
| 873 |
} else if (datatypeIRI == PREFIX_XML_NCNAME_DATATYPE) { |
| 874 |
dataLiteralValue = parseStringValue(dataLexicalValueString,false,context); |
| 875 |
} else if (datatypeIRI == PREFIX_XML_NMTOKEN_DATATYPE) { |
| 876 |
dataLiteralValue = parseStringValue(dataLexicalValueString,false,context); |
| 877 |
} else if (datatypeIRI == PREFIX_XML_LANGUAGE_DATATYPE) { |
| 878 |
dataLiteralValue = parseStringValue(dataLexicalValueString,false,context); |
| 879 |
|
| 880 |
|
| 881 |
} else if (datatypeIRI == PREFIX_XML_BOOLEAN_DATATYPE) { |
| 882 |
dataLiteralValue = parseBooleanValue(dataLexicalValueString,context); |
| 883 |
|
| 884 |
|
| 885 |
} else if (datatypeIRI == PREFIX_XML_DOUBLE_DATATYPE) { |
| 886 |
dataLiteralValue = parseDoubleValue(dataLexicalValueString,context); |
| 887 |
} else if (datatypeIRI == PREFIX_XML_FLOAT_DATATYPE) { |
| 888 |
dataLiteralValue = parseFloatValue(dataLexicalValueString,context); |
| 889 |
|
| 890 |
|
| 891 |
} else if (datatypeIRI == PREFIX_XML_IRI_DATATYPE) { |
| 892 |
dataLiteralValue = parseIRIValue(dataLexicalValueString,context); |
| 893 |
|
| 894 |
} else if (datatypeIRI == PREFIX_XML_XML_DATATYPE) { |
| 895 |
dataLiteralValue = parseXMLValue(dataLexicalValueString,context); |
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
} else if (datatypeIRI == PREFIX_XML_BINARYHEX_DATATYPE) { |
| 900 |
dataLiteralValue = parseBinaryHexValue(dataLexicalValueString,context); |
| 901 |
} else if (datatypeIRI == PREFIX_XML_BINARYBASE64_DATATYPE) { |
| 902 |
dataLiteralValue = parseBinaryBase64Value(dataLexicalValueString,context); |
| 903 |
|
| 904 |
|
| 905 |
} else if (datatypeIRI == PREFIX_XML_DATETIME_DATATYPE) { |
| 906 |
dataLiteralValue = parseDateTimeValue(dataLexicalValueString,context); |
| 907 |
} else if (datatypeIRI == PREFIX_XML_DATETIMESTAMP_DATATYPE) { |
| 908 |
dataLiteralValue = parseDateTimeValue(dataLexicalValueString,context); |
| 909 |
|
| 910 |
} else { |
| 911 |
LOG(WARNING,"::Konclude::Reasoner::Preprocess::DataLiteralNormaliser",logTr("Unknown or not supported datatype '%1', cannot parse '%2'.").arg(datatypeIRI).arg(dataLexicalValueString),this); |
| 912 |
} |
| 913 |
|
| 914 |
if (!dataLiteralValue) { |
| 915 |
LOG(WARNING,"::Konclude::Reasoner::Preprocess::DataLiteralNormaliser",logTr("Failed to parse literal '%1' for datatype '%2'.").arg(dataLexicalValueString).arg(datatypeIRI),this); |
| 916 |
} |
| 917 |
} |
| 918 |
return dataLiteralValue; |
| 919 |
} |
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
}; // end namespace Preprocess |
| 924 |
|
| 925 |
}; // end namespace Reasoner |
| 926 |
|
| 927 |
}; // end namespace Konclude |