List of usage examples for org.apache.commons.lang StringUtils capitalize
public static String capitalize(String str)
Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .
From source file:com.haulmont.timesheets.gui.project.ProjectBrowse.java
private void initProjectsTable() { projectsTable.addAction(new CreateAction(projectsTable) { @Override//from ww w.ja va 2 s . c o m public WindowManager.OpenType getOpenType() { return WindowManager.OpenType.DIALOG; } }); projectsTable.addAction(new EditAction(tasksTable) { @Override public WindowManager.OpenType getOpenType() { return WindowManager.OpenType.DIALOG; } @Override protected void afterCommit(Entity entity) { projectsTable.refresh(); } }); LoadContext<ProjectRole> loadContext = new LoadContext<>(ProjectRole.class); loadContext.setQueryString("select pr from ts$ProjectRole pr order by pr.name"); List<ProjectRole> projectRoles = getDsContext().getDataSupplier().loadList(loadContext); projectRoles = new ArrayList<>(projectRoles); sortProjectRoles(projectRoles); for (final ProjectRole projectRole : projectRoles) { assignBtn.addAction(new AbstractAction("assign" + projectRole.getCode()) { @Override public String getCaption() { return (getMessage("caption.assign" + StringUtils.capitalize(projectRole.getCode().getId().toLowerCase()))); } @SuppressWarnings("unchecked") @Override public void actionPerform(Component component) { if (CollectionUtils.isNotEmpty(projectsTable.getSelected())) { openLookup("sec$User.lookup", items -> { if (CollectionUtils.isNotEmpty(items)) { Collection<Project> selectedProjects = projectsTable.getSelected(); Collection<User> selectedUsers = (Collection) items; boolean needToRefresh = projectsService.assignUsersToProjects(selectedUsers, selectedProjects, projectRole); if (needToRefresh) { participantsTable.refresh(); } } }, WindowManager.OpenType.DIALOG); } else { showNotification(getMessage("notification.pleaseSelectProject"), NotificationType.HUMANIZED); } } }); } projectsTable.setStyleProvider(new Table.StyleProvider<Project>() { @Nullable @Override public String getStyleName(Project entity, @Nullable String property) { if ("status".equals(property)) { return ComponentsHelper.getProjectStatusStyle(entity); } return null; } }); }
From source file:info.magnolia.importexport.PropertiesImportExport.java
protected Object convertNodeDataStringToObject(String valueStr) { if (contains(valueStr, ':')) { final String type = StringUtils.substringBefore(valueStr, ":"); final String value = StringUtils.substringAfter(valueStr, ":"); // there is no beanUtils converter for Calendar if (type.equalsIgnoreCase("date")) { return ISO8601.parse(value); } else if (type.equalsIgnoreCase("binary")) { return new ByteArrayInputStream(value.getBytes()); } else {/* w w w. j a v a2s . c o m*/ try { final Class<?> typeCl; if (type.equals("int")) { typeCl = Integer.class; } else { typeCl = Class.forName("java.lang." + StringUtils.capitalize(type)); } return ConvertUtils.convert(value, typeCl); } catch (ClassNotFoundException e) { // possibly a stray :, let's ignore it for now return valueStr; } } } // no type specified, we assume it's a string, no conversion return valueStr; }
From source file:fr.ritaly.dungeonmaster.Skill.java
/** * Returns this {@link Skill}'s label. Example: Returns "Ninja" for the * {@link #NINJA} skill.//from w w w .j a v a 2 s . c om * * @return a {@link String}. */ public String getLabel() { return StringUtils.capitalize(name().toLowerCase()); }
From source file:mrcg.domain.JavaField.java
public String getNameAsLabel() { String label = StringUtils.capitalize(getName()); label = Utils.toSpacedCamelCase(label); return label; }
From source file:com.adguard.compiler.Main.java
/** * Builds extension// w ww . jav a2 s . com * * @param source Source path * @param dest Destination folder * @param filtersScriptRules List of javascript injection rules. * For AMO and addons.opera.com we embed all * js rules into the extension and do not update them * from remote server. * @param extensionId Extension identifier (Use for safari) * @param updateUrl Add to manifest update url. * Otherwise - do not add it. * All extension stores have their own update channels so * we shouldn't add update channel to the manifest. * @param browser Browser type * @param version Build version * @param branch Build branch * @return Path to build result * @throws Exception */ private static File createBuild(File source, File dest, boolean useLocalScriptRules, Map<Integer, List<String>> filtersScriptRules, String extensionId, String updateUrl, Browser browser, String version, String branch) throws Exception { if (dest.exists()) { log.debug("Removed previous build: " + dest.getName()); FileUtils.deleteQuietly(dest); } FileUtil.copyFiles(source, dest, browser); SettingUtils.writeLocalScriptRulesToFile(dest, useLocalScriptRules, filtersScriptRules); String extensionNamePostfix = ""; if (StringUtils.isNotEmpty(branch)) { extensionNamePostfix = " (" + StringUtils.capitalize(branch) + ")"; } SettingUtils.updateManifestFile(dest, browser, version, extensionId, updateUrl, extensionNamePostfix); if (browser == Browser.CHROMIUM) { LocaleUtils.updateExtensionNameForChromeLocales(dest, extensionNamePostfix); } if (browser == Browser.FIREFOX || browser == Browser.FIREFOX_LEGACY) { LocaleUtils.writeLocalesToFirefoxInstallRdf(dest, extensionNamePostfix); } return dest; }
From source file:edu.psu.citeseerx.myciteseer.domain.logic.AccountValidator.java
public String getInputFieldValidationMessage(String formInputId, String formInputValue) { String validationMessage = ""; try {/*ww w . ja v a2 s .co m*/ Object formBackingObject = new Account(); Errors errors = new BindException(formBackingObject, "command"); formInputId = formInputId.split("\\.")[1]; String capitalizedFormInputId = StringUtils.capitalize(formInputId); String accountMethodName = "set" + capitalizedFormInputId; Class setterArgs[] = new Class[] { String.class }; Method accountMethod = formBackingObject.getClass().getMethod(accountMethodName, setterArgs); accountMethod.invoke(formBackingObject, new Object[] { formInputValue }); String validationMethodName = "validate" + capitalizedFormInputId; Class validationArgs[] = new Class[] { String.class, Errors.class }; Method validationMethod = getClass().getMethod(validationMethodName, validationArgs); validationMethod.invoke(this, new Object[] { formInputValue, errors }); validationMessage = getValidationMessage(errors, formInputId); } catch (Exception e) { e.printStackTrace(); } return validationMessage; }
From source file:de.themoep.clancontrol.ClanControl.java
@Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (args.length > 0) { if (args[0].equalsIgnoreCase("map")) { if (sender.hasPermission("clancontrol.command.map")) { Location location = null; if (sender instanceof Player) { Player p = (Player) sender; List<BaseComponent[]> msg = getRegionManager().getRegionMap(p); if (msg.size() > 0) { for (BaseComponent[] row : msg) { p.spigot().sendMessage(row); }/*from w w w . j a va 2 s.com*/ } else { sender.sendMessage("The world " + p.getWorld().getName() + " cannot be controlled!"); } } else { sender.sendMessage("This command can only be run by a player!"); } return true; } else { sender.sendMessage("You don't have the permission clancontrol.command.map"); } } else if (args[0].equalsIgnoreCase("region")) { if (sender.hasPermission("clancontrol.command.region")) { if (sender instanceof Player) { Player p = (Player) sender; Region region = null; if (args.length == 1) { region = getRegionManager().getRegion(p.getLocation()); } else if (args.length == 3) { try { int x = Integer.parseInt(args[1]); try { int z = Integer.parseInt(args[2]); region = getRegionManager().getRegion(p.getLocation().getWorld().getName(), x, z); } catch (NumberFormatException e) { sender.sendMessage( ChatColor.GOLD + args[2] + ChatColor.RED + " is not a valid number!"); return true; } } catch (NumberFormatException e) { sender.sendMessage( ChatColor.GOLD + args[1] + ChatColor.RED + " is not a valid number!"); return true; } } else { sender.sendMessage(ChatColor.RED + "Usage: /" + label + " region [<x> <z>]"); return true; } if (region != null) { List<BaseComponent[]> msg = getRegionManager().getChunkMap(p, region); if (msg.size() > 0) { String head = "Region " + region.getX() + "/" + region.getZ(); head += " - Status: " + StringUtils.capitalize(region.getStatus().toString().toLowerCase()); if (!region.getController().isEmpty()) { head += " - Controller: " + getClanDisplay(region.getController()); } p.spigot().sendMessage(new ComponentBuilder(head).create()); for (BaseComponent[] row : msg) { p.spigot().sendMessage(row); } } else { sender.sendMessage( "The world " + p.getWorld().getName() + " cannot be controlled!"); } } else { sender.sendMessage(ChatColor.RED + "This region does not exist!"); } } else { sender.sendMessage("This command can only be run by a player!"); } } else { sender.sendMessage("You don't have the permission clancontrol.command.region"); } return true; } else if (args[0].equalsIgnoreCase("reload")) { if (sender.hasPermission("clancontrol.command.reload")) { sender.sendMessage("Config reloaded."); } else { sender.sendMessage("You don't have the permission clancontrol.command.reload"); } return true; } else if (args[0].equalsIgnoreCase("register")) { if (sender instanceof Player) { if (sender.hasPermission("clancontrol.command.register")) { if (args.length > 1) { Block b = ((Player) sender).getTargetBlock((Set<Material>) null, 7); if (b.getType() == Material.BEACON) { if (getRegionManager().registerBeacon(args[1], b.getLocation())) { sender.sendMessage("Registered Beacon for " + getClanDisplay(args[1]) + "!"); } else { sender.sendMessage( "Could not register Beacon for " + getClanDisplay(args[1]) + "!"); } } else { sender.sendMessage("You have to look at a Beacon block to register it!"); } } else { sender.sendMessage("Usage: /" + label + " register <clantag>"); } } else { sender.sendMessage("You don't have the permission clancontrol.command.register"); } } else { sender.sendMessage("This command can only be run by a player as you need to look at a beacon!"); } return true; } } return false; }
From source file:com.evolveum.midpoint.repo.sql.util.MidPointImplicitNamingStrategy.java
@Override public Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source) { Identifier i = super.determineJoinColumnName(source); // RObject, creatorRef.target, oid -> m_object.creatorRef_targetOid // RObjectReference, owner, oid -> m_object_reference.owner_oid // RObjectReference, target, oid -> m_object_reference.targetOid AttributePath path = source.getAttributePath(); String property = path.getProperty(); String columnName = source.getReferencedColumnName().getText(); Identifier real;/*from w w w . j a va 2s.c o m*/ if (path.getDepth() == 1) { String name; if (property.endsWith("target") && "oid".equals(columnName)) { name = property + "Oid"; } else { name = StringUtils.join(Arrays.asList(property, columnName), "_"); } real = toIdentifier(name, source.getBuildingContext()); } else { // TODO fixme BRUTAL HACK -- we are not able to eliminate columns like 'ownerRefCampaign_targetOid' from the schema (even with @AttributeOverride/@AssociationOverride) if ("ownerRefCampaign.target".equals(path.getFullPath()) || "ownerRefDefinition.target".equals(path.getFullPath()) || "ownerRefTask.target".equals(path.getFullPath())) { path = AttributePath.parse("ownerRef.target"); } AttributePath parent = path.getParent(); String translatedParent = transformAttributePath(parent); columnName = property + StringUtils.capitalize(columnName); real = toIdentifier(StringUtils.join(Arrays.asList(translatedParent, columnName), "_"), source.getBuildingContext()); } LOGGER.trace("determineJoinColumnName {} {} -> {}, {}", source.getReferencedTableName(), source.getReferencedColumnName(), i, real); return real; }
From source file:dk.dma.msinm.common.time.TimeTranslator.java
/** * Translate the time description/*from w ww . j a v a 2s .c o m*/ * @param time the time description to translate * @param translateRules the translation rules to apply * @return the result */ public String translate(String time, Map<String, String> translateRules) throws TimeException { BufferedReader reader = new BufferedReader(new StringReader(time)); String line; StringBuilder result = new StringBuilder(); try { while ((line = reader.readLine()) != null) { //line = line.trim().toLowerCase(); // Replace according to replace rules for (String key : translateRules.keySet()) { String value = translateRules.get(key); Matcher m = Pattern.compile(key, Pattern.CASE_INSENSITIVE).matcher(line); StringBuffer sb = new StringBuffer(); while (m.find()) { String text = m.group(); m.appendReplacement(sb, value); } m.appendTail(sb); line = sb.toString(); } // Capitalize, unless the line starts with something like "a) xxx" if (!line.matches("\\w\\) .*")) { line = StringUtils.capitalize(line); } result.append(line + "\n"); } } catch (Exception e) { throw new TimeException("Failed translating time description", e); } return result.toString().trim(); }
From source file:com.simplexwork.mysql.tools.utils.DocumentUtils.java
/** * ????JavaBean??// w w w . j ava 2 s . c o m * @param tableName ?? * @return */ private static String getJavaBeanName(String tableName) { if (table_prefix == null) return tableName; for (String str : table_prefix) { tableName = tableName.replaceAll(str, ""); } return fixName(StringUtils.capitalize(tableName)); }