/** * Creates an instance of OkapiTMXHandler * @param sourceLang the language to import as the source language. * @param tmxFilter the IFilter to use to parse the TMX */ public OkapiTmxImporter(LocaleId sourceLang, IFilter tmxFilter) { this.tmxFilter = tmxFilter; this.sourceLang = sourceLang; if (Util.isNullOrEmpty(sourceLang)) { throw new IllegalArgumentException("'sourceLang' must be set"); } if (tmxFilter == null) { throw new IllegalArgumentException("'filter' must be set"); } }
private void checkImportTmxParams(URI tmxUri, LocaleId targetLang, ITmWriter tmWriter) { if (Util.isNullOrEmpty(targetLang)) { throw new IllegalArgumentException("'targetLang' was not set"); } if (tmxUri == null) { throw new IllegalArgumentException("'tmxUri' was not set"); } if (tmWriter == null) { throw new IllegalArgumentException("'tmWriter' was not set"); } }
/** * Gets text of the first part of the target of a given text unit resource in the given locale. * * @param textUnit * the text unit resource which source text should be returned. * @param locId * the locale the target part being sought. * @return the target part of the given text unit resource in the given loacle, or an empty string if the text unit * doesn't contain one. */ public static String getTargetText (ITextUnit textUnit, LocaleId locId) { if (textUnit == null) return ""; if (Util.isNullOrEmpty(locId)) return ""; return getCodedText(textUnit.getTarget(locId).getFirstContent()); }
/** * Attaches an annotation to the target part of a given text unit resource in a given language. * * @param textUnit * the given text unit resource. * @param locId * the locale of the target part being attached to. * @param annotation * the annotation to be attached to the target part of the text unit. */ public static void setTargetAnnotation (ITextUnit textUnit, LocaleId locId, IAnnotation annotation) { if ( textUnit == null ) return; if ( Util.isNullOrEmpty(locId) ) return; if ( textUnit.getTarget(locId) == null ) return; textUnit.getTarget(locId).setAnnotation(annotation); }
/** * Finds either source or target reference in the skeleton. If locId is specified, then its target reference is sought for. * @param skel the skeleton being sought for the reference. * @param locId the locale to search the reference for. * @return index in the list of skeleton parts for the skeleton part containing the reference. */ public static int findTuRefInSkeleton(GenericSkeleton skel, LocaleId locId) { if ( skel == null ) return -1; List<GenericSkeletonPart> list = skel.getParts(); for ( int i=0; i<list.size(); i++ ) { GenericSkeletonPart part = list.get(i); String st = part.toString(); if ( Util.isEmpty(st) ) continue; if ( st.equalsIgnoreCase(TU_REF) ) { if ( Util.isNullOrEmpty(locId) ) { return i; } else if ( locId.equals(part.getLocale()) ) { return i; } } } return -1; }
/** * Gets an annotation attached to the target part of a given text unit resource in a given locale. * * @param <A> a class implementing IAnnotation * @param textUnit * the given text unit resource. * @param locId * the locale of the target part being sought. * @param type * reference to the requested annotation type. * @return the annotation or null if not found. */ public static <A extends IAnnotation> A getTargetAnnotation (ITextUnit textUnit, LocaleId locId, Class<A> type) { if ( textUnit == null ) return null; if ( Util.isNullOrEmpty(locId) ) return null; if ( textUnit.getTarget(locId) == null ) return null; return textUnit.getTarget(locId).getAnnotation(type); }
if (Util.isNullOrEmpty(locId)) res.add(TextUnitUtil.getSourceText(textUnit)); else
case START_DOCUMENT: sourceLocale = event.getStartDocument().getLocale(); if (!Util.isNullOrEmpty(sourceLocale)) { processStartDocument(event); } else { break; case TEXT_UNIT: if (!Util.isNullOrEmpty(sourceLocale)) { processTextUnit(event); } else {
public long doCount(Object text, LocaleId language) { if (Util.isNullOrEmpty(language)) return 0L;
if ( Util.isNullOrEmpty(language) ) { sendAsSkeleton(cell); continue;
textUnit.setSource(source); if (target != null && !Util.isNullOrEmpty(locId)) textUnit.setTarget(locId, target);
public Counts doFullCount(Object text, LocaleId language) { if (Util.isNullOrEmpty(language)) return new Counts();
if ( !Util.isNullOrEmpty(input.getTargetLocale()) ) { trgLangCode = input.getTargetLocale().toString().toLowerCase();