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:de.micromata.genome.gwiki.pagelifecycle_1_0.artefakt.GWikiBranchFileStatsArtefakt.java
/** * Compiles branchfilestats from file/*from w w w .j av a 2 s . c om*/ */ private BranchFileStats compileObject() { if (StringUtils.isBlank(super.getStorageData()) == true) { return new BranchFileStats(); } String[] lines = StringUtils.split(super.getStorageData(), "\n"); BranchFileStats fileStats = new BranchFileStats(); for (final String line : lines) { FileStatsDO fileStatsDO = new FileStatsDO(); Map<String, String> map = PipeValueList.decode(line); fileStatsDO.setPageId(map.get(FileStatsDO.PAGE_ID)); String s = map.get(FileStatsDO.FILE_STATE); if (StringUtils.isNotBlank(s) == true) { fileStatsDO.setFileState(FileState.valueOf(s)); } fileStatsDO.setCreatedAt(map.get(FileStatsDO.CREATED_AT)); fileStatsDO.setCreatedBy(map.get(FileStatsDO.CREATED_BY)); fileStatsDO.setLastModifiedAt(map.get(FileStatsDO.MODIFIED_AT)); fileStatsDO.setLastModifiedBy(map.get(FileStatsDO.MODIFIED_BY)); fileStatsDO.setAssignedTo(map.get(FileStatsDO.ASSIGNED_TO)); fileStatsDO.setStartAt(map.get(FileStatsDO.START_AT)); fileStatsDO.setEndAt(map.get(FileStatsDO.END_AT)); fileStatsDO.setPreviousAssignee(map.get(FileStatsDO.PREVIOUS_ASSIGNEE)); String operatorsString = map.get(FileStatsDO.OPERATORS); String[] operatorArray = StringUtils.split(operatorsString, ","); if (operatorArray != null) { Set<String> operators = new HashSet<String>(); for (String operator : operatorArray) { operators.add(operator); } fileStatsDO.setOperators(operators); } fileStats.addFileStats(fileStatsDO); } return fileStats; }
From source file:net.sourceforge.mavenhippo.SourceCodeBeanFinder.java
public Map<String, HippoBeanClass> getBeansInProject(ContextParameterExtractor contextParameterExtractor) { Map<String, HippoBeanClass> result = new HashMap<String, HippoBeanClass>(); String sourceDirectoryPath = sourceDirectory.getAbsolutePath(); String beansAnnotatedClassesParam = contextParameterExtractor .getContextParameter(Constants.ContextParameter.BEANS_ANNOTATED_CLASSES_PARAM); if (beansAnnotatedClassesParam.startsWith(CLASSPATH)) { String[] split = StringUtils.split(beansAnnotatedClassesParam, ", \t\r\n"); for (String slice : split) { File packageFolder = getPackageFolder(sourceDirectoryPath, slice); if (packageFolder.exists()) { scanPackageRecursively(packageFolder, result, maximumDepthOfScan); }//w ww . j av a2 s. c om } } return result; }
From source file:name.martingeisse.common.util.string.StringUtil.java
/** * Splits the specified string as {@link StringUtils#split(String, char)} * does, then trims the resulting segments. * //from w w w. j av a 2 s . c om * @param s the string to split * @param separator the separator character * @return the trimmed segments */ public static String[] splitAndTrim(String s, char separator) { String[] result = StringUtils.split(s, separator); for (int i = 0; i < result.length; i++) { result[i] = result[i].trim(); } return result; }
From source file:com.techcavern.wavetact.ircCommands.chanhalfop.Topic.java
@Override public void onCommand(String command, User user, PircBotX network, String prefix, Channel channel, boolean isPrivate, int userPermLevel, String... args) throws Exception { Record topicseparator = DatabaseUtils.getChannelProperty(IRCUtils.getNetworkNameByNetwork(network), channel.getName(), "topicseparator"); boolean isTopicCommand = args[0].equalsIgnoreCase("ad") || args[0].equalsIgnoreCase("add") || args[0].startsWith("+") || args[0].startsWith("-") || args[0].equalsIgnoreCase("sw") || args[0].equalsIgnoreCase("swap") || args[0].equalsIgnoreCase("switch") || args[0].equalsIgnoreCase("rev") || args[0].equalsIgnoreCase("revert"); if (!isTopicCommand) { IRCUtils.setTopic(network, channel, GeneralUtils.buildMessage(0, args.length, args)); saveTopic(channel, network);/* w w w .ja v a 2 s . c om*/ return; } else if (topicseparator == null) { IRCUtils.sendError(user, network, channel, "Please set the topic separator before using this command", prefix); return; } StringUtils.split(channel.getTopic(), topicseparator.getValue(CHANNELPROPERTY.VALUE)); List<String> topic = new LinkedList(Arrays .asList(StringUtils.split(channel.getTopic(), topicseparator.getValue(CHANNELPROPERTY.VALUE)))); List<String> newtopic = new LinkedList(Arrays .asList(StringUtils.split(channel.getTopic(), topicseparator.getValue(CHANNELPROPERTY.VALUE)))); if (args[0].equalsIgnoreCase("ad") || args[0].equalsIgnoreCase("add")) { IRCUtils.setTopic(network, channel, channel.getTopic() + " " + topicseparator.getValue(CHANNELPROPERTY.VALUE) + " " + GeneralUtils.buildMessage(1, args.length, args)); saveTopic(channel, network); } else if (args[0].startsWith("+")) { newtopic.set(Integer.parseInt(args[0].replaceFirst("\\+", "")) - 1, " " + GeneralUtils.buildMessage(1, args.length, args) + " "); IRCUtils.setTopic(network, channel, StringUtils.join(newtopic, topicseparator.getValue(CHANNELPROPERTY.VALUE))); saveTopic(channel, network); } else if (args[0].startsWith("-")) { newtopic.remove(Integer.parseInt(args[0].replaceFirst("\\-", "")) - 1); IRCUtils.setTopic(network, channel, StringUtils.join(newtopic, topicseparator.getValue(CHANNELPROPERTY.VALUE))); saveTopic(channel, network); } else if (args[0].equalsIgnoreCase("sw") || args[0].equalsIgnoreCase("swap") || args[0].equalsIgnoreCase("switch")) { newtopic.set((Integer.parseInt(args[1]) - 1), topic.get(Integer.parseInt(args[2]) - 1)); newtopic.set((Integer.parseInt(args[2]) - 1), topic.get(Integer.parseInt(args[1]) - 1)); channel.send().setTopic(StringUtils.join(newtopic, topicseparator.getValue(CHANNELPROPERTY.VALUE))); saveTopic(channel, network); } else if (args[0].equalsIgnoreCase("rev") || args[0].equalsIgnoreCase("revert")) { Record oldTopic = DatabaseUtils.getChannelProperty(IRCUtils.getNetworkNameByNetwork(network), channel.getName(), "topic"); if (oldTopic != null) { IRCUtils.setTopic(network, channel, oldTopic.getValue(CHANNELPROPERTY.VALUE)); } else { IRCUtils.sendError(user, network, channel, "Error: no reversal possible", prefix); } } else { IRCUtils.setTopic(network, channel, GeneralUtils.buildMessage(0, args.length, args)); saveTopic(channel, network); } }
From source file:com.denimgroup.threadfix.importer.update.impl.DefectTrackerUpdater.java
@Override public void doUpdate(@Nonnull String fileName, @Nonnull BufferedReader reader) throws IOException { LOG.info("Updating defect tracker information from file " + fileName); String line = reader.readLine(); while (line != null) { String[] splitLine = StringUtils.split(line, ','); if (splitLine.length == 2) { DefectTrackerType type = defectTrackerTypeDao.retrieveByNameIgnoreCase(splitLine[0]); if (type == null) { // let's create one type = new DefectTrackerType(); type.setName(splitLine[0]); type.setFullClassName(splitLine[1]); defectTrackerTypeDao.saveOrUpdate(type); LOG.info("Created a Defect Tracker with name " + splitLine[0]); } else { LOG.info("Already had an entry for " + splitLine[0]); if (type.getFullClassName().contains("JiraDefectTracker")) { type.setName("JIRA"); }//from w ww . jav a2 s.c o m type.setFullClassName(splitLine[1]); defectTrackerTypeDao.saveOrUpdate(type); } } else { LOG.error("Line had " + splitLine.length + " sections instead of 2: " + line); } line = reader.readLine(); } }
From source file:com.hybris.mobile.app.commerce.activity.ApplicationActivity.java
public String backdoorLogin(String argument) { String parameters[] = StringUtils.split(argument, ';'); return CalabashUtils.login(this, parameters[0], parameters[1], parameters[2]); }
From source file:me.mayo.telnetkek.ConnectionManager.java
public void triggerConnect(final String hostnameAndPort) { final String[] parts = StringUtils.split(hostnameAndPort, ":"); if (parts.length <= 1) { this.triggerConnect(parts[0], 23); } else {/*from w ww . j av a2 s . c o m*/ int _port = 23; try { _port = Integer.parseInt(parts[1]); } catch (NumberFormatException ex) { } this.triggerConnect(parts[0], _port); } }
From source file:com.xpn.xwiki.XWikiConfig.java
/** * @return array of string splited from property. * @param param - name of property/* www . j a v a 2 s . c o m*/ */ public String[] getPropertyAsList(String param) { return StringUtils.split(getProperty(param, ""), " ,"); }
From source file:ca.on.oicr.pde.workflows.GATKGenotypeGVCFsWorkflow.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 w w .java 2 s. c o m*/ if ((inputFilesSet.size() % 2) != 0) { throw new RuntimeException("Each GVCF should have a corresponding index"); } Map<String, String> gvcfs = new HashMap<>(); Map<String, String> gvcfIndexes = new HashMap<>(); for (String f : inputFilesSet) { if (f == null || f.isEmpty()) { } else if (f.endsWith("g.vcf.gz")) { gvcfs.put(StringUtils.removeEnd(f, "g.vcf.gz"), f); } else if (f.endsWith("g.vcf.gz.tbi")) { gvcfIndexes.put(StringUtils.removeEnd(f, "g.vcf.gz.tbi"), f); } else { throw new RuntimeException("Unsupported input file: [" + f + "]"); } } int id = 0; for (Entry<String, String> e : gvcfs.entrySet()) { String key = e.getKey(); String gvcfFilePath = e.getValue(); String gvcfIndexFilePath = gvcfIndexes.get(key); if (gvcfIndexFilePath == null) { throw new RuntimeException("Missing index for " + FilenameUtils.getName(gvcfFilePath)); } SqwFile gvcf = this.createFile("file_in_" + id++); gvcf.setSourcePath(gvcfFilePath); gvcf.setType("application/g-vcf-gz"); gvcf.setIsInput(true); SqwFile gvcfIndex = this.createFile("file_in_" + id++); gvcfIndex.setSourcePath(gvcfIndexFilePath); gvcfIndex.setType("application/tbi"); gvcfIndex.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 gvcfIndex.setOutputPath(FilenameUtils.getPath(gvcf.getProvisionedPath())); inputFiles.add(gvcf.getProvisionedPath()); } return this.getFiles(); }
From source file:com.thruzero.common.core.utils.StringUtilsExt.java
/** * Create a byte array from the given {@code tokenStream}, using the given token {@code separator}. Leading and trailing spaces of each token are trimmed. * <p>// w w w . j a v a 2 s .c o m * Example input: "0xc3, 0x41, 0x55, 0xed, 0xf4, 0x41, 0x3e, 0x61". */ public static byte[] tokensToByteArray(final String tokenStream, final String separator) { byte[] result; String[] stringArray = StringUtils.split(tokenStream, separator); int i = 0; result = new byte[stringArray.length]; for (String string : stringArray) { int num = Short.decode(string.trim()); result[i++] = (byte) num; } return result; }