EVALUATION
This should be added for merlin. By adding a flag to Segment, the method
could support partial returns without compatibility problems.
timothy.prinzing@eng 2000-11-19
Added the following API change, javadoc changes, and GapContent now supports
the partial return flag:
The addition of a flag on the javax.swing.text.Segment class to indicate
that partial returns are ok.
/**
* Flag to indicate that partial returns are valid. If the flag is true,
* an implementation of the interface method Document.getText(position,length,Segment)
* should return as much text as possible without making a copy. The default
* state of the flag is false which will cause Document.getText(position,length,Segment)
* to provide the same return behavior it currently does, which may or may not
* make a copy of the text depending upon the request.
*
* @param p whether or not partial returns are valid.
* @since 1.4
*/
void setPartialReturn(boolean b) {
}
/**
* Flag to indicate that partial returns are valid.
*
* @return whether or not partial returns are valid.
* @since 1.4
*/
boolean isPartialReturn() {
}
The javadoc for the Document.getText method will be changed to indicate
the new functionality.
/**
* Fetches the text contained within the given portion
* of the document.
* <p>
* If the partialReturn property on the txt parameter is false, the
* data returned in the Segment will be the entire length requested and
* may or may not be a copy depending upon how the data was stored.
* If the partialReturn property is true, only the amount of text that
* can be returned without creating a copy is returned. Using partial
* returns will give better performance for situations where large
* parts of the document are being scanned. The following is an example
* of using the partial return:
* <p>
* <pre><code>
*
* int nleft = doc.getLength();
* Segment text = new Segment();
* int offs = 0;
* text.setPartialReturn(true);
* while (nleft > 0) {
* doc.getText(offs, nleft, text);
* // do someting with text
* nleft -= text.count;
* offs += text.count;
* }
*
* </code></pre>
*
* @param offset the offset into the document representing the desired
* start of the text >= 0
* @param length the length of the desired string >= 0
* @param txt the Segment object to return the text in
*
* @exception BadLocationException Some portion of the given range
* was not a valid part of the document. The location in the exception
* is the first bad position encountered.
*/
public void getText(int offset, int length, Segment txt) throws BadLocationException;
The javadoc for AbstractDocument.getText has also been changed.
timothy.prinzing@eng 2000-11-30
|