/** * Returns the specified substring of the document. * @param start The start offset * @param len The length of the substring * @return The substring, or null if the offsets are invalid */ public final String getText(int start, int len) { try { return document.getText(start,len); } catch(BadLocationException bl) { bl.printStackTrace(); return null; } }
/** * Copies the specified substring of the document into a segment. * If the offsets are invalid, the segment will contain a null string. * @param start The start offset * @param len The length of the substring * @param segment The segment */ public final void getText(int start, int len, Segment segment) { try { document.getText(start,len,segment); } catch(BadLocationException bl) { bl.printStackTrace(); segment.offset = segment.count = 0; } }
/** * Returns the entire text of this text area. */ public String getText() { try { return document.getText(0,document.getLength()); } catch(BadLocationException bl) { bl.printStackTrace(); return null; } }
/** * Reparses the document, by passing the specified lines to the * token marker. This should be called after a large quantity of * text is first inserted. * @param start The first line to parse * @param len The number of lines, after the first one to parse */ public void tokenizeLines(int start, int len) { if(tokenMarker == null || !tokenMarker.supportsMultilineTokens()) return; Segment lineSegment = new Segment(); Element map = getDefaultRootElement(); len += start; try { for(int i = start; i < len; i++) { Element lineElement = map.getElement(i); int lineStart = lineElement.getStartOffset(); getText(lineStart,lineElement.getEndOffset() - lineStart - 1,lineSegment); tokenMarker.markTokens(lineSegment,i); } } catch(BadLocationException bl) { bl.printStackTrace(); } }