code: public static List < PictureSymbol > parsePicture(final String picture,
              final char currencySymbol) {
          int factoredNumber = 0;
          boolean factorSequence = false;
          char lastChar = 0;
          PictureSymbol pictureSymbol = null;
          List < PictureSymbol > result = new LinkedList < PictureSymbol >();
          for (int i = 0; i < picture.length(); i++) {
              char c = picture.charAt(i);
              if (c != currencySymbol) {
                  c = Character.toUpperCase(c);
              }
              if (factorSequence) {
                  if (c == ')') {
                      pictureSymbol.setNumber(pictureSymbol.getNumber()
                              + factoredNumber - 1);
                      factorSequence = false;
                  } else {
                      if (Character.isDigit(c)) {
                          factoredNumber = factoredNumber * 10
                                  + Character.getNumericValue(c);
                      }
                  }
              } else {
                  if (c == '(') {
                      factoredNumber = 0;
                      factorSequence = true;
                  } else {
                      /*
                       * CR and DB are special cases where we need to ignore, the
                       * second character R or B.
                       */
                      if ((c != 'B' || lastChar != 'D')
                              && (c != 'R' || lastChar != 'C')) {
                          if (c == lastChar) {
                              pictureSymbol
                                      .setNumber(pictureSymbol.getNumber() + 1);
                          } else {
                              pictureSymbol = new PictureSymbol(c, 1);
                              result.add(pictureSymbol);
                              lastChar = c;
                          }
                      }
                  }
              }
          }
          return result;
      }
docs: Parse a COBOL picture clause. Character symbols are returned in the order
  where they are found in the picture clause. All factoring is resolved and
  each character is associated with its occurrence number.
  <p/>
  For instance: 9(3)V99XX becomes 4 entries in the list for characters 9,
  V, 9 and X. First 9 occurs 3 times, V occurs 1 time, 9 occurs 2 and X
  occurs 2.
  
  @param currencySymbol the currency symbol
  @param picture the COBOL picture clause
  @return ordered list of symbols appearing in the picture clause with
  their number of occurrences.