/** * Indicates if a given text fragment object is null, or the text it contains is null or empty. * * @param textFragment * the text fragment to examine. * @return true if the given text fragment object is null, or the text it contains is null or empty. */ public static boolean isEmpty (TextFragment textFragment) { return (textFragment == null || (textFragment != null && textFragment.isEmpty())); }
/** * Indicates if this container is empty (no text and no codes). * * @return true if this container is empty. */ public boolean isEmpty() { for ( TextPart part : parts ) { if ( !part.getContent().isEmpty() ) return false; } return true; }
public static boolean hasMergedCode(TextFragment tf) { if (tf == null || tf.isEmpty()) { return false; } for (Code c : tf.getCodes()) { if (c.isMerged()) { return true; } } return false; }
private static boolean isFragmentEmpty(TranslationUnitVariant frag) { return (frag == null || frag.getContent() == null || frag.getContent().isEmpty()); }
if ( isEmpty() ) return sub; StringBuilder tmpText = new StringBuilder(getCodedText(start, end)); ArrayList<Code> tmpCodes = null;
if ( parts.get(parts.size()-1).getContent().isEmpty() ) { parts.set(parts.size()-1, part);
/** * Appends a part at the end of this container. * <p> * If collapseIfPreviousEmpty and if the current last part (segment or non-segment) * is empty, the text fragment is appended to the last part. * Otherwise the text fragment is appended to the content as a new non-segment part. * <p> * Important: If the container is empty, the appended part becomes * a segment, as the container has always at least one segment. * * @param fragment the text fragment to append. * @param collapseIfPreviousEmpty true to collapse the previous part if it is empty. * @param keepCodeIds true to block code balancing. */ public void append(TextFragment fragment, boolean collapseIfPreviousEmpty, boolean keepCodeIds) { if ( collapseIfPreviousEmpty ) { // If the last part is empty we append to it if ( parts.get(parts.size()-1).getContent().isEmpty() ) { // Append the fragment to the segment or non-segment part parts.get(parts.size()-1).text.append(fragment, keepCodeIds); } else { // Else: like appending a TextPart append(new TextPart(fragment), false); } } else { append(new TextPart(fragment), false); } }
/** * Writes a given text unit. One TMX TU per segment if the text unit is segment, * or one TU for the full content, if the text unit is not segmented. * @param tu The text unit to output. * @param attributes The optional set of attribute to put along with the entry. */ public void writeItem (ITextUnit tu, Map<String, String> attributes) { if ( !tu.hasTarget(trgLoc) ) { return; // No target } ISegments srcSegs = tu.getSourceSegments(); ISegments trgSegs = tu.getTargetSegments(trgLoc); // Output each segment (handles single-segment entry) String tuId = tu.getId(); for ( Segment srcSeg : srcSegs ) { Segment trgSeg = trgSegs.get(srcSeg.id); if (( trgSeg == null ) || trgSeg.text.isEmpty() ) continue; // No target // Else: output writeTU(srcSeg.text, trgSeg.text, String.format("%s_s%s", tuId, srcSeg.id), attributes); } }
boolean evenIfEmpty) if ( tf.isEmpty() && !evenIfEmpty ) return false; // Skip empty entries
if ( !tf.isEmpty() ) { if ( tf.hasText() || extractedMarker ) {
for ( AltTranslation at : atAnn ) { TextFragment srcFrag = at.getSource().getFirstContent(); if ( srcFrag.isEmpty() ) { srcFrag = tu.getSource().getFirstContent(); if ( trgFrag.isEmpty() ) continue; // Skip possible empty entries if ( srcFrag.isEmpty() ) { Segment srcSeg = tu.getSource().getSegments().get(seg.id); if ( srcSeg == null ) continue; // No source: skip it if ( trgFrag.isEmpty() ) continue; // Skip possible empty entries
if ( srcFrag.isEmpty() ) { srcFrag = srcOriginal;
if ( !frag.isEmpty() ) { // Nothing but white spaces skel.add(frag.toText().replace("\n", (params.escapeLineBreak ? " " : lineBreak))); // Pass them as skeleton
if ( trgSeg != null && !trgSeg.text.isEmpty()) { writeTUV(trgSeg.text, loc, trgCont);
if (content.isEmpty()) continue;
if ( ss == null ) continue; boolean leverage = true; if ( keepIfNotEmpty && !ts.text.isEmpty() ) { if ( keepIfTargetSameAsSource ) { if ( ts.text.compareTo(ss.text, true) != 0 ) {