if (srcStrAtts.length != destStrAtts.length) { throw new IllegalArgumentException("Src and Dest string indices differ in length!!"); } for (int i = 0; i < srcStrAtts.length; i++) { int instIndex = instSrcCompat ? srcStrAtts[i] : destStrAtts[i]; Attribute src = srcDataset.attribute(srcStrAtts[i]); Attribute dest = destDataset.attribute(destStrAtts[i]); if (!instance.isMissing(instIndex)) {    int valIndex = dest.addStringValue(src, (int)instance.value(instIndex));   instance.setValue(instIndex, (double)valIndex); } }
if (inst.dataset() == null) { throw new IllegalArgumentException("Instance has no dataset assigned!!"); } else if (inst.dataset().numAttributes() != destDataset.numAttributes()) { throw new IllegalArgumentException("Src and Dest differ in # of attributes!!"); } copyStringValues(inst, true, inst.dataset(), strAtts, destDataset, strAtts);
  protected void copyStringValues(Instance instance, boolean instSrcCompat,                                  Instances srcDataset, int []srcStrAtts,                                  Instances destDataset, int []destStrAtts) {    if (srcDataset == destDataset) {      return;    }    if (srcStrAtts.length != destStrAtts.length) {      throw new IllegalArgumentException("Src and Dest string indices differ in length!!");    }    for (int i = 0; i < srcStrAtts.length; i++) {      int instIndex = instSrcCompat ? srcStrAtts[i] : destStrAtts[i];      Attribute src = srcDataset.attribute(srcStrAtts[i]);      Attribute dest = destDataset.attribute(destStrAtts[i]);      if (!instance.isMissing(instIndex)) {        //System.err.println(instance.value(srcIndex)         //                   + " " + src.numValues()        //                   + " " + dest.numValues());        int valIndex = dest.addStringValue(src, (int)instance.value(instIndex));        // setValue here shouldn't be too slow here unless your dataset has        // squillions of string attributes        instance.setValue(instIndex, (double)valIndex);      }    }  }