/** * Reads all bytes from uri. It throws an unchecked exception if an error occurs. */ public byte[] readBytes(URI uri) { return searchForSupportedProcessor(uri).readBytes(uri); }
/** * Reads all characters from uri, using the given character set. * It throws an unchecked exception if an error occurs. */ public String readString(URI uri, Charset charset) { return searchForSupportedProcessor(uri).readString(uri, charset); }
/** * Returns a detailed description of the given uri. For example HTTP URIs are completed * with the configured HTTP proxy. */ public String description(URI uri) { SchemeProcessor reader = searchForSupportedProcessor(uri); return reader.description(uri); }
@Test public void file_processor_is_always_available() { UriReader uriReader = new UriReader(new UriReader.SchemeProcessor[0]); assertThat(uriReader.searchForSupportedProcessor(testFile)).isNotNull(); }
@Test public void register_processors() throws Exception { UriReader.SchemeProcessor processor = mock(UriReader.SchemeProcessor.class); when(processor.getSupportedSchemes()).thenReturn(new String[] {"ftp"}); UriReader uriReader = new UriReader(new UriReader.SchemeProcessor[] {processor}); assertThat(uriReader.searchForSupportedProcessor(new URI("ftp://sonarsource.org"))).isNotNull(); } }
/** * Reads all bytes from uri. It throws an unchecked exception if an error occurs. */ public byte[] readBytes(URI uri) { return searchForSupportedProcessor(uri).readBytes(uri); }
/** * Reads all characters from uri, using the given character set. * It throws an unchecked exception if an error occurs. */ public String readString(URI uri, Charset charset) { return searchForSupportedProcessor(uri).readString(uri, charset); }
/** * Returns a detailed description of the given uri. For example HTTP URIs are completed * with the configured HTTP proxy. */ public String description(URI uri) { SchemeProcessor reader = searchForSupportedProcessor(uri); return reader.description(uri); }
/** * Reads all bytes from uri. It throws an unchecked exception if an error occurs. */ public byte[] readBytes(URI uri) { return searchForSupportedProcessor(uri).readBytes(uri); }
/** * Reads all characters from uri, using the given character set. * It throws an unchecked exception if an error occurs. */ public String readString(URI uri, Charset charset) { return searchForSupportedProcessor(uri).readString(uri, charset); }
/** * Returns a detailed description of the given uri. For example HTTP URIs are completed * with the configured HTTP proxy. */ public String description(URI uri) { SchemeProcessor reader = searchForSupportedProcessor(uri); return reader.description(uri); }