net.sf.okapi.common.Util.isNullOrEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(267)

本文整理了Java中net.sf.okapi.common.Util.isNullOrEmpty()方法的一些代码示例,展示了Util.isNullOrEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isNullOrEmpty()方法的具体详情如下:
包路径:net.sf.okapi.common.Util
类名称:Util
方法名:isNullOrEmpty

Util.isNullOrEmpty介绍

[英]Indicates if a locale id is null or empty.
[中]指示区域设置id是空的还是空的。

代码示例

代码示例来源:origin: net.sf.okapi.tm/okapi-tm-pensieve

  1. /**
  2. * Creates an instance of OkapiTMXHandler
  3. * @param sourceLang the language to import as the source language.
  4. * @param tmxFilter the IFilter to use to parse the TMX
  5. */
  6. public OkapiTmxImporter(LocaleId sourceLang, IFilter tmxFilter) {
  7. this.tmxFilter = tmxFilter;
  8. this.sourceLang = sourceLang;
  9. if (Util.isNullOrEmpty(sourceLang)) {
  10. throw new IllegalArgumentException("'sourceLang' must be set");
  11. }
  12. if (tmxFilter == null) {
  13. throw new IllegalArgumentException("'filter' must be set");
  14. }
  15. }

代码示例来源:origin: net.sf.okapi.tm/okapi-tm-pensieve

  1. private void checkImportTmxParams(URI tmxUri,
  2. LocaleId targetLang,
  3. ITmWriter tmWriter)
  4. {
  5. if (Util.isNullOrEmpty(targetLang)) {
  6. throw new IllegalArgumentException("'targetLang' was not set");
  7. }
  8. if (tmxUri == null) {
  9. throw new IllegalArgumentException("'tmxUri' was not set");
  10. }
  11. if (tmWriter == null) {
  12. throw new IllegalArgumentException("'tmWriter' was not set");
  13. }
  14. }

代码示例来源:origin: net.sf.okapi/okapi-core

  1. /**
  2. * Gets text of the first part of the target of a given text unit resource in the given locale.
  3. *
  4. * @param textUnit
  5. * the text unit resource which source text should be returned.
  6. * @param locId
  7. * the locale the target part being sought.
  8. * @return the target part of the given text unit resource in the given loacle, or an empty string if the text unit
  9. * doesn't contain one.
  10. */
  11. public static String getTargetText (ITextUnit textUnit,
  12. LocaleId locId)
  13. {
  14. if (textUnit == null)
  15. return "";
  16. if (Util.isNullOrEmpty(locId))
  17. return "";
  18. return getCodedText(textUnit.getTarget(locId).getFirstContent());
  19. }

代码示例来源:origin: net.sf.okapi/okapi-core

  1. /**
  2. * Attaches an annotation to the target part of a given text unit resource in a given language.
  3. *
  4. * @param textUnit
  5. * the given text unit resource.
  6. * @param locId
  7. * the locale of the target part being attached to.
  8. * @param annotation
  9. * the annotation to be attached to the target part of the text unit.
  10. */
  11. public static void setTargetAnnotation (ITextUnit textUnit,
  12. LocaleId locId,
  13. IAnnotation annotation)
  14. {
  15. if ( textUnit == null ) return;
  16. if ( Util.isNullOrEmpty(locId) ) return;
  17. if ( textUnit.getTarget(locId) == null ) return;
  18. textUnit.getTarget(locId).setAnnotation(annotation);
  19. }

代码示例来源:origin: net.sf.okapi/okapi-core

  1. /**
  2. * Finds either source or target reference in the skeleton. If locId is specified, then its target reference is sought for.
  3. * @param skel the skeleton being sought for the reference.
  4. * @param locId the locale to search the reference for.
  5. * @return index in the list of skeleton parts for the skeleton part containing the reference.
  6. */
  7. public static int findTuRefInSkeleton(GenericSkeleton skel,
  8. LocaleId locId)
  9. {
  10. if ( skel == null ) return -1;
  11. List<GenericSkeletonPart> list = skel.getParts();
  12. for ( int i=0; i<list.size(); i++ ) {
  13. GenericSkeletonPart part = list.get(i);
  14. String st = part.toString();
  15. if ( Util.isEmpty(st) ) continue;
  16. if ( st.equalsIgnoreCase(TU_REF) ) {
  17. if ( Util.isNullOrEmpty(locId) ) {
  18. return i;
  19. }
  20. else if ( locId.equals(part.getLocale()) ) {
  21. return i;
  22. }
  23. }
  24. }
  25. return -1;
  26. }

代码示例来源:origin: net.sf.okapi/okapi-core

  1. /**
  2. * Gets an annotation attached to the target part of a given text unit resource in a given locale.
  3. *
  4. * @param <A> a class implementing IAnnotation
  5. * @param textUnit
  6. * the given text unit resource.
  7. * @param locId
  8. * the locale of the target part being sought.
  9. * @param type
  10. * reference to the requested annotation type.
  11. * @return the annotation or null if not found.
  12. */
  13. public static <A extends IAnnotation> A getTargetAnnotation (ITextUnit textUnit,
  14. LocaleId locId,
  15. Class<A> type)
  16. {
  17. if ( textUnit == null ) return null;
  18. if ( Util.isNullOrEmpty(locId) ) return null;
  19. if ( textUnit.getTarget(locId) == null ) return null;
  20. return textUnit.getTarget(locId).getAnnotation(type);
  21. }

代码示例来源:origin: net.sf.okapi/okapi-core

  1. if (Util.isNullOrEmpty(locId))
  2. res.add(TextUnitUtil.getSourceText(textUnit));
  3. else

代码示例来源:origin: net.sf.okapi/okapi-core

  1. case START_DOCUMENT:
  2. sourceLocale = event.getStartDocument().getLocale();
  3. if (!Util.isNullOrEmpty(sourceLocale)) {
  4. processStartDocument(event);
  5. } else {
  6. break;
  7. case TEXT_UNIT:
  8. if (!Util.isNullOrEmpty(sourceLocale)) {
  9. processTextUnit(event);
  10. } else {

代码示例来源:origin: net.sf.okapi.steps/okapi-step-wordcount

  1. public long doCount(Object text, LocaleId language) {
  2. if (Util.isNullOrEmpty(language)) return 0L;

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-table

  1. if ( Util.isNullOrEmpty(language) ) {
  2. sendAsSkeleton(cell);
  3. continue;

代码示例来源:origin: net.sf.okapi/okapi-core

  1. textUnit.setSource(source);
  2. if (target != null && !Util.isNullOrEmpty(locId))
  3. textUnit.setTarget(locId, target);

代码示例来源:origin: net.sf.okapi.steps/okapi-step-wordcount

  1. public Counts doFullCount(Object text, LocaleId language) {
  2. if (Util.isNullOrEmpty(language)) return new Counts();

代码示例来源:origin: net.sf.okapi.filters/okapi-filter-its

  1. if ( !Util.isNullOrEmpty(input.getTargetLocale()) ) {
  2. trgLangCode = input.getTargetLocale().toString().toLowerCase();

相关文章