private String _cleanSelectorString(String selector){
  SearchBuffer sb=SearchBuffer.obtainSearchBuffer();
  StringBuffer buff=sb.getStringBuffer();
  boolean lastWasSpace=true;
  int lastIndex=0;
  char[] chars=selector.toCharArray();
  int numChars=chars.length;
  String retValue=null;
  try {
    for (int counter=0; counter < numChars; counter++) {
switch (chars[counter]) {
case ' ':
        if (!lastWasSpace) {
          lastWasSpace=true;
          if (lastIndex < counter) {
            buff.append(chars,lastIndex,1 + counter - lastIndex);
          }
        }
      lastIndex=counter + 1;
    break;
case '\n':
case '\r':
case '\t':
  if (!lastWasSpace) {
    lastWasSpace=true;
    if (lastIndex < counter) {
      buff.append(chars,lastIndex,counter - lastIndex);
      buff.append(' ');
    }
  }
lastIndex=counter + 1;
break;
default :
lastWasSpace=false;
break;
}
}
if (lastWasSpace && buff.length() > 0) {
buff.setLength(buff.length() - 1);
}
 else if (lastIndex < numChars) {
buff.append(chars,lastIndex,numChars - lastIndex);
}
retValue=buff.toString();
}
  finally {
SearchBuffer.releaseSearchBuffer(sb);
}
return retValue;
}

private String _cleanSelectorString ( String selector ) { SearchBuffer sb = SearchBuffer . obtainSearchBuffer ( ) ; StringBuffer buff = sb . getStringBuffer ( ) ; boolean lastWasSpace = true ; int lastIndex = 0 ; char [ ] chars = selector . toCharArray ( ) ; int numChars = chars . length ; String retValue = null ; try { for ( int counter = 0 ; counter < numChars ; counter ++ ) { switch ( chars [ counter ] ) { case ' ' : if ( ! lastWasSpace ) { lastWasSpace = true ; if ( lastIndex < counter ) { buff . append ( chars , lastIndex , 1 + counter - lastIndex ) ; } } lastIndex = counter + 1 ; break ; case '\n' : case '\r' : case '\t' : if ( ! lastWasSpace ) { lastWasSpace = true ; if ( lastIndex < counter ) { buff . append ( chars , lastIndex , counter - lastIndex ) ; buff . append ( ' ' ) ; } } lastIndex = counter + 1 ; break ; default : lastWasSpace = false ; break ; } } if ( lastWasSpace && buff . length ( ) > 0 ) { buff . setLength ( buff . length ( ) - 1 ) ; } else if ( lastIndex < numChars ) { buff . append ( chars , lastIndex , numChars - lastIndex ) ; } retValue = buff . toString ( ) ; } finally { SearchBuffer . releaseSearchBuffer ( sb ) ; } return retValue ; }
returns a new string that contains only one space between non white space characters .
