private void readArray()

in uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java [2144:2242]


  private void readArray(boolean storeIt, TypeImpl srcType, TypeImpl tgtType) throws IOException {
    final int length = readArrayLength();
    lastArrayLength = length;
    final SlotKind slotKind = tgtType.getComponentSlotKind();

    final TOP fs = storeIt ? cas.createArray(srcType, length) : null;
    currentFs = fs;

    switch (slotKind) {
      case Slot_BooleanRef:
        if (storeIt) {
          for (int i = 0; i < length; i++) {
            ((BooleanArray) fs).set(i, byte_dis.readByte() == 1);
          }
        } else {
          skipBytes(byte_dis, length);
        }
        break;

      case Slot_ByteRef:
        readIntoByteArray(((ByteArray) fs)._getTheArray(), length, storeIt);
        break;

      case Slot_ShortRef: {
        readIntoShortArray(((ShortArray) fs)._getTheArray(), length, storeIt);
        break;
      }

      case Slot_Int: {
        IntegerArray ia = (IntegerArray) fs;
        int prev = getPrevIntValue(TypeSystemConstants.intArrayTypeCode, 0);
        for (int i = 0; i < length; i++) {
          int v = readDiff(Slot_Int, prev);
          prev = v;
          if (0 == i && isUpdatePrevOK && storeIt) {
            updatePrevArray0IntValue(ia._getTypeImpl(), v);
          }
          if (storeIt) {
            ia.set(i, v);
          }
        }
        break;
      }

      case Slot_LongRef:
        readIntoLongArray(((LongArray) fs)._getTheArray(), Slot_LongRef, length, storeIt);
        break;

      case Slot_Float: {
        final FloatArray fa = (FloatArray) fs;
        for (int i = 0; i < length; i++) {
          final int floatRef = readFloat();
          if (storeIt) {
            fa.set(i, Float.intBitsToFloat(floatRef));
          }
        }
        break;
      }

      case Slot_DoubleRef:
        // if (length == 0) {
        // System.out.println("debug deser Double Array len 0, fsId = " + fs._id);
        // }
        readIntoDoubleArray(((DoubleArray) fs)._getTheArray(), Slot_DoubleRef, length, storeIt);
        break;

      case Slot_HeapRef: {
        FSArray fsa = (FSArray) fs;
        TypeImpl_array arrayType = (TypeImpl_array) fsa._getTypeImpl();
        int prev = getPrevIntValue(arrayType.getCode(), 0);
        for (int i = 0; i < length; i++) {
          final int v = readDiff(Slot_HeapRef, prev);
          prev = v;
          if (0 == i && isUpdatePrevOK && storeIt) {
            updatePrevArray0IntValue(fsa._getTypeImpl(), v);
          }
          if (storeIt) {
            final int locali = i;
            maybeStoreOrDefer_slotFixups(v, refd_fs -> fsa.set(locali, refd_fs));
          }
        }
        break;
      }
      case Slot_StrRef: {
        StringArray sa = (StringArray) fs;
        for (int i = 0; i < length; i++) {
          String s = readString(storeIt);

          if (storeIt) {
            sa.set(i, s);
          }
        }
      }
        break;

      default:
        Misc.internalError();
    } // end of switch
  }