org.openide.text
Class PositionBounds

java.lang.Object
  |
  +--org.openide.text.PositionBounds
All Implemented Interfaces:
Serializable

public final class PositionBounds
extends Object
implements Serializable

A range bounded by two PositionRefs.

See Also:
Serialized Form

Constructor Summary
PositionBounds(PositionRef begin, PositionRef end)
          Creates new PositionBounds.
 
Method Summary
 PositionRef getBegin()
          Get the starting position of this range.
 PositionRef getEnd()
          Get the ending position of this range.
 String getText()
          Finds the text contained in this range.
 PositionBounds insertAfter(String text)
          Inserts the text after this PositionBounds.
 void setText(String text)
          Replaces the text contained in this range.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PositionBounds

public PositionBounds(PositionRef begin,
                      PositionRef end)
Creates new PositionBounds.
Parameters:
begin - the start position of the range
end - the end position of the range
Method Detail

getBegin

public PositionRef getBegin()
Get the starting position of this range.
Returns:
the begin position

getEnd

public PositionRef getEnd()
Get the ending position of this range.
Returns:
the end position

setText

public void setText(String text)
             throws IOException,
                    BadLocationException
Replaces the text contained in this range. This replacement is done atomically, and so is preferable to manual inserts & removes.

If you are running this from user-oriented code, you may want to wrap it in NbDocument.runAtomicAsUser(javax.swing.text.StyledDocument, java.lang.Runnable).

Parameters:
text - new text to insert over existing text
Throws:
IOException - if any problem occurred during document loading (if that was necessary)
BadLocationException - if the positions are out of the bounds of the document

insertAfter

public PositionBounds insertAfter(String text)
                           throws IOException,
                                  BadLocationException
Inserts the text after this PositionBounds.
Parameters:
text - The text to insert. The text must not be empty.
Returns:
the range of inserted text.
Throws:
IOException - if any problem occurred during document loading (if that was necessary)
BadLocationException - if the positions are out of the bounds of the document

getText

public String getText()
               throws BadLocationException,
                      IOException
Finds the text contained in this range.
Returns:
the text
Throws:
IOException - if any I/O problem occurred during document loading (if that was necessary)
BadLocationException - if the positions are out of the bounds of the document

toString

public String toString()
Overrides:
toString in class Object


Built on December 12 2001.  |  Portions Copyright 1997-2001 Sun Microsystems, Inc. All rights reserved.