private void handleFeatSingleValue()

in uimaj-core/src/main/java/org/apache/uima/cas/impl/XmiCasDeserializer.java [1053:1131]


    private void handleFeatSingleValue(TOP fs, FeatureImpl fi, String featVal) throws SAXException {
      if ((fs instanceof AnnotationBase)
              && (fi.getCode() == TypeSystemConstants.annotBaseSofaFeatCode)) {
        // the sofa feature is set when the FS is created, can't be set separately
        return;
      }

      final int rangeClass = fi.rangeTypeClass;

      switch (rangeClass) {
        case LowLevelCAS.TYPE_CLASS_INT:
        case LowLevelCAS.TYPE_CLASS_BYTE:
        case LowLevelCAS.TYPE_CLASS_SHORT:
        case LowLevelCAS.TYPE_CLASS_LONG:
        case LowLevelCAS.TYPE_CLASS_BOOLEAN:
        case LowLevelCAS.TYPE_CLASS_FLOAT:
        case LowLevelCAS.TYPE_CLASS_DOUBLE:
        case LowLevelCAS.TYPE_CLASS_STRING: {
          CASImpl.setFeatureValueFromStringNoDocAnnotUpdate(fs, fi, featVal);
          break;
        }
        case LowLevelCAS.TYPE_CLASS_FS:
          deserializeFsRef(featVal, fi, fs);
          break;

        // For array types and list features, there are two kinds of serializations.
        // If the feature has multipleReferencesAllowed = true, then it should have been
        // serialized as a normal FS. If it has multipleReferencesAllowed = false, then
        // it should have been serialized as a multi-valued property.
        case LowLevelCAS.TYPE_CLASS_INTARRAY:
        case LowLevelCAS.TYPE_CLASS_FLOATARRAY:
        case LowLevelCAS.TYPE_CLASS_STRINGARRAY:
        case LowLevelCAS.TYPE_CLASS_BOOLEANARRAY:
        case LowLevelCAS.TYPE_CLASS_BYTEARRAY:
        case LowLevelCAS.TYPE_CLASS_SHORTARRAY:
        case LowLevelCAS.TYPE_CLASS_LONGARRAY:
        case LowLevelCAS.TYPE_CLASS_DOUBLEARRAY:
        case LowLevelCAS.TYPE_CLASS_FSARRAY: {
          if (fi.isMultipleReferencesAllowed()) {
            deserializeFsRef(featVal, fi, fs);
            break;
          }

          // is encoded with the feature reference
          // Do the multivalued property deserialization.
          // However, byte arrays have a special serialization (as hex digits)
          if (rangeClass == LowLevelCAS.TYPE_CLASS_BYTEARRAY) {
            ByteArray existingByteArray = (ByteArray) fs.getFeatureValue(fi); // might be null

            ByteArray byteArray = createOrUpdateByteArray(featVal, -1, existingByteArray);
            if (byteArray != existingByteArray) {
              CASImpl.setFeatureValueMaybeSofa(fs, fi, byteArray);
            }
          } else { // not ByteArray, but encoded locally
            String[] arrayVals = parseArray(featVal);
            handleFeatMultiValue(fs, fi, Arrays.asList(arrayVals));
          }
          break;
        }
        // For list types, we do the same as for array types UNLESS we're dealing with
        // the tail feature of another list node. In that case we do the usual FS deserialization.
        case CasSerializerSupport.TYPE_CLASS_INTLIST:
        case CasSerializerSupport.TYPE_CLASS_FLOATLIST:
        case CasSerializerSupport.TYPE_CLASS_STRINGLIST:
        case CasSerializerSupport.TYPE_CLASS_FSLIST: {
          if (fi.isMultipleReferencesAllowed()) {
            // do the usual FS deserialization
            deserializeFsRef(featVal, fi, fs);
          } else { // do the multivalued property deserialization, like arrays
            String[] arrayVals = parseArray(featVal);
            handleFeatMultiValue(fs, fi, Arrays.asList(arrayVals));
          }
          break;
        }
        default: {
          Misc.internalError(); // this should be an exhaustive case block
        }
      }
    }