public void addNameUrl ( final String name , final String url ) throws IOException { // need to first see if there is already an entry for this name. // if not, add url as the value. // if so, check the current url locations for name // if url exists, do nothing // if url does not exist, add, and set that as the value. String newValue = null ; String oldValue = get ( name ) ; if ( oldValue != null && oldValue . length ( ) > 0 ) { String curUrls [ ] = oldValue . split ( urlDelimiterRE ) ; boolean found = false ; for ( int i = 0 ; i < curUrls . length ; i ++ ) { if ( url . equals ( curUrls [ i ] ) ) { found = true ; break ; } } if ( found == false ) { newValue = oldValue + " " + url ; } } else { // null or empty value newValue = url ; if ( oldValue == null ) log . addName ( name ) ; } // did we find a value? if ( newValue != null ) { put ( name , newValue ) ; } }
add an url location for a name unless it already exists