001 package jline; 002 003 import java.io.IOException; 004 005 006 public class JLineStringBuilder implements JLineBuffer 007 { 008 StringBuilder buffer = new StringBuilder(); 009 010 public Appendable append(CharSequence s) { 011 return buffer.append(s); 012 } 013 014 public Appendable append(char c) throws IOException { 015 return buffer.append(c); 016 } 017 018 public Appendable append(CharSequence s, int start, int end) throws IOException { 019 return buffer.append(s, start, end); 020 } 021 022 public char charAt(int index) { 023 return buffer.charAt(index); 024 } 025 026 public int length() { 027 return buffer.length(); 028 } 029 030 public CharSequence subSequence(int start, int end) { 031 return buffer.subSequence(start, end); 032 } 033 034 public void delete(int start, int end) { 035 buffer.delete(start, end); 036 } 037 038 public void deleteCharAt(int index) { 039 buffer.deleteCharAt(index); 040 } 041 042 public void insert(int offset, char c) { 043 buffer.insert(offset, c); 044 } 045 046 public void insert(int offset, CharSequence s) { 047 buffer.insert(offset, s); 048 } 049 050 public void setLength(int newLength) { 051 buffer.setLength(newLength); 052 } 053 054 public String substring(int start) { 055 return buffer.substring(start); 056 } 057 058 public String substring(int start, int end) { 059 return buffer.substring(start, end); 060 } 061 062 public void replace(int start, int end, String str) { 063 buffer.replace(start, end, str); 064 } 065 066 public String toString() { 067 return buffer.toString(); 068 } 069 }