>
> Are you sure you want to return the empty string if there is a
> BadLocationException thrown from the underlying code? It looks like that
> might hide problems with the Document (sub) class implementation. Better
> would be to chain it in a InternalError() and throw that since it seems
> that BadLocationException should never be thrown when getText() is
> called like this.
I handled this the same way JTextComponent does.
/**
* Retrieves the current text in this text document.
*
* @return the text
*
* @exception NullPointerException if the underlaying document is null
*/
public String getText()
{
if (doc == null)
return null;
try
{
return doc.getText(0, doc.getLength());
}
catch (BadLocationException e)
{
// This should never happen.
return "";
}
}
I think it makes most sense to return an empty string.
Lillian
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches