@Test(expected=IllegalStateException.class) public void testCannotReadCharSequence() { TextManager manager = new TextManager("text"); manager.readText(1); }
public void readText(int amount) { initText(); if (amount <= 0) { throw new IllegalArgumentException("Amount must be positive."); } if (amount > bufferLength) { throw new IllegalArgumentException("Amount to read is larger than buffer size."); } if (!hasMoreText()) { throw new IllegalStateException("No more text to read."); } StringBuilder builder = new StringBuilder(); builder.append(text.subSequence(amount, text.length())); builder.append((char)nextCharacter); builder.append(read(amount)); text = builder.toString(); }
TextManager { public void readText(int amount) { initText(); if (amount <= 0) { throw new IllegalArgumentException("Amount must be positive."); } if (amount > bufferLength) { throw new IllegalArgumentException("Amount to read is larger than buffer size."); } if (!hasMoreText()) { throw new IllegalStateException("No more text to read."); } StringBuilder builder = new StringBuilder(); builder.append(text.subSequence(amount, text.length())); builder.append((char)nextCharacter); builder.append(read(amount)); text = builder.toString(); } }
TextManager { public void readText(int amount) { initText(); if (amount <= 0) { throw new IllegalArgumentException("Amount must be positive."); } if (amount > bufferLength) { throw new IllegalArgumentException("Amount to read is larger than buffer size."); } if (!hasMoreText()) { throw new IllegalStateException("No more text to read."); } StringBuilder builder = new StringBuilder(); builder.append(text.subSequence(amount, text.length())); builder.append((char)nextCharacter); builder.append(read(amount)); text = builder.toString(); } TextManager(CharSequence text);  TextManager(Reader reader, int bufferLength); }
TextManager { public void readText(int amount) { initText(); if (amount <= 0) { throw new IllegalArgumentException("Amount must be positive."); } if (amount > bufferLength) { throw new IllegalArgumentException("Amount to read is larger than buffer size."); } if (!hasMoreText()) { throw new IllegalStateException("No more text to read."); } StringBuilder builder = new StringBuilder(); builder.append(text.subSequence(amount, text.length())); builder.append((char)nextCharacter); builder.append(read(amount)); text = builder.toString(); } TextManager(CharSequence text);  TextManager(Reader reader, int bufferLength); int getBufferLength(); CharSequence getText(); boolean hasMoreText(); void readText(int amount); }
TextManager { public void readText(int amount) { initText(); if (amount <= 0) { throw new IllegalArgumentException("Amount must be positive."); } if (amount > bufferLength) { throw new IllegalArgumentException("Amount to read is larger than buffer size."); } if (!hasMoreText()) { throw new IllegalStateException("No more text to read."); } StringBuilder builder = new StringBuilder(); builder.append(text.subSequence(amount, text.length())); builder.append((char)nextCharacter); builder.append(read(amount)); text = builder.toString(); } TextManager(CharSequence text);  TextManager(Reader reader, int bufferLength); int getBufferLength(); CharSequence getText(); boolean hasMoreText(); void readText(int amount);  }