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:ca.on.oicr.pde.workflows.GATK3Workflow.java
@Override public Map<String, SqwFile> setupFiles() { List<String> inputFilesList = Arrays.asList(StringUtils.split(getProperty("input_files"), ",")); Set<String> inputFilesSet = new HashSet<>(inputFilesList); if (inputFilesList.size() != inputFilesSet.size()) { throw new RuntimeException("Duplicate files detected in input_files"); }//from w ww .j a va2 s.c o m if ((inputFilesSet.size() % 2) != 0) { throw new RuntimeException("Each bam should have a corresponding index"); } Map<String, String> bams = new HashMap<>(); Map<String, String> bais = new HashMap<>(); for (String f : inputFilesSet) { String fileExtension = FilenameUtils.getExtension(f); String fileKey = FilenameUtils.removeExtension(f); if (null != fileExtension) { switch (fileExtension) { case "bam": bams.put(fileKey, f); break; case "bai": bais.put(fileKey, f); break; default: throw new RuntimeException("Unsupported input file type"); } } } int id = 0; for (Entry<String, String> e : bams.entrySet()) { String key = e.getKey(); String bamFilePath = e.getValue(); String baiFilePath = bais.get(key); if (baiFilePath == null) { throw new RuntimeException("Missing index for " + FilenameUtils.getName(bamFilePath)); } SqwFile bam = this.createFile("file_in_" + id++); bam.setSourcePath(bamFilePath); bam.setType("application/bam"); bam.setIsInput(true); SqwFile bai = this.createFile("file_in_" + id++); bai.setSourcePath(baiFilePath); bai.setType("application/bam-index"); bai.setIsInput(true); //FIXME: this seems to work for now, it would be better to be able to set the provisionedPath as //bai.getProvisionedPath != bai.getOutputPath ... //at least with seqware 1.1.0, setting output path changes where the output file will be stored, //but the commonly used get provisioned path will return the incorrect path to the file bai.setOutputPath(FilenameUtils.getPath(bam.getProvisionedPath())); inputBamFiles.add(bam.getProvisionedPath()); } return this.getFiles(); }
From source file:com.textocat.textokit.eval.matching.MatchingConfigurationInitializer.java
public TypeBasedMatcherDispatcher<AnnotationFS> create() { String targetTypeNamesStr = propertyResolver .getProperty(ConfigurationKeys.KEY_MATCHING_CONFIGURATION_TARGET_TYPE); if (targetTypeNamesStr == null) { throw new IllegalStateException( String.format("Can't create matcher because there is no property under key %s", ConfigurationKeys.KEY_MATCHING_CONFIGURATION_TARGET_TYPE)); }/*from ww w . j a v a 2 s.co m*/ TypeBasedMatcherDispatcher.Builder<AnnotationFS> builder = TypeBasedMatcherDispatcher.builder(ts); List<String> targetTypeNames = Arrays.asList(StringUtils.split(targetTypeNamesStr, ",;")); for (String ttn : targetTypeNames) { Type targetType = FSTypeUtils.getType(ts, ttn, true); CompositeMatcher<AnnotationFS> m = createTargetMatcher(targetType); builder.addSubmatcher(targetType, m); } return builder.build(); }
From source file:name.martingeisse.stackd.common.geometry.SectionId.java
/** * Constructor.//from w w w . j a va 2 s.c o m * @param identifierText the text returned by {@link #getIdentifierText()}. * @throws IllegalArgumentException if the identifier text is malformed */ public SectionId(String identifierText) throws IllegalArgumentException { final String[] idTextSegments = StringUtils.split(identifierText, '_'); if (idTextSegments.length != 3) { throw new IllegalArgumentException(identifierText); } try { x = Integer.parseInt(idTextSegments[0]); y = Integer.parseInt(idTextSegments[1]); z = Integer.parseInt(idTextSegments[2]); } catch (final NumberFormatException e) { throw new IllegalArgumentException(identifierText); } }
From source file:com.nesscomputing.config.ConfigFactory.java
CombinedConfiguration load() { // Allow foo/bar/baz and foo:bar:baz final String[] configNames = StringUtils.stripAll(StringUtils.split(configName, "/:")); final CombinedConfiguration cc = new CombinedConfiguration(new OverrideCombiner()); // All properties can be overridden by the System properties. cc.addConfiguration(new SystemConfiguration(), "systemProperties"); boolean loadedConfig = false; for (int i = 0; i < configNames.length; i++) { final String configFileName = configNames[configNames.length - i - 1]; final String configFilePath = StringUtils.join(configNames, "/", 0, configNames.length - i); try {//from w w w. j a v a2 s.co m final AbstractConfiguration subConfig = configStrategy.load(configFileName, configFilePath); if (subConfig == null) { LOG.debug("Configuration '%s' does not exist, skipping", configFileName); } else { cc.addConfiguration(subConfig, configFileName); loadedConfig = true; } } catch (ConfigurationException ce) { LOG.error(String.format("While loading configuration '%s'", configFileName), ce); } } if (!loadedConfig && configNames.length > 0) { LOG.warn("Config name '%s' was given but no config file could be found, this looks fishy!", configName); } return cc; }
From source file:net.ontopia.topicmaps.nav2.plugins.PluginContentHandler.java
@Override public void startElement(String nsuri, String lname, String qname, Attributes attrs) throws SAXException { super.startElement(nsuri, lname, qname, attrs); if ("plugin".equals(qname)) { String klass = attrs.getValue("class"); if (klass == null) cplugin = new DefaultPlugin(); else// w w w.java2s .co m cplugin = createPlugin(klass); if (cplugin == null) return; // createPlugin may fail... cplugin.setId(attrs.getValue("id")); String str_groups = attrs.getValue("groups"); // split group containing string into elements if (str_groups != null && !str_groups.equals("")) { String[] grpArray = StringUtils.split(str_groups, ","); List groups = new ArrayList(grpArray.length); for (int i = 0; i < grpArray.length; i++) groups.add(grpArray[i].trim()); cplugin.setGroups(groups); } } else if ("parameter".equals(qname)) { param_name = attrs.getValue("name"); if (attrs.getValue("value") != null) cplugin.setParameter(attrs.getValue("name"), attrs.getValue("value")); } }
From source file:io.wcm.handler.url.impl.UrlHandlerImpl.java
@Override public String rewritePathToContext(final String path, final String contextPath) { if (StringUtils.isEmpty(path) || StringUtils.isEmpty(contextPath)) { return path; }/* w w w . j a va2s . co m*/ // split up paths String[] contextPathParts = StringUtils.split(contextPath, "/"); String[] pathParts = StringUtils.split(path, "/"); // check if both paths are valid - return unchanged path if not int siteRootLevelContextPath = urlHandlerConfig.getSiteRootLevel(contextPath); int siteRootLevelPath = urlHandlerConfig.getSiteRootLevel(path); if ((contextPathParts.length <= siteRootLevelContextPath) || (pathParts.length <= siteRootLevelPath) || !StringUtils.equals(contextPathParts[0], "content") || !StringUtils.equals(pathParts[0], "content")) { return path; } // rewrite path to current context StringBuilder rewrittenPath = new StringBuilder(); for (int i = 0; i <= siteRootLevelContextPath; i++) { rewrittenPath.append('/').append(contextPathParts[i]); } for (int i = siteRootLevelPath + 1; i < pathParts.length; i++) { rewrittenPath.append('/').append(pathParts[i]); } return rewrittenPath.toString(); }
From source file:edu.rosehulman.sws.protocol.AbstractHttpRequest.java
/** * /*from w ww .j a v a 2 s . c om*/ * checks given set of credentials * against requests credentials * * @param username * @param password * @return isAuthorized */ public boolean isAuthorizedFor(String username, String password) { String credentials = this.header.get(Protocol.AUTHORIZATION); if (credentials == null) { return false; } else { String[] credentialParts = StringUtils.split(credentials, Protocol.AUTHORIZATION_SEPERATOR); String requestUsername = credentialParts[0]; String requestPassword = credentialParts[1]; return username.equals(requestUsername) && password.equals(requestPassword); } }
From source file:de.mirkosertic.desktopsearch.SearchServlet.java
private void fillinSearchResult(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletException, IOException { URLCodec theURLCodec = new URLCodec(); String theQueryString = aRequest.getParameter("querystring"); String theBasePath = basePath; String theBackLink = basePath; if (!StringUtils.isEmpty(theQueryString)) { try {/* w w w . j ava2 s . c o m*/ theBasePath = theBasePath + "/" + theURLCodec.encode(theQueryString); theBackLink = theBackLink + "/" + theURLCodec.encode(theQueryString); } catch (EncoderException e) { LOGGER.error("Error encoding query string " + theQueryString, e); } } Map<String, String> theDrilldownDimensions = new HashMap<>(); String thePathInfo = aRequest.getPathInfo(); if (!StringUtils.isEmpty(thePathInfo)) { String theWorkingPathInfo = thePathInfo; // First component is the query string if (theWorkingPathInfo.startsWith("/")) { theWorkingPathInfo = theWorkingPathInfo.substring(1); } String[] thePaths = StringUtils.split(theWorkingPathInfo, "/"); for (int i = 0; i < thePaths.length; i++) { try { String theDecodedValue = thePaths[i].replace('+', ' '); String theEncodedValue = theURLCodec.encode(theDecodedValue); theBasePath = theBasePath + "/" + theEncodedValue; if (i < thePaths.length - 1) { theBackLink = theBackLink + "/" + theEncodedValue; } if (i == 0) { theQueryString = theDecodedValue; } else { FacetSearchUtils.addToMap(theDecodedValue, theDrilldownDimensions); } } catch (EncoderException e) { LOGGER.error("Error while decoding drilldown params for " + aRequest.getPathInfo(), e); } } if (basePath.equals(theBackLink)) { theBackLink = null; } } else { theBackLink = null; } if (!StringUtils.isEmpty(theQueryString)) { aRequest.setAttribute("querystring", theQueryString); try { aRequest.setAttribute("queryResult", backend.performQuery(theQueryString, theBackLink, theBasePath, theDrilldownDimensions)); } catch (Exception e) { LOGGER.error("Error running query " + theQueryString, e); } } else { aRequest.setAttribute("querystring", ""); } aRequest.setAttribute("serverBase", serverBase); aRequest.getRequestDispatcher("/index.ftl").forward(aRequest, aResponse); }
From source file:com.jdy.ddj.common.orm.PageRequest.java
/** * ???./*w ww.java2s. c o m*/ * * @param orderDir ?descasc,?','. */ public void setOrderDir(final String orderDir) { if (orderDir == null) { return; } String lowcaseOrderDir = StringUtils.lowerCase(orderDir); //order? String[] orderDirs = StringUtils.split(lowcaseOrderDir, ','); for (String orderDirStr : orderDirs) { if (!StringUtils.equals(Sort.DESC, orderDirStr) && !StringUtils.equals(Sort.ASC, orderDirStr)) { throw new IllegalArgumentException("??" + orderDirStr + "??"); } } this.orderDir = lowcaseOrderDir; }
From source file:de.adorsys.multibanking.hbci.job.LoadBalanceJob.java
private static boolean initFailed(HBCIExecStatus status) { return Stream.of(StringUtils.split(status.getErrorString(), System.getProperty("line.separator"))) .anyMatch(line -> line.charAt(0) == '9'); }