protected String expandFormat(String pszSrc){
  StringBuffer szDest=new StringBuffer();
  int iSrc=0;
  int nRepeat=0;
  while (iSrc < pszSrc.length()) {
    if ((iSrc == 0 || pszSrc.charAt(iSrc - 1) == ',') && pszSrc.charAt(iSrc) == '(') {
      String pszContents=extractSubstring(pszSrc + iSrc);
      String pszExpandedContents=expandFormat(pszContents);
      szDest.append(pszExpandedContents);
      iSrc=iSrc + pszContents.length() + 2;
    }
 else     if ((iSrc == 0 || pszSrc.charAt(iSrc - 1) == ',') && Character.isDigit(pszSrc.charAt(iSrc))) {
      int orig_iSrc=iSrc;
      for (; Character.isDigit(pszSrc.charAt(iSrc)); iSrc++) {
      }
      String nRepeatString=pszSrc.substring(orig_iSrc,iSrc);
      nRepeat=Integer.parseInt(nRepeatString);
      String pszContents=extractSubstring(pszSrc.substring(iSrc));
      String pszExpandedContents=expandFormat(pszContents);
      for (int i=0; i < nRepeat; i++) {
        szDest.append(pszExpandedContents);
        if (i < nRepeat - 1) {
          szDest.append(",");
        }
      }
      if (iSrc == '(') {
        iSrc+=pszContents.length() + 2;
      }
 else {
        iSrc+=pszContents.length();
      }
    }
 else {
      szDest.append(pszSrc.charAt(iSrc++));
    }
  }
  return szDest.toString();
}

protected String expandFormat ( String pszSrc ) { StringBuffer szDest = new StringBuffer ( ) ; int iSrc = 0 ; int nRepeat = 0 ; while ( iSrc < pszSrc . length ( ) ) { if ( ( iSrc == 0 || pszSrc . charAt ( iSrc - 1 ) == ',' ) && pszSrc . charAt ( iSrc ) == '(' ) { String pszContents = extractSubstring ( pszSrc + iSrc ) ; String pszExpandedContents = expandFormat ( pszContents ) ; szDest . append ( pszExpandedContents ) ; iSrc = iSrc + pszContents . length ( ) + 2 ; } else if ( ( iSrc == 0 || pszSrc . charAt ( iSrc - 1 ) == ',' ) && Character . isDigit ( pszSrc . charAt ( iSrc ) ) ) { int orig_iSrc = iSrc ; for ( ; Character . isDigit ( pszSrc . charAt ( iSrc ) ) ; iSrc ++ ) { } String nRepeatString = pszSrc . substring ( orig_iSrc , iSrc ) ; nRepeat = Integer . parseInt ( nRepeatString ) ; String pszContents = extractSubstring ( pszSrc . substring ( iSrc ) ) ; String pszExpandedContents = expandFormat ( pszContents ) ; for ( int i = 0 ; i < nRepeat ; i ++ ) { szDest . append ( pszExpandedContents ) ; if ( i < nRepeat - 1 ) { szDest . append ( "," ) ; } } if ( iSrc == '(' ) { iSrc += pszContents . length ( ) + 2 ; } else { iSrc += pszContents . length ( ) ; } } else { szDest . append ( pszSrc . charAt ( iSrc ++ ) ) ; } } return szDest . toString ( ) ; }
given a string that contains a coded size symbol , expand it out .
