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:com.neatresults.mgnltweaks.ui.contentapp.browser.QueryableJcrContainer.java
@Override protected QueryResult executeQuery(String statement, String language, long limit, long offset) throws RepositoryException { log.debug("ST: {}", statement); String[] segments = StringUtils.split(path, "/"); // templates needs 2 queries - one for website and one for config if ("templates".equals(segments[2])) { // pages//from w ww.j a va 2 s.c o m QueryResult res1 = super.executeQuery(statement, language, limit, offset); // config this.setWorkspace(RepositoryConstants.CONFIG); statement = StringUtils.substringBefore(statement, " where ") + " where" // id references (availability, autogeneration, ...) + " contains(t.*,'" + segments[1] + ":" + StringUtils.substringAfter(path, "/templates/") + "')" // extends + buildExtends(path); log.debug("ST2: {}", statement); QueryResult res2 = super.executeQuery(statement, language, limit, offset); return new AggregatedQueryResult(res1, res2); } this.setWorkspace(RepositoryConstants.CONFIG); return super.executeQuery(statement, language, limit, offset); }
From source file:at.beris.virtualfile.LocalArchivedFileTest.java
private String extractName(String path) { String[] pathParts = StringUtils.split(path, java.io.File.separator); return pathParts[pathParts.length - 1]; }
From source file:com.mirth.connect.connectors.smtp.SmtpSenderService.java
@Override public Object invoke(String channelId, String method, Object object, String sessionId) throws Exception { if (method.equals("sendTestEmail")) { SmtpDispatcherProperties props = (SmtpDispatcherProperties) object; String host = replacer.replaceValues(props.getSmtpHost(), channelId); String portString = replacer.replaceValues(props.getSmtpPort(), channelId); int port = -1; try {/*from w w w. j av a 2s. c o m*/ port = Integer.parseInt(portString); } catch (NumberFormatException e) { return new ConnectionTestResponse(ConnectionTestResponse.Type.FAILURE, "Invalid port: \"" + portString + "\""); } String secure = props.getEncryption(); boolean authentication = props.isAuthentication(); String username = replacer.replaceValues(props.getUsername(), channelId); String password = replacer.replaceValues(props.getPassword(), channelId); String to = replacer.replaceValues(props.getTo(), channelId); String from = replacer.replaceValues(props.getFrom(), channelId); Email email = new SimpleEmail(); email.setDebug(true); email.setHostName(host); email.setSmtpPort(port); if ("SSL".equalsIgnoreCase(secure)) { email.setSSL(true); } else if ("TLS".equalsIgnoreCase(secure)) { email.setTLS(true); } if (authentication) { email.setAuthentication(username, password); } email.setSubject("Mirth Connect Test Email"); try { for (String toAddress : StringUtils.split(to, ",")) { email.addTo(toAddress); } email.setFrom(from); email.setMsg( "Receipt of this email confirms that mail originating from this Mirth Connect Server is capable of reaching its intended destination.\n\nSMTP Configuration:\n- Host: " + host + "\n- Port: " + port); email.send(); return new ConnectionTestResponse(ConnectionTestResponse.Type.SUCCESS, "Sucessfully sent test email to: " + to); } catch (EmailException e) { return new ConnectionTestResponse(ConnectionTestResponse.Type.FAILURE, e.getMessage()); } } return null; }
From source file:com.mingo.convert.ConverterService.java
/** * Constructor with parameters.//from www . j a v a 2 s . c om * * @param convertersPackages converters packages */ public ConverterService(String convertersPackages) { if (StringUtils.isNotBlank(convertersPackages)) { convertersPackages = convertersPackages.replaceAll("\\s", ""); this.convertersPackages = Sets.newHashSet(StringUtils.split(convertersPackages, ",")); initConvertersClasses(); } }
From source file:com.paladin.mvc.ActionServlet.java
/** * init actions which declared in web.xml *///from w ww . j a va 2 s .c o m @Override public void init() throws ServletException { String packages = getInitParameter("packages"); actionPackages = Arrays.asList(StringUtils.split(packages, ',')); String initial_actions = getInitParameter("initial_actions"); for (String action : StringUtils.split(initial_actions, ',')) try { loadAction(action); } catch (Exception e) { log.error("Failed to initial action : " + action, e); } }
From source file:io.apiman.gateway.vertx.api.AuthenticatingRouteMatcher.java
private boolean basicAuth(HttpServerRequest request, String encodedAuth) { byte[] authBytes = Base64.decodeBase64(encodedAuth); String decodedString = new String(authBytes); String[] splitAuth = StringUtils.split(StringUtils.trim(decodedString), ":"); //$NON-NLS-1$ if (splitAuth.length != 2) return false; if (fileBasicAuthData.containsKey(splitAuth[0])) { String storedHash = new String(Base64.decodeBase64(fileBasicAuthData.get(splitAuth[0]))); MessageDigest digest;//from ww w . j ava2 s .co m try { digest = MessageDigest.getInstance("SHA-256"); //$NON-NLS-1$ digest.update(splitAuth[1].getBytes()); String receivedHash = new String(digest.digest()); if (storedHash.equals(receivedHash)) { return true; } } catch (NoSuchAlgorithmException e) { logger.error(e.getMessage(), e.getCause()); } } request.response().headers().add("WWW-Authenticate", "Basic realm=\"" + config.getRealm() + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return false; }
From source file:com.nts.alphamale.util.Utils.java
/*** * String ? Point ? // w w w.ja v a2 s . com * @param pointStr * @return */ public static Point stringToPoint(String pointStr) { if (pointStr != null && pointStr.contains(",")) { return new Point(Integer.valueOf(StringUtils.split(pointStr, ",")[0]), Integer.valueOf(StringUtils.split(pointStr, ",")[1])); } return null; }
From source file:com.github.wolfdogs.kemono.util.resource.zip.ZipDirResource.java
private void createResource(String path, ZipArchiveEntry entry) { String[] childs = StringUtils.split(path, "/\\"); ZipDirResource res = this; for (int i = 0; i < childs.length - 1; i++) { String name = childs[i];/*from w w w . ja v a2 s . c o m*/ ZipDirResource child = (ZipDirResource) res.getDir(name); if (child == null) child = new ZipDirResource(res, zipFile); res.addResource(name, child); res = child; } if (entry.isDirectory()) { ZipDirResource child = new ZipDirResource(res, zipFile); child.setEntry(entry); res.addResource(childs[childs.length - 1], child); } else { ZipFileResource child = new ZipFileResource(res, zipFile, entry); res.addResource(childs[childs.length - 1], child); } }
From source file:com.github.jknack.handlebars.internal.HbsErrorReporter.java
@Override public void syntaxError(final Recognizer<?, ?> recognizer, final Object offendingSymbol, final int line, final int charPositionInLine, final String msg, final RecognitionException e) { int column = Math.max(1, charPositionInLine); CommonToken offendingToken = (CommonToken) offendingSymbol; StringBuilder message = new StringBuilder(); message.append(filename).append(":").append(line).append(":").append(column).append(": "); String stacktrace = ""; int reasonStart = message.length(); if (offendingToken == null) { String[] parts = StringUtils.split(msg, "\n"); message.append(parts[0]);// w ww . j a va2 s . c o m stacktrace = "\n" + join(parts, "\n", 1, parts.length); } else { message.append("found: '").append(offendingToken.getText()).append("', "); message.append("expected: '").append(msg).append("'"); } String reason = message.substring(reasonStart); message.append("\n"); int evidenceStat = message.length(); String[] lines = lines(recognizer); underline(message, lines, line, column); String prevLine = lineAt(lines, line > lines.length ? lines.length : line - 2); String nextLine = lineAt(lines, line); String evidence = prevLine + "\n" + message.substring(evidenceStat) + "\n" + nextLine; message.append(stacktrace); HandlebarsError error = new HandlebarsError(filename, line, column, reason.replace("<EOF>", "EOF"), evidence, message.toString()); throw new HandlebarsException(error); }
From source file:com.jdom.word.playdough.android.AndroidGamePackResolver.java
@Override public SortedSet<String> getGamePackNames() { InputStream openRawResource = null; String gamePackList = ""; try {// w w w . j a v a 2 s. c o m openRawResource = context.getResources().openRawResource(ID_OF_GAME_PACK_LIST); gamePackList = IOUtils.toString(openRawResource); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(openRawResource); } String[] gamePacks = StringUtils.split(gamePackList, '\n'); TreeSet<String> treeSet = new TreeSet<String>(new Comparator<String>() { public int compare(String arg0, String arg1) { return new Integer(arg0).compareTo(new Integer(arg1)); } }); treeSet.addAll(Arrays.asList(gamePacks)); return treeSet; }