List of usage examples for org.apache.commons.lang StringUtils join
public static String join(Collection<?> collection, String separator)
Joins the elements of the provided Collection
into a single String containing the provided elements.
From source file:adalid.core.ViewSelect.java
private String filters(List<String> list) { return list == null || list.isEmpty() ? "" : " WHERE (" + StringUtils.join(list, " AND ") + ") "; }
From source file:info.archinnov.achilles.internal.metadata.holder.AbstractComponentProperties.java
@Override public String toString() { return Objects.toStringHelper(this.getClass()) .add("componentClasses", StringUtils.join(Lists.transform(componentClasses, fqcnToStringFn), ",")) .add("componentNames", componentNames).toString(); }
From source file:io.viewserver.execution.nodes.UnEnumNode.java
@Override protected String getConfigForOperatorName(ParameterHelper parameterHelper) { return String.format("unenum:%s:%s", dataSource.getName(), StringUtils.join(dimensions, ',')); }
From source file:commondb.mock.MockResultSet.java
/** * ResultSet rs = new MockResultSet(/* w w w . j av a 2 s . co m*/ * "ID,NAME,CITY", * "3,John,New York", * "4,Bill,Sydney" * ); * * @param str headers and rows that form the CSV data */ public MockResultSet(String... str) throws SQLException { loadCSV(new StringReader(StringUtils.join(str, "\n"))); }
From source file:de.dlr.knowledgefinder.dataimport.utils.transformer.ArrayToStringTransformer.java
@Override public Object transformRow(Map<String, Object> row, Context context) { for (Map<String, String> map : context.getAllEntityFields()) { String column = map.get(DataImporter.COLUMN); String source = map.get(ARRAY_SOURCE_DATA_FIELD); if (source != null && row.containsKey(source) && row.get(source) != null) { try { String result = ""; if (row.get(source) instanceof Object[]) { Object[] array = (Object[]) row.get(source); result = StringUtils.join(array, ", "); } else result = row.get(source).toString(); row.put(column, result); } catch (Exception e) { LOG.warn(e.toString());//from ww w. j av a 2 s . c o m } } } return row; }
From source file:au.org.ala.delta.intkey.directives.invocation.ContentsDirectiveInvocation.java
@Override public boolean execute(IntkeyContext context) { try {//from w w w .j a v a2 s .c om BufferedReader reader = new BufferedReader(new FileReader(file)); // use LinkedHashMap to maintain insertion order of keys LinkedHashMap<String, String> contentsMap = new LinkedHashMap<String, String>(); String line; while ((line = reader.readLine()) != null) { if (line.contains("*")) { String[] tokens = line.split("\\*"); if (tokens.length != 2) { context.getUI() .displayErrorMessage(UIUtils.getResourceString("BadlyFormedContentsFile.error")); return false; } contentsMap.put(tokens[0].trim(), tokens[1].trim()); } else { String[] tokens = line.split(" "); if (tokens.length > 1) { String description = StringUtils.join(Arrays.copyOf(tokens, tokens.length - 1), " "); String fileName = tokens[tokens.length - 1]; // TODO hack here. Really should be building // IntkeyDirectiveInvocation objects // from both line formats and passing them to the // contents directive, rather than // getting the contents directive to do directive // parsing. String command = "FILE DISPLAY " + fileName.trim(); contentsMap.put(description.trim(), command); } else { } } } context.getUI().displayContents(contentsMap); } catch (IOException ex) { } return true; }
From source file:com.perl5.lang.perl.psi.references.PerlNamespaceFileReference.java
@Override public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException { String currentName = myElement.getCanonicalName(); if (currentName != null && newElementName.endsWith(".pm")) { String[] nameChunks = currentName.split(PerlPackageUtil.PACKAGE_SEPARATOR); nameChunks[nameChunks.length - 1] = newElementName.replaceFirst("\\.pm$", ""); newElementName = StringUtils.join(nameChunks, PerlPackageUtil.PACKAGE_SEPARATOR); return super.handleElementRename(newElementName); }/*w w w .ja v a 2s . c o m*/ throw new IncorrectOperationException("Can't bind package use/require to a non-pm file: " + newElementName); }
From source file:net.morematerials.cmds.SMExecutor.java
@SuppressWarnings("unchecked") public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (args.length == 0) { sender.sendMessage(MainManager.getUtils() .getMessage("This server is running " + this.plugin.getDescription().getName() + " " + "v" + plugin.getDescription().getVersion() + "! " + "Credits to " + StringUtils.join(this.plugin.getDescription().getAuthors(), ", ") + "!")); return true; }/*ww w. j av a2 s. c om*/ // Help parameter. if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help")) { // Someone specified the command to get help for. if (args.length > 1) { Map<String, Object> commands = (HashMap<String, Object>) this.plugin.getDescription().getCommands() .values(); if (!commands.containsKey(args[1])) { return false; } sender.sendMessage(MainManager.getUtils().getMessage("Help page for /" + args[1], Level.SEVERE)); sender.sendMessage(MainManager.getUtils().getMessage("---------------------------------")); String commandInfo = (String) ((HashMap<String, Object>) commands.get(args[1])).get("usage"); for (String usage : StringUtils.split(commandInfo, "\n")) { usage = usage.replaceAll("<command>", args[1] + ChatColor.GOLD); sender.sendMessage(MainManager.getUtils().getMessage(usage, Level.WARNING)); } // Someone wants to see all commands. } else { sender.sendMessage(MainManager.getUtils().getMessage("Help page", Level.SEVERE)); sender.sendMessage(MainManager.getUtils().getMessage("---------------------------------")); // Getting commands from plugin.yml // TODO unsafe cast warning remove HashMap<String, Object> commands = (HashMap<String, Object>) this.plugin.getDescription() .getCommands().values(); for (String commandsEntry : commands.keySet()) { // TODO unsafe cast warning remove HashMap<String, Object> commandInfo = (HashMap<String, Object>) commands.get(commandsEntry); sender.sendMessage(MainManager.getUtils().getMessage( "/" + commandsEntry + " -> " + ChatColor.GOLD + commandInfo.get("description"), Level.WARNING)); } } } // This is some kind of weird command - do we actualy need it? if (args[0].equalsIgnoreCase("fixme")) { if (!(sender instanceof Player)) { return false; } Player player = (Player) sender; SpoutItemStack itemStack = new SpoutItemStack(player.getItemInHand()); player.sendMessage(MainManager.getUtils() .getMessage("The item in your hand is custom: " + itemStack.isCustomItem())); player.sendMessage( MainManager.getUtils().getMessage("It's called " + itemStack.getMaterial().getName() + "!")); } return true; }
From source file:com.github.stagirs.web.MainContriller.java
@RequestMapping("/searchTags") public String searchTags(Model model, @RequestParam(value = "query", required = false, defaultValue = "") String query) { Query q = new Query(query); model.addAttribute("type", "searchTags"); model.addAttribute("query", query); model.addAttribute("keywords", "(" + StringUtils.join(executor.getKeywords(q), "|") + ")"); model.addAttribute("items", query.isEmpty() ? null : executor.sentences(q)); return "search"; }
From source file:de.tudarmstadt.ukp.dkpro.core.tokit.AnnotationByLengthFilterTest.java
@Test public void testMin() throws Exception { AnalysisEngine filter = createEngine(AnnotationByLengthFilter.class, AnnotationByLengthFilter.PARAM_FILTER_ANNOTATION_TYPES, new String[] { Token.class.getName() }, AnnotationByLengthFilter.PARAM_MIN_LENGTH, 5); JCas jcas = filter.newJCas();//from ww w. j ava 2 s. c om TokenBuilder<Token, Annotation> tb = new TokenBuilder<Token, Annotation>(Token.class, Annotation.class); tb.buildTokens(jcas, content); filter.process(jcas); assertEquals("55555 666666 7777777 88888888 999999999", StringUtils.join(toText(select(jcas, Token.class)), " ")); }