public String canonicalize(String simpleURL){
  String resultURL=simpleURL;
  if (simpleURL.startsWith("ftp.")) {
    resultURL="ftp://" + simpleURL;
  }
 else   if (simpleURL.startsWith("gopher.")) {
    resultURL="gopher://" + simpleURL;
  }
 else   if (simpleURL.startsWith("/")) {
    resultURL="file:" + simpleURL;
  }
 else   if (!hasProtocolName(simpleURL)) {
    if (isSimpleHostName(simpleURL)) {
      simpleURL="www." + simpleURL + ".com";
    }
    resultURL="http://" + simpleURL;
  }
  return resultURL;
}

public String canonicalize ( String simpleURL ) { String resultURL = simpleURL ; if ( simpleURL . startsWith ( "ftp." ) ) { resultURL = "ftp://" + simpleURL ; } else if ( simpleURL . startsWith ( "gopher." ) ) { resultURL = "gopher://" + simpleURL ; } else if ( simpleURL . startsWith ( "/" ) ) { resultURL = "file:" + simpleURL ; } else if ( ! hasProtocolName ( simpleURL ) ) { if ( isSimpleHostName ( simpleURL ) ) { simpleURL = "www." + simpleURL + ".com" ; } resultURL = "http://" + simpleURL ; } return resultURL ; }
given a possibly abbreviated url ( missing a protocol name , typically ) , this method ' s job is to transform that url into a canonical form , by including a protocol name and additional syntax , if necessary . for a correctly formed url , this method should just return its argument .
