public static synchronized void | addTrackerExtension(org.gudy.azureus2.plugins.download.Download download, java.lang.String extension_prefix, java.lang.String extension_value)
String extension = "&" + extension_prefix + "=" + extension_value;
String value = download.getAttribute( ta_tracker_extensions );
if ( value != null ){
// if already exists then bail
if ( value.indexOf( extension ) != -1 ){
return;
}
// if prefix exists then remove existing value
if ( value.indexOf( extension_prefix ) != -1 ){
String[] bits = value.split("&");
value = "";
for ( int i=0; i<bits.length; i++ ){
String bit = bits[i].trim();
if ( bit.length() == 0 ){
continue;
}
if ( !bit.startsWith(extension_prefix.substring(1))){
value += "&" + bit;
}
}
}
value += extension;
}else{
value = extension;
}
download.setAttribute( ta_tracker_extensions, value );
|