/** * Get the text of the fragment (all codes are removed) * @return the content of fragment without codes */ public String getText () { if ( !hasCode() ) { return text.toString(); } Matcher m = MARKERS_REGEX.matcher(new String(text)); return m.replaceAll(""); }
/** * Indicates if this text has at least one annotation of a given type. * @param type the type of annotation to look for. * @return true if there is at least one annotation of the given type, false otherwise. */ public boolean hasAnnotation (String type) { if ( !hasCode() ) return false; for ( Code code : codes ) { if ( code.hasAnnotation(type) ) return true; } return false; }
/** * Indicates if this text has at least one annotation. * @return true if there is at least one annotation, false otherwise. */ public boolean hasAnnotation () { if ( !hasCode() ) return false; for ( Code code : codes ) { if ( code.hasAnnotation() ) return true; } return false; }
/** * Indicates if this TextFragment contains any in-line code with a reference. * @return true if there is one or more in-line codes with a reference, * false if there is no reference. */ public boolean hasReference () { if ( !hasCode() ) return false; for ( Code code : codes ) { if ( code.hasReference() ) return true; } return false; }
/** * Removes all annotations in this text. This also removes any code that * is or was there only for holding an annotation. */ public void removeAnnotations () { if ( !hasCode() ) return; boolean clean = false; for ( Code code : codes ) { if ( code.annotations != null ) { code.annotations.clear(); code.annotations = null; clean = true; } } if ( clean ) cleanUnusedCodes(); }
/** * Removes all annotations of a given type in this text. This also removes any * code that is there only for holding an annotation of the given type, or * any code that has no annotation and no data either. * @param type the type of annotation to remove. */ public void removeAnnotations (String type) { if ( !hasCode() ) return; boolean clean = false; for ( Code code : codes ) { code.removeAnnotation(type); clean = true; } if ( clean ) cleanUnusedCodes(); }
if (!frag.hasCode()) { return text; // No codes
if ( !textFragment.hasCode() ) { return res;
private String prepareFragment (TextFragment tf) { String text = tf.getCodedText(); if ( !tf.hasCode() ) { return text;
if ( !frag.hasCode() ) return pos;
if ( !fragment.hasCode() && ( genericText.indexOf('<') == -1 )) { fragment.setCodedText(genericText); return;
/** * Create a single code with a given TextPart's text. * Needed to protect the text of the text part from being escaped by * an encoder. If the TextPart already has codes, no conversion * is performed. * @param textPart the given TextPart */ public static void convertTextPartToCode(TextPart textPart) { if (!textPart.isSegment()) { TextFragment tf = textPart.getContent(); if (tf.hasCode()) return; // Move the whole text of text part to a single code tf.changeToCode(0, tf.getCodedText().length(), TagType.PLACEHOLDER, null); } }
private TextFragment makeFragment(String codedHtml, TextFragment sourceFragment) { return sourceFragment.hasCode() ? new TextFragment(util.fromCodedHTML(codedHtml, sourceFragment, false), sourceFragment.getClonedCodes()) : new TextFragment(util.fromCodedHTML(codedHtml, sourceFragment, false)); } }
if ( text.hasCode() && params.getSupportCodes() ) { plain = GenericContent.fromFragmentToLetterCoded(text, true); if ( qr.getFuzzyScore() < threshold ) break; // Done if ( text.hasCode() && params.getSupportCodes() ) { qr.source = GenericContent.fromLetterCodedToFragment((String)map.get("source"), null, false, true); qr.target = GenericContent.fromLetterCodedToFragment((String)map.get("target"), null, false, true);
if ( overwrite ) { TextFragment srcFrag = tu.getSource().getContent(); if ( srcFrag.hasCode() ) { BooleanQuery bq = new BooleanQuery(); bq.add(
if (target == null || !target.hasCode()) { return;
if ( !tf.hasCode() ) { return new Fragment(store, isTarget, tf.getCodedText());
if (tf == null || !tf.hasCode()) return tf;
if ( !oriFrag.hasCode() ) {