diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-07-15 22:53:58 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-07-15 22:53:58 +0200 |
commit | 7b04ba6913de738897a84c27dd2fa4dd1cbcb5f7 (patch) | |
tree | 5d6857c56e56094c7d0f39b242745248f9350fcd /sonar-plugin-api | |
parent | aa7ffed3ca2a18e4b8b9a292cea960699e7dbd92 (diff) | |
download | sonarqube-7b04ba6913de738897a84c27dd2fa4dd1cbcb5f7.tar.gz sonarqube-7b04ba6913de738897a84c27dd2fa4dd1cbcb5f7.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java | 12 | ||||
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java | 22 |
2 files changed, 17 insertions, 17 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java index 1f7b1c54613..2d5ec5dbbbc 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java @@ -42,7 +42,7 @@ import java.util.List; * * @since 2.2 */ -public class HttpDownloader implements UriReader.SchemeProcessor, BatchComponent, ServerComponent { +public class HttpDownloader extends UriReader.SchemeProcessor implements BatchComponent, ServerComponent { public static final int TIMEOUT_MILLISECONDS = 20 * 1000; @@ -92,7 +92,7 @@ public class HttpDownloader implements UriReader.SchemeProcessor, BatchComponent return Joiner.on(", ").join(descriptions); } - public String description(URI uri) { + String description(URI uri) { return String.format("%s (%s)", uri.toString(), getProxySynthesis(uri)); } @@ -170,19 +170,19 @@ public class HttpDownloader implements UriReader.SchemeProcessor, BatchComponent } } - public String[] getSupportedSchemes() { + String[] getSupportedSchemes() { return new String[]{"http", "https"}; } - public byte[] readBytes(URI uri) { + byte[] readBytes(URI uri) { return download(uri); } - public String readString(URI uri, Charset charset) { + String readString(URI uri, Charset charset) { return downloadPlainText(uri, charset.name()); } - public InputStream openStream(URI uri) { + InputStream openStream(URI uri) { try { HttpURLConnection connection = newHttpConnection(uri); return connection.getInputStream(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java index 105d984dfd8..4a7978ed8eb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java @@ -94,29 +94,29 @@ public class UriReader implements BatchComponent, ServerComponent { return processor; } - static interface SchemeProcessor extends BatchComponent, ServerComponent { - String[] getSupportedSchemes(); + abstract static class SchemeProcessor implements BatchComponent, ServerComponent { + abstract String[] getSupportedSchemes(); - byte[] readBytes(URI uri); + abstract byte[] readBytes(URI uri); - String readString(URI uri, Charset charset); + abstract String readString(URI uri, Charset charset); - InputStream openStream(URI uri); + abstract InputStream openStream(URI uri); - String description(URI uri); + abstract String description(URI uri); } /** * This implementation is not exposed in API and is kept private. */ - private static class FileProcessor implements SchemeProcessor { + private static class FileProcessor extends SchemeProcessor { public String[] getSupportedSchemes() { return new String[]{"file"}; } - public byte[] readBytes(URI uri) { + byte[] readBytes(URI uri) { try { return Files.toByteArray(new File(uri)); } catch (IOException e) { @@ -124,7 +124,7 @@ public class UriReader implements BatchComponent, ServerComponent { } } - public String readString(URI uri, Charset charset) { + String readString(URI uri, Charset charset) { try { return Files.toString(new File(uri), charset); } catch (IOException e) { @@ -132,7 +132,7 @@ public class UriReader implements BatchComponent, ServerComponent { } } - public InputStream openStream(URI uri) { + InputStream openStream(URI uri) { try { return Files.newInputStreamSupplier(new File(uri)).getInput(); } catch (IOException e) { @@ -140,7 +140,7 @@ public class UriReader implements BatchComponent, ServerComponent { } } - public String description(URI uri) { + String description(URI uri) { return new File(uri).getAbsolutePath(); } } |