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:eu.openanalytics.rsb.security.IdentifiedUserDetailsService.java
@PostConstruct public void initializeGrantedAuthorities() { grantedAuthorities = new HashSet<GrantedAuthority>(); if (StringUtils.isBlank(configuredAuthorities)) { return;/*from w ww .j a va 2s .c om*/ } for (final String configuredAuthority : StringUtils.split(configuredAuthorities, ", ")) { final String strippedAuthority = StringUtils.stripToEmpty(configuredAuthority); if (StringUtils.isNotEmpty(strippedAuthority)) { grantedAuthorities.add(new SimpleGrantedAuthority(strippedAuthority)); } } }
From source file:com.ppcxy.cyfm.showcase.demos.utilities.string.ApacheStringUtilsDemo.java
@Test public void joinSplit() { // join// www . j a v a 2s. c o m List<String> inputList = Lists.newArrayList("a", "b", "c"); String result = StringUtils.join(inputList, ","); assertThat(result).isEqualTo("a,b,c"); // split String input = "a,b,c"; String[] resultArray = StringUtils.split(input, ","); assertThat(resultArray).containsSequence("a", "b", "c"); }
From source file:be.error.rpi.knx.UdpChannel.java
@Override public void run() { String s = null;/* ww w . ja v a2 s . c om*/ try { logger.debug("UdpChannel on port " + clientSocket.getPort() + " started."); while (true) { byte b[] = new byte[256]; DatagramPacket receivePacket = new DatagramPacket(b, b.length); clientSocket.receive(receivePacket); s = new String(b, "UTF8").trim(); logger.debug("UdpChannel received " + s); String[] split = StringUtils.split(s, "|"); UdpChannelCommand udpChannelCommand = fromString(split[0]); synchronized (udpChannelCallbacks) { this.udpChannelCallbacks.stream().filter(cb -> cb.command() == udpChannelCommand) .forEach(cb -> { try { cb.callBack(StringUtils.join(remove(split, 0))); } catch (Exception e) { logger.error("UdpChannel on port " + clientSocket.getPort() + " with command " + cb.command().toString(), e); } }); } } } catch (Exception e) { logger.error("UdpChannel on port " + clientSocket.getPort() + " with raw command " + s, e); } }
From source file:com.precioustech.fxtrading.utils.TradingUtils.java
/** * Utility method to return the currency pair which form the tradeable * instrument. It is effectively a string tokeniser with no validation for * currency or number of tokens or in fact the separator character. * /* ww w .j ava 2 s .c o m*/ * input "GBP_USD", "_" will return ["GBP","USD"] input "GBP_USD", "/" will * return ["GBP_USD"] input "hello_GBP_USD", "_" will return * ["hello","GBP","USD"] * * @param instrument * @param currencySeparator * @return String tokens for instrument which contains currencySeparator. */ public static String[] splitCcyPair(String instrument, String currencySeparator) { return StringUtils.split(instrument, currencySeparator); }
From source file:com.navercorp.pinpoint.web.batch.BatchConfiguration.java
private void readPropertyValues(Properties properties) { logger.info("pinpoint-batch.properties read."); batchServerIp = readString(properties, "batch.server.ip", null); String[] flinkServers = StringUtils.split(readString(properties, "batch.flink.server", null), ","); if (flinkServers == null) { this.flinkServerList = Collections.emptyList(); } else {//from ww w . j a v a2s.com this.flinkServerList = new ArrayList<>(flinkServers.length); for (String flinkServer : flinkServers) { if (!StringUtils.isEmpty(flinkServer)) { this.flinkServerList.add(StringUtils.trim(flinkServer)); } } } }
From source file:io.wcm.maven.plugins.contentpackage.ArtifactHelper.java
public File getArtifactFile(final String artifactId, final String groupId, final String version, final String packaging, final String artifact) throws MojoFailureException, MojoExecutionException { // check if artifact was specified if ((StringUtils.isEmpty(artifactId) || StringUtils.isEmpty(groupId) || StringUtils.isEmpty(version)) && StringUtils.isEmpty(artifact)) { return null; }/*from w ww. j a v a2s . co m*/ // split up artifact string Artifact artifactObject; if (StringUtils.isEmpty(artifactId)) { String[] parts = StringUtils.split(artifact, ":"); if (parts.length < 3 && parts.length > 4) { throw new MojoFailureException("Invalid artifact: " + artifact); } artifactObject = repository.createArtifact(parts[0], parts[1], parts[2], parts.length > 3 ? parts[3] : null); } else { artifactObject = repository.createArtifact(groupId, artifactId, version, packaging); } // resolve artifact ArtifactResolutionRequest request = new ArtifactResolutionRequest(); request.setArtifact(artifactObject); request.setLocalRepository(localRepository); request.setRemoteRepositories(remoteRepositories); ArtifactResolutionResult result = repository.resolve(request); if (result.isSuccess()) { return artifactObject.getFile(); } else { throw new MojoExecutionException("Unable to download artifact: " + artifactObject.toString()); } }
From source file:com.cognifide.aet.job.common.comparators.source.diff.DiffParser.java
/** * Generates deltas of changes using DiffUtils library. If {trimmed} all source lines are trimmed before * comparison in order to remove white spaces differences between html tags. * * @param pattern - pattern to compare * @param source - source to compare * @param trimmedLines - flag if lines should be trimmed * @return List of Delta changes//w w w .j a v a 2 s . co m */ public List<ResultDelta> generateDiffs(String pattern, String source, boolean trimmedLines) { List<String> patternList = Arrays.asList(StringUtils.split(pattern, NEW_LINE)); List<String> sourceList = Arrays.asList(StringUtils.split(source, NEW_LINE)); if (trimmedLines) { patternList = Lists.transform(patternList, TRIM_FUNCTION); sourceList = Lists.transform(sourceList, TRIM_FUNCTION); } Patch patch = DiffUtils.diff(patternList, sourceList); List<Delta> deltas = patch.getDeltas(); return addFullSource(deltas, patternList, sourceList); }
From source file:io.bibleget.BibleGetSelection.java
public void getQuoteFromSelection() { List<String> preferredVersions = new ArrayList<>(); Object retVal = biblegetDB.getOption("PREFERREDVERSIONS"); if (null == retVal) { } else {//from w ww. j a v a 2s .co m String[] favoriteVersions = StringUtils.split((String) retVal, ','); preferredVersions = Arrays.asList(favoriteVersions); } if (preferredVersions.isEmpty()) { preferredVersions.add("NVBSE"); } String versions = StringUtils.join(preferredVersions.toArray(), ','); Object m_xCurSel; try { m_xCurSel = m_xTextDocument.getCurrentSelection(); if (m_xCurSel != null) { //there is a selection, we can do something with it XIndexAccess xIndex = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, m_xCurSel); Object Sel0; try { Sel0 = xIndex.getByIndex(0); XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, Sel0); String myInputContent = xTextRange.getString(); myInputContent = StringUtils.deleteWhitespace(myInputContent); //System.out.println("You typed : "+myInputContent); if (myInputContent.isEmpty() == false) { HTTPCaller myHTTPCaller = new HTTPCaller(); String myResponse; try { Boolean querycheck = myHTTPCaller.integrityCheck(myInputContent, preferredVersions); if (querycheck) { //JOptionPane.showMessageDialog(null, "All is proceeding nicely", "progress info", JOptionPane.INFORMATION_MESSAGE); myResponse = myHTTPCaller.sendGet(myInputContent, versions); if (myResponse != null) { xTextRange.setString(""); BibleGetJSON myJSON = new BibleGetJSON(m_xController); myJSON.JSONParse(myResponse); } else { JOptionPane.showMessageDialog(null, __( "There was a problem communicating with the BibleGet server. Please try again."), "ERROR >> SERVER CONNECTIVITY ISSUE", JOptionPane.ERROR_MESSAGE); } } else { String[] errorMessages = myHTTPCaller.getErrorMessages(); String errorDialog = StringUtils.join(errorMessages, "\n\n"); JOptionPane.showMessageDialog(null, errorDialog, "ERROR >> MALFORMED QUERYSTRING", JOptionPane.ERROR_MESSAGE); } } catch (HeadlessException | ClassNotFoundException | UnknownPropertyException | PropertyVetoException | com.sun.star.lang.IllegalArgumentException | WrappedTargetException ex) { Logger.getLogger(BibleGetFrame.class.getName()).log(Level.SEVERE, null, ex); } } else { JOptionPane.showMessageDialog(null, __("You cannot send an empty query."), "ERROR >> EMPTY SELECTION", JOptionPane.ERROR_MESSAGE); } } catch (IndexOutOfBoundsException | WrappedTargetException ex) { Logger.getLogger(BibleGetSelection.class.getName()).log(Level.SEVERE, null, ex); } } } catch (Exception ex) { Logger.getLogger(BibleGetSelection.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:ch.cyberduck.core.manta.MantaAccountHomeInfo.java
private Path buildNormalizedHomePath(final String rawHomePath) { final String defaultPath = StringUtils.defaultIfBlank(rawHomePath, Path.HOME); final String accountRootRegex = String.format("^/?(%s|~~?)/?", accountRoot.getAbsolute()); final String subdirectoryRawPath = defaultPath.replaceFirst(accountRootRegex, ""); if (StringUtils.isEmpty(subdirectoryRawPath)) { return accountRoot; }/*from w w w . j av a2 s. c o m*/ final String[] subdirectoryPathSegments = StringUtils.split(subdirectoryRawPath, Path.DELIMITER); Path homePath = accountRoot; for (final String pathSegment : subdirectoryPathSegments) { EnumSet<Path.Type> types = EnumSet.of(Path.Type.directory); if (homePath.getParent().equals(accountRoot) && StringUtils.equalsAny(pathSegment, HOME_PATH_PRIVATE, HOME_PATH_PUBLIC)) { types.add(Path.Type.volume); } homePath = new Path(homePath, pathSegment, types); } return homePath; }
From source file:com.textocat.textokit.eval.TypeSystemInitializer.java
@SuppressWarnings("unused") @PostConstruct/*from w w w .j ava 2 s . com*/ private void init() { if (!isBlank(typeSystemDescPathsString)) { typeSystemDescPaths = StringUtils.split(typeSystemDescPathsString, ";,"); } if (!isBlank(typeSystemDescNamesString)) { typeSystemDescNames = StringUtils.split(typeSystemDescNamesString, ";,"); } }