se.biltmore.tools.fileeditor
Interface TextBuffer

All Known Implementing Classes:
TextFileBuffer

public interface TextBuffer


Method Summary
 void addLine(String text)
          Adds a line of text to the end of the buffer.
 void clear()
          Clears the buffer.
 String getLine(int line)
          Gets a specific line from the buffer.
 int getSize()
          Returns the number of lines in the buffer.
 void insertLine(int line, String text)
          Inserts a new line at the specified position.
 void load(String path)
          Loads a text file into the buffer.
 TextBuffer newInstance()
          Returns a new instance of the buffer.
 void removeLine(int line)
          Removes the specified line.
 void save()
          Saves the buffer back to disk again.
 void saveAs(String path)
          Saves the buffer to another file.
 void setLine(int line, String text)
          Replaces a specific line in the buffer.
 void setReadOnly(boolean readOnly)
          If true makes the buffer read only.
 

Method Detail

load

void load(String path)
          throws IOException
Loads a text file into the buffer.

Parameters:
path - The path to the file to load.
Throws:
IOException

save

void save()
          throws IOException
Saves the buffer back to disk again.

Throws:
IOException

saveAs

void saveAs(String path)
            throws IOException
Saves the buffer to another file.

Parameters:
path - The path to the file to save to.
Throws:
IOException

clear

void clear()
Clears the buffer.


getSize

int getSize()
Returns the number of lines in the buffer.


getLine

String getLine(int line)
Gets a specific line from the buffer.

Parameters:
line - The line to get.

setLine

void setLine(int line,
             String text)
Replaces a specific line in the buffer.

Parameters:
line - The line to replace.
text - The new text for the line.

removeLine

void removeLine(int line)
Removes the specified line.

Parameters:
line - The line to remove.

insertLine

void insertLine(int line,
                String text)
Inserts a new line at the specified position.

Parameters:
line - the poistion to insert at.
text - The text to insert.

addLine

void addLine(String text)
Adds a line of text to the end of the buffer.

Parameters:
text - The text to add.

newInstance

TextBuffer newInstance()
Returns a new instance of the buffer.

Some editor operations work by creating a new buffer. This method allows those operations to create a buffer of the same type.

Please note however that any saved reference to the loaded file must be copied to the new instance before it is returned.


setReadOnly

void setReadOnly(boolean readOnly)
If true makes the buffer read only.

Parameters:
readOnly - Set to true to make buffer read only. Defaults to false.


Copyright © 2009-2010 Biltmore Group AB. All Rights Reserved.