diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-11-07 09:36:47 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-11-07 09:47:35 +0100 |
commit | 5bd495c4c1d885fba933a7fabff0496935f9d427 (patch) | |
tree | 14062aa08d739acf1c94008cb04f86eb882d4995 /sonar-plugin-api | |
parent | 981a4e65cb275c2661430f29a279f6c4add03c65 (diff) | |
download | sonarqube-5bd495c4c1d885fba933a7fabff0496935f9d427.tar.gz sonarqube-5bd495c4c1d885fba933a7fabff0496935f9d427.zip |
Remove class TxtWriter
Diffstat (limited to 'sonar-plugin-api')
3 files changed, 0 insertions, 126 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java index b192078a057..149ae4178c7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java @@ -20,7 +20,6 @@ package org.sonar.api.server.ws; import org.sonar.api.utils.text.JsonWriter; -import org.sonar.api.utils.text.TxtWriter; import org.sonar.api.utils.text.XmlWriter; import java.io.OutputStream; @@ -42,8 +41,6 @@ public interface Response { XmlWriter newXmlWriter(); - TxtWriter newTxtWriter(); - Response noContent(); Stream stream(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/TxtWriter.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/TxtWriter.java deleted file mode 100644 index e52f92a4ea2..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/text/TxtWriter.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.api.utils.text; - -import java.io.IOException; -import java.io.Writer; -import java.util.List; - -import static com.google.common.collect.Lists.newArrayList; - -/** - * @since 5.0 - */ -public class TxtWriter { - - private final Writer writer; - private static final String LINE_SEPARATOR = "\r\n"; - - private TxtWriter(Writer writer) { - this.writer = writer; - } - - public static TxtWriter of(Writer writer) { - return new TxtWriter(writer); - } - - public TxtWriter values(List<String> values) { - for (String value : values) { - write(value); - write(LINE_SEPARATOR); - } - return this; - } - - public TxtWriter values(String... values) { - return values(newArrayList(values)); - } - - public void close() { - try { - writer.close(); - } catch (IOException e) { - throw new WriterException("Fail to close TXT output", e); - } - } - - private void write(String s) { - try { - writer.append(s); - } catch (IOException e) { - throw new WriterException("Fail to generate TXT with value: " + s, e); - } - } -} diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/TxtWriterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/TxtWriterTest.java deleted file mode 100644 index dca31b0d855..00000000000 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/text/TxtWriterTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.api.utils.text; - -import org.junit.Test; - -import java.io.BufferedReader; -import java.io.StringReader; -import java.io.StringWriter; - -import static org.fest.assertions.Assertions.assertThat; - -public class TxtWriterTest { - - @Test - public void write_txt() throws Exception { - StringWriter output = new StringWriter(); - TxtWriter writer = TxtWriter.of(output); - - writer.values("France", "Paris"); - writer.close(); - - BufferedReader reader = new BufferedReader(new StringReader(output.toString())); - String line1 = reader.readLine(); - assertThat(line1).isEqualTo("France"); - - String line2 = reader.readLine(); - assertThat(line2).isEqualTo("Paris"); - - assertThat(reader.readLine()).isNull(); - } - -} |