List of usage examples for org.apache.commons.lang StringUtils split
public static String[] split(String str, String separatorChars)
Splits the provided text into an array, separators specified.
From source file:io.kahu.hawaii.config.HawaiiAppContextInitializer.java
private PropertySource<Object> getPropertySource() { List<Resource> resources = new ArrayList<Resource>(); String configurationFiles = System.getProperty("properties.configuration"); String[] files = StringUtils.split(configurationFiles, ","); for (String configFileName : files) { try {/* w w w . j a v a 2s. com*/ File file = new File(configFileName); if (file.exists()) { resources.add(0, new FileSystemResource(file)); } else { System.err.println("Configured properties file '" + configFileName + "' does not exist."); } } catch (Throwable t) { System.err.print("Error loading properties from file '" + configFileName + "': " + t.getMessage()); resources = null; } } try { CompositePropertySource propertySource = new CompositePropertySource("properties"); for (Resource resource : resources) { propertySource.addPropertySource(new ResourcePropertySource(resource)); } return propertySource; } catch (IOException e) { throw new IllegalStateException(e); } }
From source file:mysoft.sonar.plugins.web.check.OnlyOneChildCheck.java
@Override public void startDocument(List<Node> nodes) { for (String item : trimSplitCommaSeparatedList(elements)) { String[] pair = StringUtils.split(item, "."); if (pair.length != 2) continue; ElementRule a = new ElementRule(); a.parent = pair[0].trim();/*from w ww .ja v a2 s.c o m*/ a.child = pair[1].trim(); elementRules.add(a); } }
From source file:com.alibaba.doris.common.operation.OperationPolicy.java
protected void parse(String policyString) { if (StringUtils.isBlank(policyString)) { throw new IllegalArgumentException("Invalid namespace policy cant' be null"); }/*from w ww . j av a 2s . co m*/ try { String[] policyArray = StringUtils.split(policyString, ","); int copyCount = Integer.valueOf(policyArray[0]); int writeCount = Integer.valueOf(policyArray[1]); int readCount = Integer.valueOf(policyArray[2]); this.copyCount = copyCount; this.writeCount = writeCount; this.readCount = readCount; } catch (Exception e) { throw new IllegalArgumentException( "Invalid namespace policy string:'" + policyString + "'. Right format such as :'2,2,1'", e); } }
From source file:edu.ku.brc.af.ui.forms.DataGetterForDOM.java
public Object getFieldValue(Object dataObj, String fieldName) { if (dataObj == null) { return null; }//w w w .ja v a 2 s. c om if (!(dataObj instanceof Element)) { throw new RuntimeException("DataGetterForDOM the dataObj is NOT an a dom4j Element! " + dataObj.getClass().getSimpleName()); } String fldName; String attr; if (fieldName.indexOf('#') > -1) { String[] tokens = StringUtils.split(fieldName, "#"); fldName = tokens[0]; attr = tokens[1]; } else { fldName = fieldName; attr = null; } Element domRoot = (Element) dataObj; Element element = (Element) domRoot.selectSingleNode(fldName); if (element != null) { if (attr != null) { return XMLHelper.getAttr(element, attr, null); } // else return element.getTextTrim(); } return null; }
From source file:info.archinnov.achilles.test.integration.utils.CassandraLogAsserter.java
public void assertConsistencyLevels(ConsistencyLevel read, ConsistencyLevel write) { String[] standardOutputs = StringUtils.split(logStream.toString(), "\n"); try {//from w ww .j a v a2 s .c o m for (String logLine : standardOutputs) { if (logLine.contains("fetchRows Command/ConsistencyLevel is")) { assertThat(logLine).contains("/" + read.name()); } if (logLine.contains("mutate Mutations/ConsistencyLevel are [RowMutation")) { assertThat(logLine).contains("/" + write.name()); } } } finally { logStream = null; storageProxyLogger.setLevel(Level.WARN); storageProxyLogger.removeAppender(writerAppender); } }
From source file:cn.cuizuoli.gotour.utils.HtmlHelper.java
/** * toList/*from w w w .j a v a 2 s . c o m*/ * @param text * @return */ public static String toList(String text) { String[] lines = StringUtils.split(text, "\r\n"); StringBuffer listBuffer = new StringBuffer(); listBuffer.append("<ul>").append("\n"); for (String line : lines) { Matcher listMatcher = LIST_PATTERN.matcher(line); if (listMatcher.matches()) { String li = listMatcher.group(1) + listMatcher.group(2); if (StringUtils.contains(li, "")) { li = "<strong>" + StringUtils.replace(li, "", "</strong>"); } listBuffer.append("<li>").append(li).append("</li>").append("\n"); } } listBuffer.append("</ul>").append("\n"); return listBuffer.toString(); }
From source file:com.thistech.spotlink.job.AdmRegistrationJob.java
public void setAdmEndpoints(String value) { this.admEndpoints = StringUtils.split(value, ","); }
From source file:info.magnolia.cms.util.Rule.java
/** * generate list from the string/*from w ww. ja v a 2 s . co m*/ * @param allowedTypes * @param separator */ public Rule(String allowedTypes, String separator) { String[] types = StringUtils.split(allowedTypes, separator); for (int j = 0; j < types.length; j++) { this.addAllowType(types[j]); } }
From source file:TestExtractor.java
@Test public void TestConf() { try {//from w w w .j av a2s. c om Configuration conf = new PropertiesConfiguration( System.getProperty("user.dir") + "/src/test/resources/xwiki.cfg"); int ldapPort = conf.getInt("xwiki.authentication.ldap.port", 389); String tmpldap_server = conf .getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_server"); //String tmpldap_base_DN = conf.getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_base_DN"); String tmpBinDN = conf.getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_bind_DN"); String tmpldap_bind_pass = conf .getString("xwiki.authentication.trustedldap.remoteUserMapping.ldap_bind_pass"); String[] ldap_server = StringUtils.split(tmpldap_server, "|"); //String[] ldap_base_DN = StringUtils.split(tmpldap_base_DN,"|"); String[] BinDN = StringUtils.split(tmpBinDN, "|"); String[] ldap_bind_pass = StringUtils.split(tmpldap_bind_pass, "|"); //assertTrue(ldap_server.length == ldap_base_DN.length); assertTrue(BinDN.length == ldap_bind_pass.length); assertTrue(ldap_server.length == ldap_bind_pass.length); assertTrue(ldap_server.length == 6); assertTrue(ldapPort == 389); String className = conf.getString("xwiki.authentication.ldap.ssl.secure_provider", "com.sun.net.ssl.internal.ssl.Provider"); assertEquals(className, "com.sun.net.ssl.internal.ssl.Provider"); assertEquals(conf.getInt("xwiki.authentication.ldap.timeout", 500), 500); assertEquals(conf.getInt("xwiki.authentication.ldap.maxresults", 10), 10); } catch (ConfigurationException ex) { Logger.getLogger(TestExtractor.class.getName()).log(Level.SEVERE, null, ex); fail(ex.getLocalizedMessage()); } }
From source file:co.cask.cdap.gateway.router.RouterPathLookup.java
/** * Returns the CDAP service which will handle the HttpRequest * * @param fallbackService service to which we fall back to if we can't determine the destination from the URI path * @param requestPath Normalized (and query string removed) URI path * @param httpRequest HttpRequest used to get the Http method and account id * @return destination service/*from w ww. ja v a 2 s . com*/ */ public String getRoutingService(String fallbackService, String requestPath, HttpRequest httpRequest) { try { String method = httpRequest.getMethod().getName(); AllowedMethod requestMethod = AllowedMethod.valueOf(method); String[] uriParts = StringUtils.split(requestPath, '/'); //Check if the call should go to webapp //If service contains "$HOST" and if first split element is NOT the gateway version, then send it to WebApp //WebApp serves only static files (HTML, CSS, JS) and so /<appname> calls should go to WebApp //But stream calls issued by the UI should be routed to the appropriate CDAP service if (fallbackService.contains("$HOST") && (uriParts.length >= 1) && !("/" + uriParts[0]).equals(Constants.Gateway.API_VERSION_3)) { return fallbackService; } if (uriParts[0].equals(Constants.Gateway.API_VERSION_3_TOKEN)) { return getV3RoutingService(uriParts, requestMethod); } } catch (Exception e) { // Ignore exception. Default routing to app-fabric. } return Constants.Service.APP_FABRIC_HTTP; }