List of usage examples for org.apache.commons.lang StringUtils split
public static String[] split(String str)
Splits the provided text into an array, using whitespace as the separator.
From source file:com.xebia.incubator.xebium.SeleniumServerFixture.java
/** * Start server with arguments./* w ww . j ava 2 s . com*/ * * @param args Arguments, same as when started from command line */ public void startSeleniumServer(final String args) { if (seleniumProxy != null) { throw new IllegalStateException("There is already a Selenium remote server running"); } try { final RemoteControlConfiguration configuration; LOG.info("Starting server with arguments: '" + args + "'"); //String[] argv = StringUtils.isNotBlank(args) ? StringUtils.split(args) : new String[] {}; String[] argv = StringUtils.split(args); configuration = RemoteControlLauncher.parseLauncherOptions(argv); //checkArgsSanity(configuration); System.setProperty("org.openqa.jetty.http.HttpRequest.maxFormContentSize", "0"); // default max is 200k; zero is infinite seleniumProxy = new SeleniumServer(isSlowConnection(), configuration); seleniumProxy.start(); } catch (Exception e) { //server.stop(); LOG.info("Server stopped"); } }
From source file:de.thischwa.pmcms.tool.InternalAntTool.java
/** * Starts poormans with respect of the current OS. Dependent on that, special JVM settings and environment variables * are set./*from www.j a v a 2s . c om*/ * * @param dataDir Data directory to use for. * @param props Properties to use for. * @param starterClass * @param printDebug if true additional logging informations will be print out at stdio. * @param additionalArgs Additional poormans commandline arguments. Can be <tt>null</tt> or empty. */ public static void start(final File dataDir, final Properties props, final String starterClass, boolean printDebug, final String[] additionalArgs) { OSDetector.Type os = OSDetector.getType(); // Throws a RuntimeException, if os isn't supported! Project project = buildProject(); List<String> jvmArgs = new ArrayList<String>(); if (props.getProperty("jvm.arguments") != null) { String args = props.getProperty("jvm.arguments"); if (printDebug) project.log("Raw JVM argements: " + args); jvmArgs = new ArrayList<String>(Arrays.asList(StringUtils.split(args))); } Throwable caught = null; String propLib = props.getProperty("pmcms.dir.lib"); String propLibSwt = props.getProperty("pmcms.dir.lib.swt"); if (printDebug) { project.log("Java: " + System.getProperty("java.version")); project.log("OS: " + os); project.log("Starter class: " + starterClass); project.log("Lib-folder: " + propLib); project.log("Lib-swt-folder: " + propLibSwt); } int retVal = -1; try { /** initialize an java task **/ Java javaTask = new Java(); javaTask.setNewenvironment(true); javaTask.setTaskName("runjava"); javaTask.setProject(project); javaTask.setFork(true); javaTask.setFailonerror(true); javaTask.setClassname(starterClass); /** build the class path */ Path classPath = new Path(project); javaTask.setClasspath(classPath); FileSet libFileSet = new FileSet(); libFileSet.setDir(new File(Constants.APPLICATION_DIR, propLib)); libFileSet.setIncludes("**/*jar,**/*properties"); /** build the requested swt-jar */ boolean enable64bit = Boolean.parseBoolean(props.getProperty("pmcms.64bit")); String swt64bitAddOn = (enable64bit) ? "_64" : ""; if (printDebug) project.log(String.format("Requested swt-arch: %sbit", (enable64bit) ? "64" : "32")); String swtFolderRaw; switch (os) { case MAC: swtFolderRaw = "cocoa-macosx%s"; break; case LINUX: swtFolderRaw = "gtk-linux-x86%s"; break; default: swtFolderRaw = "win32-win32-x86%s"; } swtFolderRaw = String.format("%s/%s", propLibSwt, swtFolderRaw); String swtFolder = String.format(swtFolderRaw, swt64bitAddOn); File swtDir = new File(Constants.APPLICATION_DIR, swtFolder); if (printDebug) project.log(String.format("Swt-directory: %s", swtDir.getPath())); FileSet swtFileSet = new FileSet(); swtFileSet.setDir(swtDir); swtFileSet.setIncludes("*jar"); classPath.addFileset(swtFileSet); classPath.addFileset(libFileSet); if (printDebug) project.log("Classpath: " + classPath); // add some vm args dependent on the os switch (os) { case MAC: if (!jvmArgs.contains("-XstartOnFirstThread")) jvmArgs.add("-XstartOnFirstThread"); break; case WIN: String arg = String.format("-Djava.library.path=%s", swtFolder); jvmArgs.add(arg); break; case LINUX: // no special properties required, setting be done by jvm args break; default: project.log("Error: Unknown OS: " + OSDetector.getOSString()); System.exit(3); break; } // add jvm args if exists if (!jvmArgs.isEmpty()) { // clean-up the jvm-args and ensure that each one starts with '-D' or '-X' List<String> tmpArgs = new ArrayList<String>(); for (String arg : jvmArgs) { if (arg.startsWith("-D") || arg.startsWith("-d") || arg.startsWith("-X") || arg.startsWith("-x")) tmpArgs.add(arg); } jvmArgs.clear(); jvmArgs.addAll(tmpArgs); // build the args line and replace inline-variables String jvmArgsLine = StringUtils.join(jvmArgs, ' '); Argument argument = javaTask.createJvmarg(); argument.setLine(jvmArgsLine); if (printDebug) project.log("JVM args: " + jvmArgsLine); } // add some program args if exists String strArgs = String.format("-datadir \"%s\"", dataDir); if (additionalArgs != null && additionalArgs.length > 0) strArgs += " " + StringUtils.join(additionalArgs, ' '); Argument taskArgs = javaTask.createArg(); taskArgs.setLine(strArgs); if (printDebug) project.log("Program-args: " + strArgs); // call the java task javaTask.init(); retVal = javaTask.executeJava(); } catch (Exception e) { caught = e; } if (caught != null) project.log("Error while starting poormans: " + caught.getMessage(), caught, Project.MSG_ERR); else if (retVal != 0 && caught == null) project.log("finished with code: " + retVal); else project.log("successful finished"); project.fireBuildFinished(caught); }
From source file:hudson.plugins.clearcase.ucm.service.ActivityService.java
public Collection<Activity> getContributingActivities(Activity activity) throws IOException, InterruptedException { String output = lsActivityToString(activity, "%[contrib_acts]Xp"); Collection<Activity> activities = new ArrayList<Activity>(); for (String activityId : StringUtils.split(output)) { activities.add(UcmSelector.parse(activityId, Activity.class)); }/* ww w .jav a 2 s .com*/ return activities; }
From source file:edu.ku.brc.ui.CsvTableModel.java
public CsvTableModel(File csvFile) throws Exception { listeners = new Vector<TableModelListener>(); rand = new Random(); randStart = rand.nextInt(2756);/* www . j av a 2 s.co m*/ rowData = new Vector<String[]>(); methods = new Vector<String>(); this.csvFile = csvFile; FileReader fr = new FileReader(csvFile); BufferedReader br = new BufferedReader(fr); // first line is header String line = br.readLine(); header = StringUtils.split(line); line = br.readLine(); while (line != null) { String[] row = StringUtils.split(line); if (row.length > 0) { rowData.add(row); } line = br.readLine(); } for (int i = 0; i < rowData.size(); ++i) { //setup a method int j = rand.nextInt(15); if (j == 0) { methods.add("dynamite"); } else if (j == 1) { methods.add("boat electro-shocker"); } else { methods.add("seine"); } } }
From source file:de.hybris.platform.acceleratorstorefrontcommons.util.MetaSanitizerUtil.java
/** * Takes a string of words, removes duplicates and returns a comma separated list of keywords as a String * * @param keywords/*from www . j a va2s .co m*/ * Keywords to be sanitized * @return String of comma separated keywords */ public static String sanitizeKeywords(final String keywords) { final String clean = StringUtils.isNotEmpty(keywords) ? Jsoup.parse(keywords).text() : ""; // Clean html final String[] cleaned = StringUtils.split(clean.replace("\"", "")); // Clean quotes // Remove duplicates String noDupes = ""; for (final String word : cleaned) { if (!noDupes.contains(word)) { noDupes += word + ","; } } if (!noDupes.isEmpty()) { noDupes = noDupes.substring(0, noDupes.length() - 1); } return noDupes; }
From source file:com.adobe.acs.commons.quickly.Command.java
public Command(final String raw) { this.raw = StringUtils.stripToEmpty(raw); String opWithPunctuation = StringUtils .stripToEmpty(StringUtils.lowerCase(StringUtils.substringBefore(this.raw, " "))); int punctuationIndex = StringUtils.indexOfAny(opWithPunctuation, PUNCTUATIONS); if (punctuationIndex > 0) { this.punctuation = StringUtils.substring(opWithPunctuation, punctuationIndex).split("(?!^)"); this.operation = StringUtils.substring(opWithPunctuation, 0, punctuationIndex); } else {// w ww .j a v a 2s. c o m this.punctuation = new String[] {}; this.operation = opWithPunctuation; } this.param = StringUtils.stripToEmpty(StringUtils.removeStart(this.raw, opWithPunctuation)); this.params = StringUtils.split(this.param); if (log.isTraceEnabled()) { log.trace("Raw: {}", this.raw); log.trace("Operation: {}", this.operation); log.trace("Punctuation: {}", Arrays.toString(this.punctuation)); log.trace("Param: {}", this.param); log.trace("Params: {}", Arrays.toString(this.params)); } }
From source file:com.google.gdt.eclipse.designer.gxt.databinding.wizards.autobindings.GxtWidgetDescriptor.java
public void setPropertyClass(String classes) { m_propertyClasses = StringUtils.split(classes); }
From source file:com.google.gdt.eclipse.designer.gxt.model.layout.AnchorDataInfo.java
public String getAnchorWidth() throws Exception { String anchor = getAnchor();// w ww. j a v a 2 s.c o m if (anchor != null) { String[] anchorParts = StringUtils.split(anchor); if (anchorParts.length >= 1) { return anchorParts[0]; } } return null; }
From source file:com.egt.core.db.util.InterpreteSqlPostgreSQL.java
@Override public String getComandoExecute(String comando, int argumentos, EnumTipoResultadoSQL tipoResultado) { boolean retornaResultadoCompuesto = EnumTipoResultadoSQL.COMPUESTO.equals(tipoResultado); String execute = StringUtils.stripToNull(comando); String command = retornaResultadoCompuesto ? COMANDO_EXECUTE_2 : COMANDO_EXECUTE_1; if (execute != null) { String[] token = StringUtils.split(execute); String parametros = "()"; if (argumentos > 0) { parametros = ""; for (int i = 0; i < argumentos; i++, parametros += ",?") { }/*from ww w. j av a 2s .co m*/ parametros = "(" + parametros.substring(1) + ")"; } if (!token[0].equalsIgnoreCase(COMANDO_EXECUTE_1)) { execute = command + " " + execute; } if (!execute.endsWith(parametros) && !execute.endsWith(";")) { execute += parametros; } } return execute; }
From source file:name.richardson.james.bukkit.utilities.command.argument.PositionalArgument.java
protected final String[] removeOptionsAndSwitches(String arguments) { arguments = arguments.replaceAll(OptionArgument.getPattern().toString(), ""); arguments = arguments.replaceAll(SwitchArgument.getPattern().toString(), ""); return StringUtils.split(arguments); }