@Test public void buildForConnId() throws URISyntaxException, MalformedURLException { AtomicReference<String> location = new AtomicReference<>(); location.set("www.tirasa.net"); IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> URIUtils.buildForConnId(location.get())); assertEquals(exception.getClass(), IllegalArgumentException.class); location.set("connid:test/location"); URI expectedURI = new URI(location.get().trim()); assertEquals(expectedURI, URIUtils.buildForConnId(location.get())); }
public static URI buildForConnId(final String location) throws MalformedURLException, URISyntaxException { final String candidate = location.trim(); if (!candidate.startsWith("file:") && !candidate.startsWith("connid:") && !candidate.startsWith("connids:")) { throw new IllegalArgumentException(candidate + " is not a valid URI for file or connid(s) schemes"); } URI uri; if (candidate.startsWith("file:")) { uri = new File(new URL(candidate).getFile()).getAbsoluteFile().toURI(); } else { uri = new URI(candidate); } return uri; }
URIUtils { public static URI buildForConnId(final String location) throws MalformedURLException, URISyntaxException { final String candidate = location.trim(); if (!candidate.startsWith("file:") && !candidate.startsWith("connid:") && !candidate.startsWith("connids:")) { throw new IllegalArgumentException(candidate + " is not a valid URI for file or connid(s) schemes"); } URI uri; if (candidate.startsWith("file:")) { uri = new File(new URL(candidate).getFile()).getAbsoluteFile().toURI(); } else { uri = new URI(candidate); } return uri; } }
URIUtils { public static URI buildForConnId(final String location) throws MalformedURLException, URISyntaxException { final String candidate = location.trim(); if (!candidate.startsWith("file:") && !candidate.startsWith("connid:") && !candidate.startsWith("connids:")) { throw new IllegalArgumentException(candidate + " is not a valid URI for file or connid(s) schemes"); } URI uri; if (candidate.startsWith("file:")) { uri = new File(new URL(candidate).getFile()).getAbsoluteFile().toURI(); } else { uri = new URI(candidate); } return uri; } private  URIUtils(); }
URIUtils { public static URI buildForConnId(final String location) throws MalformedURLException, URISyntaxException { final String candidate = location.trim(); if (!candidate.startsWith("file:") && !candidate.startsWith("connid:") && !candidate.startsWith("connids:")) { throw new IllegalArgumentException(candidate + " is not a valid URI for file or connid(s) schemes"); } URI uri; if (candidate.startsWith("file:")) { uri = new File(new URL(candidate).getFile()).getAbsoluteFile().toURI(); } else { uri = new URI(candidate); } return uri; } private  URIUtils(); static URI buildForConnId(final String location); }
URIUtils { public static URI buildForConnId(final String location) throws MalformedURLException, URISyntaxException { final String candidate = location.trim(); if (!candidate.startsWith("file:") && !candidate.startsWith("connid:") && !candidate.startsWith("connids:")) { throw new IllegalArgumentException(candidate + " is not a valid URI for file or connid(s) schemes"); } URI uri; if (candidate.startsWith("file:")) { uri = new File(new URL(candidate).getFile()).getAbsoluteFile().toURI(); } else { uri = new URI(candidate); } return uri; } private  URIUtils(); static URI buildForConnId(final String location);  }