code: public static Partition fromString(String strForm) {
  
          if (strForm == null || strForm.isEmpty()) throw new IllegalArgumentException("null or empty string provided");
  
          Partition p = new Partition();
          int index = 0;
          if (strForm.charAt(0) == '[') {
              index++;
          }
          int endIndex;
          if (strForm.charAt(strForm.length() - 1) == ']') {
              endIndex = strForm.length() - 2;
          } else {
              endIndex = strForm.length() - 1;
          }
          int currentCell = -1;
          int numStart = -1;
          while (index <= endIndex) {
              char c = strForm.charAt(index);
              if (Character.isDigit(c)) {
                  if (numStart == -1) {
                      numStart = index;
                  }
              } else if (c == ',') {
                  int element = Integer.parseInt(strForm.substring(numStart, index));
                  if (currentCell == -1) {
                      p.addCell(element);
                      currentCell = 0;
                  } else {
                      p.addToCell(currentCell, element);
                  }
                  numStart = -1;
              } else if (c == '|') {
                  int element = Integer.parseInt(strForm.substring(numStart, index));
                  if (currentCell == -1) {
                      p.addCell(element);
                      currentCell = 0;
                  } else {
                      p.addToCell(currentCell, element);
                  }
                  currentCell++;
                  p.addCell();
                  numStart = -1;
              }
              index++;
          }
          int lastElement = Integer.parseInt(strForm.substring(numStart, endIndex + 1));
          p.addToCell(currentCell, lastElement);
          return p;
      }
docs: Parse a string like "[0,2|1,3]" to form the partition; cells are
  separated by '|' characters and elements within the cell by commas.
  
  @param strForm the partition in string form
  @return the partition corresponding to the string
  @throws IllegalArgumentException thrown if the provided strFrom is
  null or empty