List of usage examples for org.apache.commons.lang3 StringUtils split
public static String[] split(final String str, final String separatorChars)
Splits the provided text into an array, separators specified.
From source file:com.github.wolfdogs.kemono.util.resource.fs.FsDirResource.java
@Override public DirResource getParent() { if (dirPath == null || dirPath == "") { return null; }//from w ww .ja v a2s .com String[] pathArr = StringUtils.split(dirPath, "/\\"); StringBuffer parentPath = new StringBuffer(); for (int i = 1; i < pathArr.length - 1; i++) { if (pathArr[i] == null) pathArr[i] = ""; parentPath.append(pathArr[i]); } return generateDirRes(parentPath.toString()); }
From source file:io.cloudex.framework.utils.ObjectUtils.java
/** * comma separated string to set//from w ww . java 2 s . co m * @param csv * @return */ public static Set<String> csvToSet(String csv) { Set<String> tokens = new HashSet<>(); if (StringUtils.isNotBlank(csv)) { String[] tokensArr = StringUtils.split(csv, ','); // clean up the tokens //tokens = Sets.newHashSet(tokensArr); for (String token : tokensArr) { tokens.add(token.trim()); } } return tokens; }
From source file:com.nts.alphamale.util.Utils.java
/*** * ? ?? /*from w ww. jav a 2 s .c om*/ * @param screenSize : ? ? (ex : 720X1280) * @param width : ?? * @param height : ?? * @return */ public static double[] getScreenRatio(String screenSize, int width, int height) { if (screenSize != null) { if (screenSize.contains("x")) screenSize = screenSize.replace("x", ","); if (screenSize.contains("X")) screenSize = screenSize.replace("X", ","); double ratioX = Utils.getRatio(Integer.parseInt(StringUtils.split(screenSize, ",")[0]), width); double ratioY = Utils.getRatio(Integer.parseInt(StringUtils.split(screenSize, ",")[1]), height); return new double[] { ratioX, ratioY }; } return new double[] { 1.0, 1.0 }; }
From source file:com.anrisoftware.globalpom.checkfilehash.CheckFileHash.java
private String readExpectedHash(URI hashResource) throws Exception { if (StringUtils.equals(hashResource.getScheme(), "md5")) { return hashResource.getSchemeSpecificPart(); } else if (StringUtils.equals(hashResource.getScheme(), "sha1")) { return hashResource.getSchemeSpecificPart(); } else {/*from w ww . j a v a 2 s. co m*/ String line = readLines(hashResource.toURL().openStream()).get(0); String hash = StringUtils.split(line, SEP)[0]; return hash; } }
From source file:com.eryansky.common.orm.core.PageRequest.java
/** * ??./*from w w w. ja v a2 s . c o m*/ */ @SuppressWarnings("unchecked") public List<Sort> getSort() { if (orderBy == null || orderDir == null) { return Collections.EMPTY_LIST; } String[] orderBys = StringUtils.split(orderBy, ','); String[] orderDirs = StringUtils.split(orderDir, ','); Assert.isTrue(orderBys.length == orderDirs.length, "???,????"); List<Sort> orders = new ArrayList<Sort>(); for (int i = 0; i < orderBys.length; i++) { orders.add(new Sort(orderBys[i], orderDirs[i])); } return orders; }
From source file:atg.tools.dynunit.nucleus.NucleusFactory.java
private void setSystemPropertiesFromEnvironment() { logger.entry();// w ww . j a v a 2s. c om final String[] properties = StringUtils.split(environment, ';'); if (properties == null) { logger.exit(); return; } for (String property : properties) { final String[] entry = StringUtils.split(property, '='); if (entry.length > 1) { final String key = entry[0]; final String value = entry[1]; logger.debug("Setting property {} = {}", key, value); setSystemProperty(key, value); } } logger.exit(); }
From source file:de.micromata.genome.db.jpa.normsearch.NormalizedSearchServiceImpl.java
@Override public String[] tokenize(String input) { if (StringUtils.isEmpty(input) == true) { return new String[] {}; }//ww w. j av a2 s . c o m // String t = input.toUpperCase(); String[] els = StringUtils.split(input, " \t\n"); for (int i = 0; i < els.length; ++i) { els[i] = normalize(els[i]); } return els; }
From source file:info.magnolia.ui.api.action.ActionDefinitionKeyGenerator.java
/** * Will generate keys for the message bundle in the following form <code> <app-name>.<sub-app-name>.actions.<action-name>[.name of getter or field annotated with {@link info.magnolia.i18nsystem.I18nText}]</code>. * <p>/*from w ww. ja v a 2 s . c o m*/ * Also generates "default" keys for all actions. Still unique keys for those actions are generated in case one wants to override the default ones. For example, if your app has a commit action defined like this <code>/modules/my-module/apps/my-app/subApps/detail/actions/commit</code> a fallback key will in the form <code>actions.commit</code> will be generated besides a <code>my-module.detail.actions.commit</code> key. */ @Override protected void keysFor(List<String> keys, ActionDefinition actionDefinition, AnnotatedElement el) { final String fieldOrGetterName = fieldOrGetterName(el); final String actionName = actionDefinition.getName(); final Object root = getRoot(actionDefinition); if (root instanceof AppDescriptor) { final AppDescriptor appDescriptor = (AppDescriptor) root; Object parent = getParentViaCast(actionDefinition); if (parent instanceof SubAppDescriptor) { final SubAppDescriptor subAppDescriptor = (SubAppDescriptor) parent; addKey(keys, appDescriptor.getName(), subAppDescriptor.getName(), "actions", actionName, fieldOrGetterName); } else { addKey(keys, appDescriptor.getName(), "chooseDialog", "actions", actionName, fieldOrGetterName); } } else { final List<String> ancestorKeys = getKeysfromAncestors(actionDefinition, el, root); if (ancestorKeys.isEmpty()) { String idOrName = getIdOrNameForUnknownRoot(actionDefinition); if (idOrName != null) { addKey(keys, idOrName, "actions", actionName, fieldOrGetterName); String[] parts = StringUtils.split(idOrName, "."); if (parts.length > 1) { String idOrNameNoModuleName = parts[parts.length - 1]; addKey(keys, idOrNameNoModuleName, "actions", actionName, fieldOrGetterName); } } } else { addKey(keys, StringUtils.join(ancestorKeys, '.'), "actions", actionName, fieldOrGetterName); } } // add a fallback key for all actions addKey(keys, "actions", actionName, fieldOrGetterName); }
From source file:io.wcm.devops.conga.generator.plugins.fileheader.XmlFileHeader.java
@Override public FileHeaderContext extract(FileContext file) { try {/*from ww w .j av a2 s . co m*/ Document doc = documentBuilder.parse(file.getFile()); if (doc.getChildNodes().getLength() > 0) { Node firstNode = doc.getChildNodes().item(0); if (firstNode instanceof Comment) { String comment = StringUtils.trim(((Comment) firstNode).getTextContent()); List<String> lines = ImmutableList.copyOf(StringUtils.split(comment, "\n")); return new FileHeaderContext().commentLines(lines); } } } catch (SAXException | IOException ex) { throw new GeneratorException("Unable to parse file header from " + FileUtil.getCanonicalPath(file), ex); } return null; }
From source file:com.adguard.android.contentblocker.preferences.PreferenceDb.java
private void refreshItems() { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); for (PreferenceItem item : itemsList) { if (item.value instanceof Boolean) { item.value = prefs.getBoolean(item.name, (Boolean) item.value); } else if (item.value instanceof Integer) { item.value = prefs.getInt(item.name, (Integer) item.value); } else if (item.value instanceof String) { item.value = prefs.getString(item.name, (String) item.value); } else if (item.value instanceof String[]) { item.value = StringUtils.split(prefs.getString(item.name, (String) item.value), System.lineSeparator()); }//from w ww . j a v a 2 s . c o m } }