Fix compilation

This commit is contained in:
leventov
2015-06-20 07:21:01 +03:00
parent 1d7f54635a
commit f003f13ba3
@@ -28,6 +28,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.io.UTFDataFormatException;
public final class CharSequenceReader<S extends CharSequence>
implements BytesReader<S>, StatefulCopyable<CharSequenceReader<S>> {
@@ -81,12 +82,32 @@ public final class CharSequenceReader<S extends CharSequence>
this.identity = identity;
}
/**
* Method copied here because corresponding method in AbstractBytes was turned
* to instance method, but we need to call on Bytes, not AbstractBytes
*/
private static void readUTF0(Bytes b, @NotNull Appendable appendable, int utflen)
throws IOException {
int count = 0;
while (count < utflen) {
int c = b.readUnsignedByteOrThrow();
if (c >= 128) {
b.position(b.position() - 1);
AbstractBytes.readUTF2(b, appendable, utflen, count);
break;
}
count++;
appendable.append((char) c);
}
}
@NotNull
@Override
public S read(@NotNull Bytes bytes, long size) {
sb.setLength(0);
try {
AbstractBytes.readUTF0(bytes, sb, (int) size);
readUTF0(bytes, sb, (int) size);
} catch (IOException e) {
throw new IllegalStateException(e);
}
@@ -109,7 +130,7 @@ public final class CharSequenceReader<S extends CharSequence>
appendable = sb;
}
try {
AbstractBytes.readUTF0(bytes, appendable, (int) size);
readUTF0(bytes, appendable, (int) size);
} catch (IOException e) {
throw new IllegalStateException(e);
}