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.anrisoftware.sscontrol.scripts.findusedport.FindUsedPort.java
private Map<Integer, String> findServices(ProcessTask task) { String out = task.getOut();/*w w w . j ava 2 s . c om*/ String[] lines = StringUtils.split(out, "\n"); Map<Integer, String> services = new HashMap<Integer, String>(); for (int i = 0; i < lines.length; i++) { for (Integer port : ports) { if (StringUtils.contains(lines[i], format(":%d ", port))) { parsePortService(services, port, lines[i]); } } } return services; }
From source file:de.jcup.egradle.sdk.builder.action.javadoc.RemoveWhitespacesAndStarsFromJavadocAction.java
private String buildNewDescription(Type parentType, String description, SDKBuilderContext context) throws IOException { if (description == null) { return null; }/*ww w . j ava 2s . c om*/ StringBuilder fullDescription = new StringBuilder(); String[] lines = StringUtils.split(description, System.getProperty("line.separator")); for (String line : lines) { String newLine = removeWhitespacesAndStars(line); fullDescription.append(newLine); fullDescription.append("\n"); } return fullDescription.toString(); }
From source file:de.micromata.genome.db.jpa.normsearch.NormalizedSearchServiceImpl.java
@Override public List<Long> search(IEmgr<?> emgr, final Class<? extends NormSearchDO> clazz, final String expression) { if (StringUtils.isBlank(expression) == true) { return Collections.emptyList(); }/* ww w.j av a 2s . co m*/ String[] tks = StringUtils.split(expression, " "); StringBuilder sb = new StringBuilder(); Map<String, Object> args = new HashMap<String, Object>(); sb.append("select distinct(m.parent) from ").append(clazz.getSimpleName()).append(" m where "); int num; for (int i = 0; i < tks.length; ++i) { if (i > 0) { sb.append(" or "); } sb.append("m.value like :a" + i); args.put("a" + i, normalize(tks[i]) + "%"); } return emgr.selectAttached(Long.class, sb.toString(), args); }
From source file:info.magnolia.ui.api.location.DefaultLocation.java
private void parseLocation(String fragment) { String[] split = StringUtils.split(fragment, ";"); setAppParams(split[0]);/*from w w w . ja va 2s .c om*/ if (split.length == 2) { this.parameter = decodeFragment(split[1]); } }
From source file:com.hibo.bas.fileplugin.file.FtpPlugin.java
@Override public void upload(String path, File file, String contentType) { Map<String, String> ftpInfo = getFtpInfo(contentType); if (!"".equals(ftpInfo.get("host")) && !"".equals(ftpInfo.get("username")) && !"".equals(ftpInfo.get("password"))) { FTPClient ftpClient = new FTPClient(); InputStream inputStream = null; try {/*from w w w . j a v a 2 s .c o m*/ inputStream = new FileInputStream(file); ftpClient.connect(ftpInfo.get("host"), 21); ftpClient.login(ftpInfo.get("username"), ftpInfo.get("password")); ftpClient.setFileTransferMode(FTP.STREAM_TRANSFER_MODE); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); ftpClient.enterLocalPassiveMode(); path = ftpInfo.get("path") + path; if (FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) { String directory = StringUtils.substringBeforeLast(path, "/"); String filename = StringUtils.substringAfterLast(path, "/"); if (!ftpClient.changeWorkingDirectory(directory)) { String[] paths = StringUtils.split(directory, "/"); String p = "/"; ftpClient.changeWorkingDirectory(p); for (String s : paths) { p += s + "/"; if (!ftpClient.changeWorkingDirectory(p)) { ftpClient.makeDirectory(s); ftpClient.changeWorkingDirectory(p); } } } ftpClient.storeFile(filename, inputStream); ftpClient.logout(); } } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inputStream); if (ftpClient.isConnected()) { try { ftpClient.disconnect(); } catch (IOException e) { } } } } }
From source file:org.meruvian.yama.core.application.Application.java
@Transient public Set<String> getRegisteredRedirectUris() { String[] redirectUris = StringUtils.split(this.redirectUris, ','); if (redirectUris == null) return new LinkedHashSet<String>(); return new LinkedHashSet<String>(Arrays.asList(redirectUris)); }
From source file:com.nesscomputing.migratory.jdbi.MigratoryStatementLocator.java
@Override public String locate(final String statementName, final StatementContext context) throws Exception { context.setAttribute(MigratoryStatementRewriter.SKIP_REWRITE, null); if (StringUtils.isEmpty(statementName)) { throw new IllegalStateException("Statement Name can not be empty/null!"); }/* ww w . j a v a 2 s.c o m*/ // This is a recorded statement that comes from some loader. This needs // to be preregistered using addTemplate, so look there. if (statementName.charAt(0) == '@') { LOG.trace("Retrieving statement: %s", statementName); final String rawSql = sql.get(statementName); if (rawSql == null) { throw new IllegalStateException("Statement '" + statementName + "' not registered!"); } // @T is a template. if (statementName.charAt(1) == 'T') { return templatize(rawSql, context); } else { context.setAttribute(MigratoryStatementRewriter.SKIP_REWRITE, Boolean.TRUE); return rawSql; } } // Or is it one of the internal statements used by // migratory to do its housekeeping? If yes, load it from the // predefined location on the class path. else if (statementName.charAt(0) == '#') { // Multiple templates can be in a string template group. In that case, the name is #<template-group:<statement name> final String[] statementNames = StringUtils.split(statementName.substring(1), ":"); final String sqlLocation = SQL_LOCATION + context.getAttribute("db_type") + "/" + statementNames[0] + ".st"; LOG.trace("Loading SQL: %s", sqlLocation); final URL location = Resources.getResource(MigratoryStatementLocator.class, sqlLocation); if (location == null) { throw new IllegalArgumentException("Location '" + sqlLocation + "' does not exist!"); } final String rawSql = Resources.toString(location, Charsets.UTF_8); if (statementNames.length == 1) { // Plain string template file. Just run it. return templatize(rawSql, context); } else { final StringTemplateGroup group = new StringTemplateGroup(new StringReader(rawSql), AngleBracketTemplateLexer.class); LOG.trace("Found %s in %s", group.getTemplateNames(), location); final StringTemplate template = group.getInstanceOf(statementNames[1]); template.setAttributes(context.getAttributes()); final String sql = template.toString(); LOG.trace("SQL: %s", sql); return sql; } } // Otherwise, it is raw SQL that was run on the database. Pass it through. else { context.setAttribute(MigratoryStatementRewriter.SKIP_REWRITE, Boolean.TRUE); return statementName; } }
From source file:com.github.sdbg.core.test.util.PlainTestProject.java
public IFolder createFolder(String path) throws Exception { String[] parts = StringUtils.split(path, "/"); IContainer container = project;/*from w w w . j ava 2s . com*/ for (String part : parts) { IFolder folder = container.getFolder(new Path(part)); if (!folder.exists()) { folder.create(true, true, null); } container = folder; } return (IFolder) container; }
From source file:com.l2jfree.gameserver.network.L2ClientSelectorThread.java
public void printDebug(ByteBuffer buf, L2Client client, int... opcodes) { report(ErrorMode.INVALID_OPCODE, client, null, null); if (!Config.PACKET_HANDLER_DEBUG) return;//ww w. j av a2 s . c o m L2TextBuilder sb = L2TextBuilder.newInstance(); sb.append("Unknown Packet: "); for (int i = 0; i < opcodes.length; i++) { if (i != 0) sb.append(" : "); sb.append("0x").append(Integer.toHexString(opcodes[i])); } sb.append(", Client: ").append(client); _log.info(sb.moveToString()); byte[] array = new byte[buf.remaining()]; buf.get(array); for (String line : StringUtils.split(HexUtil.printData(array), "\n")) _log.info(line); }
From source file:com.ebuddy.cassandra.cql.dao.CqlStructuredDataSupportSystemTest.java
@BeforeMethod(groups = { "system" }) public void setUp() throws Exception { MockitoAnnotations.initMocks(this); EmbeddedCassandraServerHelper.startEmbeddedCassandra(); // default to using cassandra on localhost, but can be overridden with a system property String cassandraHostsString = System.getProperty(CASSANDRA_HOSTS_SYSTEM_PROPERTY, LOCALHOST_IP); String[] cassandraHosts = StringUtils.split(cassandraHostsString, ','); Cluster.Builder clusterBuilder = Cluster.builder(); for (String host : cassandraHosts) { clusterBuilder.addContactPoint(host); }/* w ww . j a va 2 s .co m*/ cluster = clusterBuilder.withPort(9142).build(); dropAndCreateSchema(); // get new session using a default keyspace that we now know exists session = cluster.connect(TEST_KEYSPACE); session = spy(session); daoSupport = new CqlStructuredDataSupport<UUID>(tableName, ConsistencyLevel.QUORUM, session); }