protected DefaultListModel stringToModel(String s){
  DefaultListModel result;
  String tmpStr;
  int i;
  boolean quote;
  String[] find;
  String[] replace;
  int index;
  result=new DefaultListModel();
  find=new String[]{"\"\"","\\n","\\r","\\t"};
  replace=new String[]{"\"","\n","\r","\t"};
  for (i=0; i < find.length; i++) {
    tmpStr="";
    while (s.length() > 0) {
      index=s.indexOf(find[i]);
      if (index > -1) {
        tmpStr+=s.substring(0,index) + replace[i];
        s=s.substring(index + 2);
      }
 else {
        tmpStr+=s;
        s="";
      }
    }
    s=tmpStr;
  }
  quote=false;
  tmpStr="";
  for (i=0; i < s.length(); i++) {
    if (s.charAt(i) == '"') {
      quote=!quote;
      tmpStr+="" + s.charAt(i);
    }
 else     if (s.charAt(i) == ',') {
      if (quote) {
        tmpStr+="" + s.charAt(i);
      }
 else {
        if (tmpStr.startsWith("\"")) {
          tmpStr=tmpStr.substring(1,tmpStr.length() - 1);
        }
        result.addElement(tmpStr);
        tmpStr="";
      }
    }
 else {
      tmpStr+="" + s.charAt(i);
    }
  }
  if (!tmpStr.equals("")) {
    if (tmpStr.startsWith("\"")) {
      tmpStr=tmpStr.substring(1,tmpStr.length() - 1);
    }
    result.addElement(tmpStr);
  }
  return result;
}

protected DefaultListModel stringToModel ( String s ) { DefaultListModel result ; String tmpStr ; int i ; boolean quote ; String [ ] find ; String [ ] replace ; int index ; result = new DefaultListModel ( ) ; find = new String [ ] { "\"\"" , "\\n" , "\\r" , "\\t" } ; replace = new String [ ] { "\"" , "\n" , "\r" , "\t" } ; for ( i = 0 ; i < find . length ; i ++ ) { tmpStr = "" ; while ( s . length ( ) > 0 ) { index = s . indexOf ( find [ i ] ) ; if ( index > - 1 ) { tmpStr += s . substring ( 0 , index ) + replace [ i ] ; s = s . substring ( index + 2 ) ; } else { tmpStr += s ; s = "" ; } } s = tmpStr ; } quote = false ; tmpStr = "" ; for ( i = 0 ; i < s . length ( ) ; i ++ ) { if ( s . charAt ( i ) == '"' ) { quote = ! quote ; tmpStr += "" + s . charAt ( i ) ; } else if ( s . charAt ( i ) == ',' ) { if ( quote ) { tmpStr += "" + s . charAt ( i ) ; } else { if ( tmpStr . startsWith ( "\"" ) ) { tmpStr = tmpStr . substring ( 1 , tmpStr . length ( ) - 1 ) ; } result . addElement ( tmpStr ) ; tmpStr = "" ; } } else { tmpStr += "" + s . charAt ( i ) ; } } if ( ! tmpStr . equals ( "" ) ) { if ( tmpStr . startsWith ( "\"" ) ) { tmpStr = tmpStr . substring ( 1 , tmpStr . length ( ) - 1 ) ; } result . addElement ( tmpStr ) ; } return result ; }
transforms the given , comma - separated string into a defaultlistmodel .
