/** * Gets the string representation of the default source container. * If the container is segmented, the representation shows the merged segments. * Inline codes are also included. * * @return the string representation of the source container. */ @Override public String toString () { return getSource().toString(); }
/** * Define equality of state. * @param other the object to compare with. * @return true if the objects are equal, false otherwise. */ @Override public boolean equals (Object other) { if ( this == other ) { return true; } if ( !(other instanceof AltTranslation) ) { return false; } AltTranslation otherHit = (AltTranslation) other; return ( this.getType() == otherHit.getType() ) && (this.getSource().toString().equals(otherHit.getSource().toString())) && (this.getTarget().toString().equals(otherHit.getTarget().toString())); }
/** * Detects if a given TextContainer contains whitespace characters to * be preserved in XML. Single space 0x20 doesn't need to be preserved, other whitespace * characters, also a sequence of 2 or more single spaces do. * @param tc the given TextContainer object. * @return true if the given TextContainer has whitespace sequences that need to be preserved. */ public static boolean needsPreserveWhitespaces(TextContainer tc) { return !Util.isEmpty(RegexUtil.find(tc.toString(), // Not [non-whitespace or single space] // or [two or more single spaces] "[^\\S ]| {2,}", 0)); }
/** * A class that overrides equals must also override hashCode. * @return the has code for this object. */ @Override public int hashCode () { int result = HashCodeUtil.SEED; result = HashCodeUtil.hash(result, getType()); result = HashCodeUtil.hash(result, getSource().toString()); result = HashCodeUtil.hash(result, getTarget().toString()); return result; }
@Override protected Event handleTextUnit (Event event) { ITextUnit tu = event.getTextUnit(); // Skip non-translatable if ( !tu.isTranslatable() ) { return event; } // Else: do the requested modifications // Make sure we have a target where to set data TextContainer cont = tu.createTarget(trgLang, false, IResource.COPY_ALL); String res; try { for ( TextPart part : cont ) { if ( params.getConversionType() == Parameters.UNESCAPE ) { res = unescape(part.text.getCodedText()); } else { res = escape(part.text.getCodedText()); } part.text.setCodedText(res); // No change of the inline codes } } catch ( Exception e ) { logger.error("Error when updating content: '{}'", cont.toString(), e); } return event; }
logger.warn("The code id='{}' ({}) is missing in target (item id='{}', name='{}')", code.getId(), code.getData(), tu.getId(), (tu.getName() == null ? "" : tu.getName())); logger.info("Source='{}'", tu.getSource().toString());
private void processWithSubfilter(String parentId, ITextUnit parentTu) { if ( this.encoderManager != null ) { this.encoderManager.setDefaultOptions(params, encoding, lineBreak); this.encoderManager.updateEncoder(MimeTypeMapper.PROPERTIES_MIME_TYPE); } SubFilter subfilter = new SubFilter(sf, encoderManager.getEncoder(), ++sectionIndex, parentId, parentTu.getName()); subfilter.open(new RawDocument(parentTu.getSource().toString(), srcLocale)); // if this is an html or xmlstream filter then set inline code // rules used to parse Java property codes if (sf.getName().startsWith("okf_html") || sf.getName().startsWith("okf_xmlstream")) { AbstractMarkupEventBuilder eb = (AbstractMarkupEventBuilder) ((AbstractMarkupFilter) sf) .getEventBuilder(); eb.initializeCodeFinder(params.isUseCodeFinder(), params .getCodeFinder().getRules()); } while (subfilter.hasNext()) { Event e = subfilter.next(); queue.add(e); } subfilter.close(); queue.add(subfilter.createRefEvent(parentTu)); }
serialized = xmlWriter.getAttributeEncoder().encode(target.toString(), EncoderContext.INLINE);
eventBuilder.addFilterEvents(pcdataSubfilter.getEvents(new RawDocument(pcdata.getSource().toString(), getSrcLoc())));