//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public SectionedCharBuffer read(SectionedCharBuffer buffer, int from) throws java.io.IOException public override SectionedCharBuffer Read(SectionedCharBuffer buffer, int from) { while (true) { _current.read(buffer, from); if (buffer.HasAvailable()) { // OK we read something from the current reader CheckNewLineRequirement(buffer.Array(), buffer.Front() - 1); return(buffer); } // Even if there's no line-ending at the end of this source we should introduce one // otherwise the last line of this source and the first line of the next source will // look like one long line. if (_requiresNewLine) { buffer.Append('\n'); _requiresNewLine = false; return(buffer); } if (!GoToNextSource()) { break; } from = buffer.Pivot(); } return(buffer); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Parameters public static java.util.Collection<ReadMethod> readMethods() public static ICollection <ReadMethod> ReadMethods() { return(Arrays.asList((readable, length) => { SectionedCharBuffer readText = new SectionedCharBuffer(length); readable.read(readText, readText.Front()); return copyOfRange(readText.Array(), readText.Pivot(), readText.Front()); }, (readable, length) => { char[] result = new char[length]; readable.read(result, 0, length); return result; })); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void shouldComplyWithSpecifiedCharset(java.nio.charset.Charset charset) throws Exception private void ShouldComplyWithSpecifiedCharset(Charset charset) { // GIVEN string data = "abcåäö[]{}"; File file = WriteToFile(data, charset); // WHEN CharReadable reader = Readables.Files(charset, file); SectionedCharBuffer buffer = new SectionedCharBuffer(100); buffer = reader.Read(buffer, buffer.Front()); // THEN char[] expected = data.ToCharArray(); char[] array = buffer.Array(); assertEquals(expected.Length, buffer.Available()); for (int i = 0; i < expected.Length; i++) { assertEquals(expected[i], array[buffer.Pivot() + i]); } }
private static void AssertBuffer(char[] expectedChars, SectionedCharBuffer buffer, int charsInBack, int charsInFront) { assertEquals(buffer.Pivot() - charsInBack, buffer.Back()); assertEquals(buffer.Pivot() + charsInFront, buffer.Front()); assertArrayEquals(expectedChars, copyOfRange(buffer.Array(), buffer.Back(), buffer.Front())); }