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

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

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

Util.isEmpty介绍

[英]Indicates if a given string is null or empty.
[中]指示给定字符串是null还是空。

代码示例

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

  1. /**
  2. * Indicates if this object has at least standoff item.
  3. * @return true if this object has at least standoff item, false otherwise.
  4. */
  5. public boolean hasStandoff () {
  6. return !Util.isEmpty(standoff);
  7. }

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

  1. /**
  2. * Converts a list of strings into an array of those strings.
  3. * @param list List of strings.
  4. * @return an array of strings.
  5. */
  6. public static String[] stringListAsArray(List<String> list) {
  7. if (Util.isEmpty(list))
  8. return new String[] {};
  9. return (String[]) list.toArray(new String[] {});
  10. }

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

  1. /**
  2. * Disallows the locales which user part matches a given user part.
  3. * @param userPart the given user part.
  4. * @return this locale filter.
  5. */
  6. public LocaleFilter excludeUserPart(String userPart) {
  7. if (Util.isEmpty(userPart)) return this;
  8. this.userPartExcludes.add("xx-xx-x-" + userPart);
  9. return this;
  10. }

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

  1. /**
  2. * Gets the length of a string, even a null one.
  3. * @param string the string to examine.
  4. * @return the length of the given string, 0 if the string is null.
  5. */
  6. static public int getLength (String string) {
  7. return (isEmpty(string)) ? 0 : string.length();
  8. }

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

  1. /**
  2. * Extracts the package name part of a qualified class name.
  3. * @param className Qualified class name
  4. * @return Package name (w/o the trailing dot)
  5. */
  6. public static String extractPackageName(String className) {
  7. if (Util.isEmpty(className)) return "";
  8. int index = className.lastIndexOf(".");
  9. if (index > -1)
  10. return className.substring(0, index);
  11. return "";
  12. }

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

  1. /**
  2. * Extracts the class name part of a qualified class name.
  3. * @param className Qualified class name
  4. * @return Class name
  5. */
  6. public static String extractShortClassName(String className) {
  7. if (Util.isEmpty(className)) return "";
  8. int index = className.lastIndexOf(".");
  9. if (index > -1)
  10. return className.substring(index + 1);
  11. return className;
  12. }

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

  1. /**
  2. * Checks if a given string contains only whitespace characters.
  3. * @param str the given string
  4. * @return true if the given string is whitespace
  5. */
  6. public static boolean isWhitespace(String str) {
  7. if (Util.isEmpty(str)) return false; // "" is neither whitespace
  8. return "".equals(str.trim());
  9. }

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

  1. /**
  2. * Disallows all locales matching a given regular expression with a given set of regex flags.
  3. * @param regex the given regular expression.
  4. * @param flags the given set of regex flags.
  5. * @return this locale filter.
  6. */
  7. public LocaleFilter excludePattern(String regex, int flags) {
  8. if (Util.isEmpty(regex)) return this;
  9. patternExcludes.add(0, Pattern.compile(regex, flags));
  10. return this;
  11. }

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

  1. /**
  2. * Detects if a given string contains shell wildcard characters (e.g. * and ?).
  3. * @param string the given string.
  4. * @return true if the string contains the asterisk (*) or question mark (?).
  5. */
  6. public static boolean containsWildcards(String string) {
  7. if (Util.isEmpty(string)) return false;
  8. return string.indexOf('*') != -1 || string.indexOf('?') != -1;
  9. }

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

  1. /**
  2. * Adds all the annotations from a given list to this object.
  3. * @param newItems the list of annotations to add.
  4. */
  5. public void addAll (List<GenericAnnotation> newItems) {
  6. if ( Util.isEmpty(newItems) ) return;
  7. // There is something to add: make sure we have a place where to copy
  8. if ( list == null ) list = new ArrayList<GenericAnnotation>(newItems.size());
  9. // Add all annotations of the given list
  10. list.addAll(newItems);
  11. }

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

  1. /**
  2. * Allows the locales which region matches a given region.
  3. * @param region the given region.
  4. * @return this locale filter.
  5. */
  6. public LocaleFilter includeRegion(String region) {
  7. if (Util.isEmpty(region)) return this;
  8. String regionMask = "xx-" + region;
  9. removeFromRegionExcludes(regionMask);
  10. this.regionIncludes.add(regionMask);
  11. return this;
  12. }

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

  1. /**
  2. * Adds a new part to this skeleton, and set a string data to it.
  3. * Empty or null data has no effect.
  4. * @param data the data to add.
  5. */
  6. public void add (String data) {
  7. if ( Util.isEmpty(data) ) return;
  8. GenericSkeletonPart part = new GenericSkeletonPart(data);
  9. list.add(part);
  10. createNew = false;
  11. }

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

  1. /**
  2. * Allows the locales which language matches any of the languages from a given array.
  3. * @param languages the given array of languages.
  4. * @return this locale filter.
  5. */
  6. public LocaleFilter includeLanguage(String ... languages) {
  7. if (Util.isEmpty(languages)) return this;
  8. for (String language : languages)
  9. includeLanguage(language);
  10. return this;
  11. }

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

  1. /**
  2. * Allows the locales which language matches a given language.
  3. * @param language the given language.
  4. * @return this locale filter.
  5. */
  6. public LocaleFilter includeLanguage(String language) {
  7. if (Util.isEmpty(language)) return this;
  8. String languageMask = language;
  9. removeFromLanguageExcludes(languageMask);
  10. this.languageIncludes.add(languageMask);
  11. return this;
  12. }

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

  1. /**
  2. * Disallows the locales from a given array of locales.
  3. * @param localeIds the given array of locales.
  4. * @return this locale filter.
  5. */
  6. public LocaleFilter exclude(LocaleId ... localeIds) {
  7. if (Util.isEmpty(localeIds)) return this;
  8. for (LocaleId localeId : localeIds)
  9. exclude(localeId);
  10. return this;
  11. }

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

  1. /**
  2. * Disallows the locales which language matches any of the languages from a given array.
  3. * @param languages the given array of languages.
  4. * @return this locale filter.
  5. */
  6. public LocaleFilter excludeLanguage(String ... languages) {
  7. if (Util.isEmpty(languages)) return this;
  8. for (String language : languages)
  9. excludeLanguage(language);
  10. return this;
  11. }

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

  1. /**
  2. * Disallows the locales which user part matches any of the user parts from a given array.
  3. * @param userParts the given array of user parts.
  4. * @return this locale filter.
  5. */
  6. public LocaleFilter excludeUserPart(String ... userParts) {
  7. if (Util.isEmpty(userParts)) return this;
  8. for (String userPart : userParts)
  9. excludeUserPart(userPart);
  10. return this;
  11. }

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

  1. public Map<String, String> toMap () {
  2. LinkedHashMap<String, String> table = new LinkedHashMap<String, String>();
  3. String tmp = toString();
  4. if ( Util.isEmpty(tmp) ) return table;
  5. String[] pairs = tmp.split("\n", 0);
  6. for ( String pair : pairs ) {
  7. String[] keyvalue = pair.split("=");
  8. table.put(keyvalue[0], // Handle empty parameters
  9. (( keyvalue.length > 1 ) ? keyvalue[1] : ""));
  10. }
  11. return table;
  12. }

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

  1. /**
  2. * Helper method.
  3. */
  4. private void setLanguage(boolean excludeMode, String language) {
  5. if (Util.isEmpty(language)) return;
  6. if (excludeMode)
  7. excludeLanguage(language);
  8. else
  9. includeLanguage(language);
  10. }

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

  1. public static void convertTextPart_whitespaceCodesToText(TextPart textPart) {
  2. if (textPart.isSegment()) return;
  3. TextFragment tf = textPart.getContent();
  4. if (tf.hasText()) return;
  5. if (Util.isEmpty(tf.toText().trim())) {
  6. // Move all codes into text
  7. textPart.setContent(new TextFragment(tf.toText()));
  8. }
  9. }

相关文章