summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2020-10-05 13:26:07 +0200
committerMartin Polden <mpolden@mpolden.no>2020-10-05 13:46:23 +0200
commitc2b5c6561939017b1bc36d6845a405f64b34234d (patch)
treeb64d27216e328522e127bfeb32eec7b6d4573d9e /vespajlib
parent2754be0ed9a6f9e391816ea6ed807e3e18d008a0 (diff)
Remove unused Utf8 methods
In-lined in the tests that used them.
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/abi-spec.json2
-rw-r--r--vespajlib/src/main/java/com/yahoo/text/Utf8.java14
-rw-r--r--vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java16
-rw-r--r--vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java9
-rw-r--r--vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java8
5 files changed, 17 insertions, 32 deletions
diff --git a/vespajlib/abi-spec.json b/vespajlib/abi-spec.json
index 7e7e376a8df..56c5d1b5081 100644
--- a/vespajlib/abi-spec.json
+++ b/vespajlib/abi-spec.json
@@ -3061,10 +3061,8 @@
"methods": [
"public void <init>()",
"public static java.nio.charset.Charset getCharset()",
- "public static java.lang.String toStringStd(byte[])",
"public static java.lang.String toString(byte[], int, int)",
"public static java.lang.String toString(java.nio.ByteBuffer)",
- "public static byte[] toBytesStd(java.lang.String)",
"public static byte[] toAsciiBytes(long)",
"public static byte[] toAsciiBytes(boolean)",
"public static byte[] toBytes(java.lang.String)",
diff --git a/vespajlib/src/main/java/com/yahoo/text/Utf8.java b/vespajlib/src/main/java/com/yahoo/text/Utf8.java
index b81f0447d04..e882353469e 100644
--- a/vespajlib/src/main/java/com/yahoo/text/Utf8.java
+++ b/vespajlib/src/main/java/com/yahoo/text/Utf8.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;
import java.io.IOException;
@@ -31,11 +31,6 @@ public final class Utf8 {
return StandardCharsets.UTF_8;
}
- /** To be used instead of String.String(byte[] bytes) */
- public static String toStringStd(byte[] data) {
- return new String(data, StandardCharsets.UTF_8);
- }
-
/**
* Utility method as toString(byte[]).
*
@@ -66,13 +61,6 @@ public final class Utf8 {
}
/**
- * Uses String.getBytes directly.
- */
- public static byte[] toBytesStd(String str) {
- return str.getBytes(StandardCharsets.UTF_8);
- }
-
- /**
* Encode a long as its decimal representation, i.e. toAsciiBytes(15L) will
* return "15" encoded as UTF-8. In other words it is an optimized version
* of String.valueOf() followed by UTF-8 encoding. Avoid going through
diff --git a/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java b/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java
index 7726cd7ea68..7f374441a18 100644
--- a/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/io/SlowInflateTestCase.java
@@ -1,20 +1,20 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.io;
-import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.zip.Deflater;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.yahoo.text.Utf8;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertTrue;
/**
* Check decompressor used among other things for packed summary fields.
*
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Steinar Knutsen
*/
public class SlowInflateTestCase {
@@ -27,7 +27,7 @@ public class SlowInflateTestCase {
@Before
public void setUp() throws Exception {
value = "000000000000000000000000000000000000000000000000000000000000000";
- raw = Utf8.toBytesStd(value);
+ raw = value.getBytes(StandardCharsets.UTF_8);
output = new byte[raw.length * 2];
Deflater compresser = new Deflater();
compresser.setInput(raw);
diff --git a/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java b/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java
index 44aa4ab2ff7..3b31c2b559e 100644
--- a/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/slime/JsonFormatTestCase.java
@@ -1,8 +1,7 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.slime;
import com.yahoo.text.Utf8;
-import org.junit.Ignore;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
@@ -201,7 +200,7 @@ public class JsonFormatTestCase {
public void testDecodeUnicodeAmp() {
final String json = "{\"body\":\"some text\\u0026more text\"}";
Slime slime = new Slime();
- new JsonDecoder().decode(slime, Utf8.toBytesStd(json));
+ new JsonDecoder().decode(slime, json.getBytes(StandardCharsets.UTF_8));
Cursor a = slime.get().field("body");
assertThat(a.asString(), is("some text&more text"));
}
@@ -224,7 +223,7 @@ public class JsonFormatTestCase {
" }\n";
Slime slime = new Slime();
- slime = new JsonDecoder().decode(slime, Utf8.toBytesStd(json));
+ slime = new JsonDecoder().decode(slime, json.getBytes(StandardCharsets.UTF_8));
Cursor a = slime.get().field("rules");
assertThat(a.asString(), is(str));
}
@@ -261,7 +260,7 @@ public class JsonFormatTestCase {
private void verifyEncodeDecode(String json, boolean compact) {
try {
Slime slime = new Slime();
- new JsonDecoder().decode(slime, Utf8.toBytesStd(json));
+ new JsonDecoder().decode(slime, json.getBytes(StandardCharsets.UTF_8));
ByteArrayOutputStream a = new ByteArrayOutputStream();
new JsonFormat(compact).encode(a, slime);
assertEquals(json, Utf8.toString(a.toByteArray()));
diff --git a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
index 97d0717dc0b..8293554140d 100644
--- a/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
+++ b/vespajlib/src/test/java/com/yahoo/text/Utf8TestCase.java
@@ -1,4 +1,4 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.text;
import com.google.common.collect.ImmutableMap;
@@ -24,8 +24,8 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
- * @author <a href="mailto:borud@yahoo-inc.com">Bjorn Borud</a>
- * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a>
+ * @author Bjorn Borud
+ * @author Steinar Knutsen
*/
public class Utf8TestCase {
@@ -322,7 +322,7 @@ public class Utf8TestCase {
for (char c=0; c < i; c++) {
sb.append(c);
}
- assertTrue(Arrays.equals(Utf8.toBytesStd(sb.toString()), Utf8.toBytes(sb.toString())));
+ assertTrue(Arrays.equals(sb.toString().getBytes(StandardCharsets.UTF_8), Utf8.toBytes(sb.toString())));
}
}