/** * Set the token text. Depending on whether the text is different to the covered text a * {@link TokenForm} annotation is created or not. This method can only be used if the document * text has already been set. If a document text is constructed incrementally, * {@link #setForm(TokenForm)} has to be called manually and whether or not a form is necessary * needs to be determined based on the current state of the document text being built. * * @param aText * the token text. */ public void setText(String aText) { TokenForm form = getForm(); if (aText != null && !aText.equals(getCoveredText())) { // Create form annotation if none is here yet if (form == null) { form = new TokenForm(jcasType.jcas, getBegin(), getEnd()); form.addToIndexes(); } // Set/update form form.setValue(aText); setForm(form); } else if (form != null) { form.removeFromIndexes(); setForm(null); } } }
/** * Set the token text. Depending on whether the text is different to the covered text a * {@link TokenForm} annotation is created or not. This method can only be used if the document * text has already been set. If a document text is constructed incrementally, * {@link #setForm(TokenForm)} has to be called manually and whether or not a form is necessary * needs to be determined based on the current state of the document text being built. * * @param aText * the token text. */ public void setText(String aText) { TokenForm form = getForm(); if (aText != null && !aText.equals(getCoveredText())) { // Create form annotation if none is here yet if (form == null) { form = new TokenForm(jcasType.jcas, getBegin(), getEnd()); form.addToIndexes(); } // Set/update form form.setValue(aText); setForm(form); } else if (form != null) { form.removeFromIndexes(); setForm(null); } } }