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:net.ontopia.topicmaps.utils.ScopeUtilsTest.java
public Collection makeContext(String spec) { Collection scope = new HashSet(); String[] tokens = StringUtils.split(spec, ","); for (int ix = 0; ix < tokens.length; ix++) { String token = tokens[ix].trim(); if (!token.isEmpty()) scope.add(getTopic(token));/*from w ww. j ava 2s.co m*/ } return scope; }
From source file:com.neatresults.mgnltweaks.ui.contentapp.browser.QueryableJcrContainer.java
@Override protected String getQueryWhereClause() { String[] segments = StringUtils.split(path, "/"); if ("dialogs".equals(segments[2])) { String id = segments[1] + ":" + StringUtils.substringAfter(path, "/dialogs/"); return " where contains(t.dialog, '" + id + "') or contains(t.dialogName, '" + id + "')" + buildExtends(path);/* w w w.j a v a2s.com*/ } else if ("templates".equals(segments[2])) { String id = segments[1] + ":" + StringUtils.substringAfter(path, "/templates/"); this.setWorkspace(RepositoryConstants.WEBSITE); return " where contains(t.[mgnl:template], '" + id + "')"; } else { return " where " + buildExtends(path).substring(3); } }
From source file:com.nesscomputing.jdbi.AnnotatedStatementLocator.java
@Override public String locate(final String statementName, final StatementContext context) throws Exception { if (StringUtils.isEmpty(statementName)) { throw new IllegalStateException("Statement Name can not be empty/null!"); }//w w w .j a v a 2s.co m if (statementName.startsWith(markerString)) { return defaultSqlLocator.getTemplate(statementName.substring(markerString.length()), context); } final String[] fieldElements = StringUtils.split(statementName, ':'); if (fieldElements.length != 2 || !fieldElements[1].startsWith(markerString)) { return defaultLocate(statementName, context); } // If the class in the tuple is actually the class for which this locator is intended, don't load // everything again, just reuse the existing sqllocator. if (defaultClassName.equals(fieldElements[0])) { return defaultSqlLocator.getTemplate(fieldElements[1].substring(markerString.length()), context); } try { final SqlLocator sqlLocator = new SqlLocator(Class.forName(fieldElements[0])); return sqlLocator.getTemplate(fieldElements[1].substring(markerString.length()), context); } catch (ClassNotFoundException cnfe) { LOG.trace(cnfe, "Ignoring, falling back to default locator"); } catch (IllegalArgumentException ex) { LOG.trace(ex, "Ignoring, falling back to default locator"); } return defaultLocate(statementName, context); }
From source file:com.anrisoftware.sscontrol.scripts.findusedport.FindUsedPort.java
private void parsePortService(Map<Integer, String> services, int port, String line) { String[] split = StringUtils.split(line, " "); String service = null;//from w w w . ja v a 2 s . c o m for (int i = 0; i < split.length; i++) { if (SERVICES_PATTERN.matcher(split[i]).matches()) { service = split[i]; } } String[] servicesplit = StringUtils.split(service, "/"); service = servicesplit[servicesplit.length - 1]; services.put(port, service); }
From source file:com.refreshsf.contrib.client.types.opts.HtmlOptions.java
public List<String> customAttrAssign() { return Arrays.asList(StringUtils.split(get("customAttrAssign", ""), ",")); }
From source file:com.synopsys.integration.hub.bdio.BdioTransformer.java
private ExternalId recreateExternalId(final Forge forge, final String fullExternalId, final String name, final String revision) { final String[] pieces = StringUtils.split(fullExternalId, forge.getSeparator()); final ExternalId id = new ExternalId(forge); if (pieces.length == 1) { // assume path but could be a 1 length moduleNames id...le sigh id.path = pieces[0];/*from w ww . j av a 2 s. c om*/ } else if (pieces.length == 2 || pieces.length == 3) { if (pieces[0].equals(name)) { id.name = pieces[0]; id.version = pieces[1]; if (pieces.length > 2) { id.architecture = pieces[2]; } } else if (pieces[1].equals(name) && pieces[2].equals(revision)) { id.group = pieces[0]; id.name = pieces[1]; id.version = pieces[2]; } else { id.moduleNames = pieces; } } else { id.moduleNames = pieces; } return id; }
From source file:jp.mathes.databaseWiki.dav.DavServlet.java
@Override public Resource getResource(final String host, final String path) { DbwConfiguration.getInstance()/*from www . java 2 s. c o m*/ .davLog(String.format("Entering getResource for host '%s' and path '%s'.", host, path)); String realPath = path.replace(this.cutoffPath, ""); realPath = StringUtils.strip(realPath, "/"); String[] realPathSplit = StringUtils.split(realPath, "/"); if (realPathSplit.length == 1) { return new DbResource(realPathSplit[0]); } else if (realPathSplit.length == 2) { return new TableResource(realPathSplit[0], realPathSplit[1]); } else if (realPathSplit.length == 3) { return new DocumentResource(realPathSplit[0], realPathSplit[1], realPathSplit[2]); } else { throw new RuntimeException(String.format("Invalid path '%s'", path)); } }
From source file:com.sunlights.common.utils.PropertyFilter.java
/** * @param filterName/* www. j a v a 2 s . co m*/ * @param value */ public PropertyFilter(final String filterName, final String value) { String matchTypeStr; String matchPattenCode = LikeMatchPatten.ALL.toString(); String matchTypeCode; String propertyTypeCode; if (filterName.contains("LIKE") && filterName.charAt(0) != 'L') { matchTypeStr = StringUtils.substringBefore(filterName, PARAM_PREFIX); matchPattenCode = StringUtils.substring(matchTypeStr, 0, 1); matchTypeCode = StringUtils.substring(matchTypeStr, 1, matchTypeStr.length() - 1); propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1, matchTypeStr.length()); } else { matchTypeStr = StringUtils.substringBefore(filterName, PARAM_PREFIX); matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1); propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1, matchTypeStr.length()); } try { matchType = Enum.valueOf(MatchType.class, matchTypeCode); likeMatchPatten = Enum.valueOf(LikeMatchPatten.class, matchPattenCode); } catch (RuntimeException e) { throw new IllegalArgumentException("filter name: " + filterName + "Not prepared in accordance with rules, not get more types of property.", e); } try { propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue(); } catch (RuntimeException e) { throw new IllegalArgumentException("filter name: " + filterName + "Not prepared in accordance with the rules, attribute value types can not be.", e); } String propertyNameStr = StringUtils.substringAfter(filterName, PARAM_PREFIX); propertyNames = StringUtils.split(propertyNameStr, PropertyFilter.OR_SEPARATOR); Validate.isTrue(propertyNames.length > 0, "filter name: " + filterName + "Not prepared in accordance with the rules, property names can not be."); this.propertyValue = ConvertUtils.convert(value, propertyType); }
From source file:cn.guoyukun.spring.jpa.repository.hibernate.type.CollectionToStringUserType.java
/** * JDBC ResultSet??,??//w w w . j a v a2 s . co m * (?null?) * names???? * * @param names * @param owner * @return * @throws org.hibernate.HibernateException * @throws java.sql.SQLException */ @Override public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { String valueStr = rs.getString(names[0]); if (StringUtils.isEmpty(valueStr)) { return newCollection(); } String[] values = StringUtils.split(valueStr, separator); Collection result = newCollection(); for (String value : values) { if (StringUtils.isNotEmpty(value)) { result.add(ConvertUtils.convert(value, elementType)); } } return result; }
From source file:com.piesky.core.orm.Page.java
/** * ???./*w w w. ja v a 2 s . c om*/ * * @param order * ?descasc,?','. */ public void setOrder(final String order) { String lowcaseOrder = StringUtils.lowerCase(order); // order? String[] orders = StringUtils.split(lowcaseOrder, ','); for (String orderStr : orders) { if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) { throw new IllegalArgumentException("??" + orderStr + "??"); } } this.order = lowcaseOrder; }