static public String makeValidCdmObjectName ( String name ) { name = name . trim ( ) ; // common case no change boolean ok = true ; for ( int i = 0 ; i < name . length ( ) ; i ++ ) { int c = name . charAt ( i ) ; if ( c < 0x20 ) ok = false ; if ( c == ' ' ) ok = false ; if ( c == ' ' ) ok = false ; if ( ! ok ) break ; } if ( ok ) return name ; StringBuilder sbuff = new StringBuilder ( name . length ( ) ) ; for ( int i = 0 , len = name . length ( ) ; i < len ; i ++ ) { int c = name . charAt ( i ) ; if ( ( c == ' ' ) || ( c == ' ' ) ) sbuff . append ( ' ' ) ; else if ( c >= 0x20 ) sbuff . append ( ( char ) c ) ; } return sbuff . toString ( ) ; }
transform embedded space to _