private static String formatList(String[] stringList,String listPattern,String listCompositionPattern){
  if (listPattern == null || listCompositionPattern == null) {
    StringBuilder result=new StringBuilder();
    for (int i=0; i < stringList.length; ++i) {
      if (i > 0) {
        result.append(',');
      }
      result.append(stringList[i]);
    }
    return result.toString();
  }
  if (stringList.length > 3) {
    MessageFormat format=new MessageFormat(listCompositionPattern);
    stringList=composeList(format,stringList);
  }
  Object[] args=new Object[stringList.length + 1];
  System.arraycopy(stringList,0,args,1,stringList.length);
  args[0]=new Integer(stringList.length);
  MessageFormat format=new MessageFormat(listPattern);
  return format.format(args);
}

private static String formatList ( String [ ] stringList , String listPattern , String listCompositionPattern ) { if ( listPattern == null || listCompositionPattern == null ) { StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < stringList . length ; ++ i ) { if ( i > 0 ) { result . append ( ',' ) ; } result . append ( stringList [ i ] ) ; } return result . toString ( ) ; } if ( stringList . length > 3 ) { MessageFormat format = new MessageFormat ( listCompositionPattern ) ; stringList = composeList ( format , stringList ) ; } Object [ ] args = new Object [ stringList . length + 1 ] ; System . arraycopy ( stringList , 0 , args , 1 , stringList . length ) ; args [ 0 ] = new Integer ( stringList . length ) ; MessageFormat format = new MessageFormat ( listPattern ) ; return format . format ( args ) ; }
format a list using given pattern strings . if either of the patterns is null , then a the list is formatted by concatenation with the delimiter ' , ' .
