restore ChannelBufferToString — go compatibility
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 15 Jun 2016 16:25:00 +0000 (18:25 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Wed, 15 Jun 2016 16:25:52 +0000 (18:25 +0200)
platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.java [new file with mode: 0644]
platform/platform-impl/src/org/jetbrains/io/MessageDecoder.java
platform/platform-impl/src/org/jetbrains/io/bufferToChars.kt [moved from platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.kt with 97% similarity]
platform/platform-impl/src/org/jetbrains/io/netty.kt

diff --git a/platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.java b/platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.java
new file mode 100644 (file)
index 0000000..bb2878d
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.io;
+
+import io.netty.buffer.ByteBuf;
+import org.jetbrains.annotations.NotNull;
+
+import java.io.IOException;
+
+@SuppressWarnings("unused")
+@Deprecated
+public final class ChannelBufferToString {
+  @NotNull
+  public static CharSequence readChars(@NotNull ByteBuf buffer) throws IOException {
+    return NettyKt.readUtf8(buffer);
+  }
+}
index 1020b5708b76fbd85a9702cd18b965e03a14e51a..1dc017dd568c373d974ff3fc2e74f5d66ab3e885 100644 (file)
@@ -49,7 +49,7 @@ public abstract class MessageDecoder extends Decoder {
         chunkedContent = CharBuffer.allocate(contentLength);
       }
 
-      ChannelBufferToStringKt.readIntoCharBuffer(input, readableBytes, chunkedContent);
+      BufferToCharsKt.readIntoCharBuffer(input, readableBytes, chunkedContent);
       consumedContentByteCount += readableBytes;
       input.release();
       return null;
@@ -60,7 +60,7 @@ public abstract class MessageDecoder extends Decoder {
       if (charBuffer != null) {
         chunkedContent = null;
         consumedContentByteCount = 0;
-        ChannelBufferToStringKt.readIntoCharBuffer(input, required, charBuffer);
+        BufferToCharsKt.readIntoCharBuffer(input, required, charBuffer);
         result = new CharSequenceBackedByChars(charBuffer);
       }
       else {
similarity index 97%
rename from platform/platform-impl/src/org/jetbrains/io/ChannelBufferToString.kt
rename to platform/platform-impl/src/org/jetbrains/io/bufferToChars.kt
index 8316843e3932e3fe96ab6e50bf104ef36e459087..ff4bd283d0140675a5fd9f4cb1a16cdcdc79f886 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2015 JetBrains s.r.o.
+ * Copyright 2000-2016 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
index e1129c35102ae0d21c01b1993b5517135eba082a..a1c8901913e0bfad408d86dabb3740a43f3c9816 100644 (file)
@@ -199,4 +199,5 @@ fun HttpRequest.isWriteFromBrowserWithoutOrigin(): Boolean {
 }
 
 fun ByteBuf.readUtf8() = toString(Charsets.UTF_8)
+
 fun ByteBuf.writeUtf8(data: CharSequence) = writeCharSequence(data, Charsets.UTF_8)
\ No newline at end of file