List of usage examples for org.apache.commons.lang WordUtils capitalize
public static String capitalize(String str)
Capitalizes all the whitespace separated words in a String.
From source file:se.vgregion.core.domain.calendar.CalendarItem.java
/** * Capitalized and localized string of the day of week. * * @param locale to use on the returned string * @return Capitalized and localized string of the day of week *//*from w ww.j a va 2 s.com*/ public String getDayOfWeek(Locale locale) { String dayOfWeek = interval.getStart().dayOfWeek().getAsText(locale); return WordUtils.capitalize(dayOfWeek); }
From source file:se.vgregion.core.domain.calendar.CalendarItem.java
/** * Capitalized string of the end day of week with sv_SE locale. * * @return Capitalized string of the day of week *///from w ww. ja va 2 s . c o m public String getEndDayOfWeek() { String dayOfWeek = interval.getEnd().dayOfWeek().getAsText(DEFAULT_LOCALE); return WordUtils.capitalize(dayOfWeek); }
From source file:se.vgregion.core.domain.calendar.CalendarItem.java
/** * Capitalized and localized string of the day of month with sv_SE locale. * * @return Capitalized and localized string of the day of month *///from w w w . j a va2 s. c om public String getEndDayOfMonth() { String dayOfMonth = interval.getEnd().dayOfMonth().getAsText(DEFAULT_LOCALE); return WordUtils.capitalize(dayOfMonth); }
From source file:se.vgregion.core.domain.calendar.CalendarItem.java
/** * Capitalized and localized string of the month of year. * * @param locale to use on the returned string * @return Capitalized and localized string of the month of year *//* ww w . j av a2 s . c o m*/ public String getMonthOfYear(Locale locale) { String monthOfYear = interval.getStart().monthOfYear().getAsText(locale); return WordUtils.capitalize(monthOfYear); }
From source file:se.vgregion.core.domain.calendar.CalendarItem.java
/** * Capitalized string of the end month of year with sv_SE locale. * * @return Capitalized and localized string of the month of year *///from w w w .j a va 2 s . com public String getEndMonthOfYear() { String monthOfYear = interval.getEnd().monthOfYear().getAsText(DEFAULT_LOCALE); return WordUtils.capitalize(monthOfYear); }
From source file:se.vgregion.core.domain.calendar.CalendarItem.java
/** * Get the type of the calendar item./*from w w w .j ava 2 s .co m*/ * * @return the type of the calendar item */ public String getCalendarType() { if (calendarType != null) { return WordUtils.capitalize(calendarType.toLowerCase(Locale.getDefault())); } return null; }
From source file:simpleserver.command.EnchantCommand.java
public void execute(Player player, String message) { String[] parts = message.trim().split(" "); Slot item;// w ww.j a v a 2 s .c o m if (parts.length == 1) { if ((item = getSessionItem(player, false)) == null) { player.addTMessage(Color.GRAY, "You have to select an item to enchant first."); player.addTMessage(Color.GRAY, "Use: %s%s ITEM", commandPrefix(), name); } else { chatItem(player, item); } } else if (parts[1].equals("add")) { if ((item = getSessionItem(player)) == null) { return; } boolean changed = false; for (int i = 2; i < parts.length; i++) { String[] ench = parts[i].split(":"); try { Integer id = Integer.valueOf(ench[0]); int level = 10; if (ench.length >= 2) { level = Integer.valueOf(ench[1]); if (level < 1 || level > 10) { player.addTMessage(Color.RED, "The enchantment level must be between 1 and 10"); continue; } } if (!availableEnchantments(item).contains(id)) { if (ENCHANTMENTS.containsKey(Integer.valueOf(id))) { player.addTMessage(Color.RED, "%s is not available for the current item", ENCHANTMENTS.get(id)); } else { player.addTMessage(Color.RED, "No enchantment with id %s exists.", id); } } else { item.addEnchantment(new Enchantment(id, level)); changed = true; } } catch (NumberFormatException e) { player.addTMessage(Color.RED, "%s is not a valid enchantment", parts[i]); } } if (changed) { chatItem(player, item); } } else if (parts[1].equals("remove")) { if ((item = getSessionItem(player)) == null) { return; } boolean changed = false; for (int i = 2; i < parts.length; i++) { try { Integer id = Integer.valueOf(parts[i]); if (!item.enchantedWith(id)) { player.addTMessage(Color.RED, "The item was not enchanted with %s", (ENCHANTMENTS.containsKey(id) ? ENCHANTMENTS.get(id) : id)); } else { item.removeEnchantment(id); changed = true; } } catch (NumberFormatException e) { player.addTMessage(Color.RED, "%s is not a valid enchantment", parts[i]); } } if (changed) { chatItem(player, item); } } else if (parts[1].equals("spawn") || parts[1].equals("give")) { if ((item = getSessionItem(player)) == null) { return; } Giver bot = new Giver(player); bot.add(item); try { player.getServer().bots.connect(bot); } catch (ConnectException e) { player.addTMessage(Color.RED, "An unknown error occured"); } } else { int id = 0; if (parts.length == 2) { try { id = Integer.valueOf(parts[1]); } catch (NumberFormatException e) { GiveAliasList alias = player.getServer().giveAliasList; Item itemAlias = alias.getItemId(parts[1]); if (itemAlias == null) { Suggestion correctName = alias.findWithLevenshtein(parts[1]); if (correctName.distance < 4) { id = alias.getItemId(correctName.name).id; } } else { id = itemAlias.id; } } } else { String name = WordUtils.capitalize(extractArgument(message)); if (ITEMS.containsValue(name)) { for (Integer itemID : ITEMS.keySet()) { if (ITEMS.get(itemID).equals(name)) { id = itemID; break; } } } } if (id == 0) { player.addTMessage(Color.RED, "Can't find item"); } else if (!ITEMS.containsKey(id)) { player.addTMessage(Color.RED, "This item is not enchantable"); } else { item = new Slot(id); chatItem(player, item); player.addTMessage(Color.GRAY, "You can now add enchantments with %s%s%s", commandPrefix(), name, " add ID:LEVEL"); sessions.put(player, item); } } }
From source file:StorageHelper.PathParser.java
/** * find all the paths in the json Object that will match the key * @param searchKey key searching for/*w w w . j av a 2 s. c o m*/ * @param searching object searching in * @return list of arrays, array being the path list of all the paths */ private ArrayList<String[]> findPaths(String searchKey, JSONObject searching) { Iterator<String> keys = searching.keys(); ArrayList<String[]> allPaths = new ArrayList<>(); //adding found key to array if (searching.has(WordUtils.capitalize(searchKey)) || searching.has(WordUtils.uncapitalize(searchKey))) { allPaths.add(new String[] { searchKey }); } while (keys.hasNext()) { ArrayList<String[]> foundPaths; String next = keys.next(); //get the next one, either as json object or json array Object nextJson = null; try { nextJson = searching.get(next); } catch (JSONException e) { e.printStackTrace(); } foundPaths = findPathsRecurser(searchKey, nextJson); //add the path to the main collection of paths for (String[] paths : foundPaths) { ArrayList<String> pathFinder = new ArrayList<>(); pathFinder.add(next); pathFinder.addAll(Arrays.asList(paths)); allPaths.add(pathFinder.toArray(new String[pathFinder.size()])); } } return allPaths; }
From source file:ubic.gemma.loader.expression.geo.GeoFamilyParser.java
/** * @param target// w w w .ja v a 2 s .c o m * @param property * @param value */ private void addTo(Object target, String property, Object value) { try { if (value == null) { log.warn("Value is null for target=" + target + " property=" + property); return; } if (target == null) { log.warn("Target is null for value=" + value + " property=" + property); return; } if (property == null) { log.warn("Property is null for value=" + value + " target=" + target); } Method adder = target.getClass().getMethod("addTo" + WordUtils.capitalize(property), new Class[] { value.getClass() }); adder.invoke(target, new Object[] { value }); } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } }
From source file:uk.ac.ebi.embl.flatfile.writer.genomeassembly.ChromosomeFileWriter.java
@Override public boolean write(Writer writer) { if (gaRecord == null) return false; @SuppressWarnings("unchecked") ArrayList<ChromosomeDataRow> rows = (ArrayList<ChromosomeDataRow>) gaRecord.getFields(); for (ChromosomeDataRow row : rows) { writeRow(row.get_object_name(), row.get_chromosome_name(), WordUtils.capitalize(row.get_type().toLowerCase()), (row.get_location() != null) ? WordUtils.capitalize(row.get_location().toLowerCase()) : null, writer);//from w ww . java 2s .co m } return true; }