code: private static double parseChoiceArgument(
              MessagePattern pattern, int partIndex,
              String source, ParsePosition pos) {
          // find the best number (defined as the one with the longest parse)
          int start = pos.getIndex();
          int furthest = start;
          double bestNumber = Double.NaN;
          double tempNumber = 0.0;
          while (pattern.getPartType(partIndex) != Part.Type.ARG_LIMIT) {
              tempNumber = pattern.getNumericValue(pattern.getPart(partIndex));
              partIndex += 2;  // skip the numeric part and ignore the ARG_SELECTOR
              int msgLimit = pattern.getLimitPartIndex(partIndex);
              int len = matchStringUntilLimitPart(pattern, partIndex, msgLimit, source, start);
              if (len >= 0) {
                  int newIndex = start + len;
                  if (newIndex > furthest) {
                      furthest = newIndex;
                      bestNumber = tempNumber;
                      if (furthest == source.length()) {
                          break;
                      }
                  }
              }
              partIndex = msgLimit + 1;
          }
          if (furthest == start) {
              pos.setErrorIndex(start);
          } else {
              pos.setIndex(furthest);
          }
          return bestNumber;
      }
docs: Ported from C++ ChoiceFormat::parse().