本文整理了Java中net.sf.okapi.common.Util.isEmpty()
方法的一些代码示例,展示了Util.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isEmpty()
方法的具体详情如下:
包路径:net.sf.okapi.common.Util
类名称:Util
方法名:isEmpty
[英]Indicates if a given string is null or empty.
[中]指示给定字符串是null还是空。
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Indicates if this object has at least standoff item.
* @return true if this object has at least standoff item, false otherwise.
*/
public boolean hasStandoff () {
return !Util.isEmpty(standoff);
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Converts a list of strings into an array of those strings.
* @param list List of strings.
* @return an array of strings.
*/
public static String[] stringListAsArray(List<String> list) {
if (Util.isEmpty(list))
return new String[] {};
return (String[]) list.toArray(new String[] {});
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Disallows the locales which user part matches a given user part.
* @param userPart the given user part.
* @return this locale filter.
*/
public LocaleFilter excludeUserPart(String userPart) {
if (Util.isEmpty(userPart)) return this;
this.userPartExcludes.add("xx-xx-x-" + userPart);
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Gets the length of a string, even a null one.
* @param string the string to examine.
* @return the length of the given string, 0 if the string is null.
*/
static public int getLength (String string) {
return (isEmpty(string)) ? 0 : string.length();
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Extracts the package name part of a qualified class name.
* @param className Qualified class name
* @return Package name (w/o the trailing dot)
*/
public static String extractPackageName(String className) {
if (Util.isEmpty(className)) return "";
int index = className.lastIndexOf(".");
if (index > -1)
return className.substring(0, index);
return "";
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Extracts the class name part of a qualified class name.
* @param className Qualified class name
* @return Class name
*/
public static String extractShortClassName(String className) {
if (Util.isEmpty(className)) return "";
int index = className.lastIndexOf(".");
if (index > -1)
return className.substring(index + 1);
return className;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Checks if a given string contains only whitespace characters.
* @param str the given string
* @return true if the given string is whitespace
*/
public static boolean isWhitespace(String str) {
if (Util.isEmpty(str)) return false; // "" is neither whitespace
return "".equals(str.trim());
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Disallows all locales matching a given regular expression with a given set of regex flags.
* @param regex the given regular expression.
* @param flags the given set of regex flags.
* @return this locale filter.
*/
public LocaleFilter excludePattern(String regex, int flags) {
if (Util.isEmpty(regex)) return this;
patternExcludes.add(0, Pattern.compile(regex, flags));
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Detects if a given string contains shell wildcard characters (e.g. * and ?).
* @param string the given string.
* @return true if the string contains the asterisk (*) or question mark (?).
*/
public static boolean containsWildcards(String string) {
if (Util.isEmpty(string)) return false;
return string.indexOf('*') != -1 || string.indexOf('?') != -1;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Adds all the annotations from a given list to this object.
* @param newItems the list of annotations to add.
*/
public void addAll (List<GenericAnnotation> newItems) {
if ( Util.isEmpty(newItems) ) return;
// There is something to add: make sure we have a place where to copy
if ( list == null ) list = new ArrayList<GenericAnnotation>(newItems.size());
// Add all annotations of the given list
list.addAll(newItems);
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Allows the locales which region matches a given region.
* @param region the given region.
* @return this locale filter.
*/
public LocaleFilter includeRegion(String region) {
if (Util.isEmpty(region)) return this;
String regionMask = "xx-" + region;
removeFromRegionExcludes(regionMask);
this.regionIncludes.add(regionMask);
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Adds a new part to this skeleton, and set a string data to it.
* Empty or null data has no effect.
* @param data the data to add.
*/
public void add (String data) {
if ( Util.isEmpty(data) ) return;
GenericSkeletonPart part = new GenericSkeletonPart(data);
list.add(part);
createNew = false;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Allows the locales which language matches any of the languages from a given array.
* @param languages the given array of languages.
* @return this locale filter.
*/
public LocaleFilter includeLanguage(String ... languages) {
if (Util.isEmpty(languages)) return this;
for (String language : languages)
includeLanguage(language);
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Allows the locales which language matches a given language.
* @param language the given language.
* @return this locale filter.
*/
public LocaleFilter includeLanguage(String language) {
if (Util.isEmpty(language)) return this;
String languageMask = language;
removeFromLanguageExcludes(languageMask);
this.languageIncludes.add(languageMask);
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Disallows the locales from a given array of locales.
* @param localeIds the given array of locales.
* @return this locale filter.
*/
public LocaleFilter exclude(LocaleId ... localeIds) {
if (Util.isEmpty(localeIds)) return this;
for (LocaleId localeId : localeIds)
exclude(localeId);
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Disallows the locales which language matches any of the languages from a given array.
* @param languages the given array of languages.
* @return this locale filter.
*/
public LocaleFilter excludeLanguage(String ... languages) {
if (Util.isEmpty(languages)) return this;
for (String language : languages)
excludeLanguage(language);
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Disallows the locales which user part matches any of the user parts from a given array.
* @param userParts the given array of user parts.
* @return this locale filter.
*/
public LocaleFilter excludeUserPart(String ... userParts) {
if (Util.isEmpty(userParts)) return this;
for (String userPart : userParts)
excludeUserPart(userPart);
return this;
}
代码示例来源:origin: net.sf.okapi/okapi-core
public Map<String, String> toMap () {
LinkedHashMap<String, String> table = new LinkedHashMap<String, String>();
String tmp = toString();
if ( Util.isEmpty(tmp) ) return table;
String[] pairs = tmp.split("\n", 0);
for ( String pair : pairs ) {
String[] keyvalue = pair.split("=");
table.put(keyvalue[0], // Handle empty parameters
(( keyvalue.length > 1 ) ? keyvalue[1] : ""));
}
return table;
}
代码示例来源:origin: net.sf.okapi/okapi-core
/**
* Helper method.
*/
private void setLanguage(boolean excludeMode, String language) {
if (Util.isEmpty(language)) return;
if (excludeMode)
excludeLanguage(language);
else
includeLanguage(language);
}
代码示例来源:origin: net.sf.okapi/okapi-core
public static void convertTextPart_whitespaceCodesToText(TextPart textPart) {
if (textPart.isSegment()) return;
TextFragment tf = textPart.getContent();
if (tf.hasText()) return;
if (Util.isEmpty(tf.toText().trim())) {
// Move all codes into text
textPart.setContent(new TextFragment(tf.toText()));
}
}
内容来源于网络,如有侵权,请联系作者删除!