palmed.edit.text
Class Text

java.lang.Object
  extended by palmed.edit.text.Text
All Implemented Interfaces:
IText, ISerializable

public final class Text
extends java.lang.Object
implements IText, ISerializable

This class handles the text.

Version:
$Revision$ $Date$
Author:
Mathieu Champlon

Constructor Summary
Text()
          Create a text.
 
Method Summary
 void clear()
          Clear the text.
 void delete()
          Delete any resource associated to the text.
 int getHeight()
          Retrieve the height of the text.
 java.lang.String getLine(int y)
          Retrieve a given line.
 void insert(Coordinate position, char c)
          Insert a character at a given position.
 void insertNewLine(Coordinate position)
          Split a line in two lines.
 void marshall(java.io.OutputStream stream)
          Write to an output stream.
 void read(java.io.InputStream stream)
          Read the text from the given stream.
 void read(java.io.InputStream stream, Coordinate from)
          Insert a part of text from the given stream.
 void register(ITextView view)
          Register a view to receive lines invalidation events.
 void remove(Coordinate from, Coordinate to)
          Remove the text between two positions.
 void setLineSeparator(java.lang.String separator)
          Change the line separator.
 void unmarshall(java.io.InputStream stream)
          Read from an input stream.
 void write(java.io.OutputStream stream)
          Write the text to the given stream.
 void write(java.io.OutputStream stream, Coordinate from, Coordinate to)
          Write a part of the text to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Text

public Text()
Create a text.

Method Detail

getHeight

public int getHeight()
Retrieve the height of the text.

Specified by:
getHeight in interface IText
Returns:
the number of lines

getLine

public java.lang.String getLine(int y)
Retrieve a given line.

Specified by:
getLine in interface IText
Parameters:
y - the number of the line to retrieve
Returns:
the content of the line or null

insert

public void insert(Coordinate position,
                   char c)
Insert a character at a given position.

Specified by:
insert in interface IText
Parameters:
position - the insertion point
c - the character

insertNewLine

public void insertNewLine(Coordinate position)
Split a line in two lines.

Specified by:
insertNewLine in interface IText
Parameters:
position - the insertion point

remove

public void remove(Coordinate from,
                   Coordinate to)
Remove the text between two positions.

The two positions must be ordered properly.

Specified by:
remove in interface IText
Parameters:
from - the first position
to - the second position

register

public void register(ITextView view)
Register a view to receive lines invalidation events.

Specified by:
register in interface IText
Parameters:
view - the view to register

clear

public void clear()
Clear the text.

Specified by:
clear in interface IText

read

public void read(java.io.InputStream stream)
          throws java.io.IOException
Read the text from the given stream.

Specified by:
read in interface IText
Parameters:
stream - the stream to read from
Throws:
java.io.IOException - an io exception occurs

write

public void write(java.io.OutputStream stream)
           throws java.io.IOException
Write the text to the given stream.

Specified by:
write in interface IText
Parameters:
stream - the stream to write to
Throws:
java.io.IOException - an io exception occurs

write

public void write(java.io.OutputStream stream,
                  Coordinate from,
                  Coordinate to)
           throws java.io.IOException
Write a part of the text to the given stream.

Specified by:
write in interface IText
Parameters:
stream - the stream to write to
from - the starting point
to - the ending point
Throws:
java.io.IOException - an io exception occurs

read

public void read(java.io.InputStream stream,
                 Coordinate from)
          throws java.io.IOException
Insert a part of text from the given stream.

Specified by:
read in interface IText
Parameters:
stream - the stream to read from
from - the insertion point
Throws:
java.io.IOException - an io exception occurs

unmarshall

public void unmarshall(java.io.InputStream stream)
                throws java.io.IOException
Read from an input stream.

Specified by:
unmarshall in interface ISerializable
Parameters:
stream - the stream to read from
Throws:
java.io.IOException - an io exception occurs

marshall

public void marshall(java.io.OutputStream stream)
              throws java.io.IOException
Write to an output stream.

Specified by:
marshall in interface ISerializable
Parameters:
stream - the stream to write to
Throws:
java.io.IOException - an io exception occurs

delete

public void delete()
Delete any resource associated to the text.

Specified by:
delete in interface IText

setLineSeparator

public void setLineSeparator(java.lang.String separator)
Change the line separator.

To reset to the default mode preserving file format use null.

Specified by:
setLineSeparator in interface IText
Parameters:
separator - a string value or null to reset


Copyright © 2004-2006 PalmEd. All Rights Reserved.