private URI canonicalize(String uriString) throws URISyntaxException {
  if ((uriString == null) || (uriString.compareTo("localhost") == 0)) {
    uriString="//localhost";
    return new URI(uriString);
  }
  URI u=new URI(uriString);
  if (u.isAbsolute()) {
    if (u.isOpaque()) {
      String scheme=u.getScheme();
      String ssp=u.getSchemeSpecificPart();
      String frag=u.getFragment();
      URI u2=null;
      int c1index=uriString.indexOf(":");
      int c2index=uriString.lastIndexOf(":");
      if (c2index != c1index) {
        if (frag == null) {
          u2=new URI(scheme + "://" + ssp);
        }
 else {
          u2=new URI(scheme + "://" + ssp+ "#"+ frag);
        }
        return u2;
      }
      u2=new URI("//" + uriString);
      return u2;
    }
 else {
      return u;
    }
  }
 else {
    String ssp=u.getSchemeSpecificPart();
    if (ssp.startsWith("//")) {
      return u;
    }
 else {
      return new URI("//" + uriString);
    }
  }
}

private URI canonicalize ( String uriString ) throws URISyntaxException { if ( ( uriString == null ) || ( uriString . compareTo ( "localhost" ) == 0 ) ) { uriString = "//localhost" ; return new URI ( uriString ) ; } URI u = new URI ( uriString ) ; if ( u . isAbsolute ( ) ) { if ( u . isOpaque ( ) ) { String scheme = u . getScheme ( ) ; String ssp = u . getSchemeSpecificPart ( ) ; String frag = u . getFragment ( ) ; URI u2 = null ; int c1index = uriString . indexOf ( ":" ) ; int c2index = uriString . lastIndexOf ( ":" ) ; if ( c2index != c1index ) { if ( frag == null ) { u2 = new URI ( scheme + "://" + ssp ) ; } else { u2 = new URI ( scheme + "://" + ssp + "#" + frag ) ; } return u2 ; } u2 = new URI ( "//" + uriString ) ; return u2 ; } else { return u ; } } else { String ssp = u . getSchemeSpecificPart ( ) ; if ( ssp . startsWith ( "//" ) ) { return u ; } else { return new URI ( "//" + uriString ) ; } } }
creates a canonical representation of the uristring . this method performs certain translations depending on the type of uri generated by the string .
