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:org.apache.slider.server.appmaster.web.view.ContainerStatsBlock.java
@Override protected void render(Block html) { // TODO Probably better to just get a copy of this list for us to avoid the repeated synchronization? // does this change if we have 50 node, 100node, 500 node clusters? final Map<String, RoleInstance> containerInstances = getContainerInstances( slider.getAppState().cloneOwnedContainerList()); for (Entry<String, RoleStatus> entry : slider.getRoleStatusByName().entrySet()) { final String name = entry.getKey(); final RoleStatus roleStatus = entry.getValue(); DIV<Hamlet> div = html.div("role-info ui-widget-content ui-corner-all"); List<ClusterNode> nodesInRole; try {/*from w w w . j a v a 2 s.c o m*/ nodesInRole = clusterOps.listClusterNodesInRole(name); } catch (Exception e) { log.error("Could not fetch containers for role: " + name, e); nodesInRole = Collections.emptyList(); } div.h2(BOLD, StringUtils.capitalize(name)); // Generate the details on this role Iterable<Entry<String, Integer>> stats = roleStatus.buildStatistics().entrySet(); generateRoleDetails(div, "role-stats-wrap", "Specifications", Iterables.transform(stats, stringIntPairFunc)); // Sort the ClusterNodes by their name (containerid) Collections.sort(nodesInRole, new ClusterNodeNameComparator()); // Generate the containers running this role generateRoleDetails(div, "role-stats-containers", "Containers", Iterables.transform(nodesInRole, new Function<ClusterNode, Entry<TableContent, String>>() { @Override public Entry<TableContent, String> apply(ClusterNode input) { final String containerId = input.name; if (containerInstances.containsKey(containerId)) { RoleInstance roleInst = containerInstances.get(containerId); if (roleInst.container.getNodeHttpAddress() != null) { return Maps.<TableContent, String>immutableEntry( new TableAnchorContent(containerId, buildNodeUrlForContainer( roleInst.container.getNodeHttpAddress(), containerId)), null); } } return Maps.immutableEntry(new TableContent(input.name), null); } })); ClusterDescription desc = slider.getAppState().getClusterStatus(); Map<String, String> options = desc.getRole(name); Iterable<Entry<TableContent, String>> tableContent; // Generate the pairs of data in the expected form if (null != options) { tableContent = Iterables.transform(options.entrySet(), stringStringPairFunc); } else { // Or catch that we have no options and provide "empty" tableContent = Collections.<Entry<TableContent, String>>emptySet(); } // Generate the options used by this role generateRoleDetails(div, "role-options-wrap", "Role Options", tableContent); // Close the div for this role div._(); } }
From source file:org.apache.sling.scripting.sightly.impl.compiler.CompileTimeObjectModel.java
private static Method findMethod(Class<?> cls, String baseName) { Method[] publicMethods = cls.getMethods(); String capitalized = StringUtils.capitalize(baseName); for (Method m : publicMethods) { if (m.getParameterTypes().length == 0) { String methodName = m.getName(); if (baseName.equals(methodName) || ("get" + capitalized).equals(methodName) || ("is" + capitalized).equals(methodName)) { // this method is good, check whether allowed if (isMethodAllowed(m)) { return m; }/*from www . jav a2 s .co m*/ // method would match but is not allowed, abort break; } } } return null; }
From source file:org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.java
private Method findMethod(Class<?> cls, String baseName) throws NoSuchMethodException { Method[] publicMethods = cls.getMethods(); String capitalized = StringUtils.capitalize(baseName); for (Method m : publicMethods) { if (m.getParameterTypes().length == 0) { String methodName = m.getName(); if (baseName.equals(methodName) || ("get" + capitalized).equals(methodName) || ("is" + capitalized).equals(methodName)) { // this method is good, check whether allowed if (isMethodAllowed(m)) { return m; }//from w ww . j a va 2s . c om // method would match but is not allwed, abort break; } } } throw new NoSuchMethodException(baseName); }
From source file:org.apache.sling.scripting.sightly.render.AbstractRuntimeObjectModel.java
protected static Method findMethod(Class<?> cls, String baseName) { Method[] publicMethods = cls.getMethods(); String capitalized = StringUtils.capitalize(baseName); for (Method m : publicMethods) { if (m.getParameterTypes().length == 0) { String methodName = m.getName(); if (baseName.equals(methodName) || ("get" + capitalized).equals(methodName) || ("is" + capitalized).equals(methodName)) { // this method is good, check whether allowed if (isMethodAllowed(m)) { return m; }//from w w w . ja v a 2 s . co m // method would match but is not allowed, abort break; } } } return null; }
From source file:org.apache.stanbol.workflow.jersey.resource.ContentItemResource.java
public static String extractLabel(UriRef uri) { String fullUri = uri.getUnicodeString(); int index = Math.max(fullUri.lastIndexOf('#'), fullUri.lastIndexOf('/')); index = Math.max(index, fullUri.lastIndexOf(':')); //do not convert if the parsed uri does not contain a local name if (index > 0 && index + 1 < fullUri.length()) { return StringUtils.capitalize(fullUri.substring(index + 1).replaceAll("[\\-_]", " ")); } else {/*w w w . ja v a 2 s . co m*/ return uri.getUnicodeString(); } }
From source file:org.apache.streams.sprinklr.util.SprinklrDataToActivityConverter.java
/** * Build the provider for the Activity/*from w w w. j a va 2 s . c om*/ * @param item JsonNode * @return Provider */ private Provider getProvider(JsonNode item) { Provider provider = new Provider(); String mediaType = item.get("snType").asText().toLowerCase(); provider.setId(getProviderId(mediaType)); provider.setDisplayName(StringUtils.capitalize(mediaType)); return provider; }
From source file:org.apache.streams.sysomos.conversion.SysomosBeatActivityConverter.java
protected void setProvider(BeatApi.BeatResponse.Beat beat, Activity converted) { Provider provider = new Provider(); String mediaType = beat.getMediaType().toLowerCase(); provider.setId(getProviderId(mediaType)); provider.setDisplayName(StringUtils.capitalize(mediaType)); converted.setProvider(provider);/*from ww w .ja va 2 s. c om*/ }
From source file:org.apache.sysml.runtime.instructions.cp.BooleanObject.java
public String getLanguageSpecificBooleanStringValue() { if (DMLScript.SCRIPT_TYPE == ScriptType.DML) { return Boolean.toString(_value).toUpperCase(); } else {/*from w w w . j av a2 s.c om*/ return StringUtils.capitalize(Boolean.toString(_value)); } }
From source file:org.apache.torque.engine.database.model.Column.java
/** * Get name to use in Java sources to build method names. * * @return the capitalised javaName//from ww w . java 2 s. com */ public String getJavaName() { if (javaName == null) { List inputs = new ArrayList(2); inputs.add(name); inputs.add(javaNamingMethod); try { javaName = NameFactory.generateName(NameFactory.JAVA_GENERATOR, inputs); } catch (EngineException e) { log.error(e, e); } } return StringUtils.capitalize(javaName); }
From source file:org.apache.torque.engine.database.model.JavaNameGenerator.java
/** * Converts a database schema name to java object name. Removes * <code>STD_SEPARATOR_CHAR</code> and <code>SCHEMA_SEPARATOR_CHAR</code>, * capitilizes first letter of name and each letter after the * <code>STD_SEPERATOR</code> and <code>SCHEMA_SEPARATOR_CHAR</code>, * converts the rest of the letters to lowercase. * * @param schemaName name to be converted. * @return converted name.//from w w w. ja v a2 s. c o m * @see org.apache.torque.engine.database.model.NameGenerator * @see #underscoreMethod(String) */ protected String underscoreMethod(String schemaName) { StringBuffer name = new StringBuffer(); // remove the STD_SEPARATOR_CHARs and capitalize // the tokens StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = ((String) tok.nextElement()).toLowerCase(); name.append(StringUtils.capitalize(namePart)); } // remove the SCHEMA_SEPARATOR_CHARs and capitalize // the tokens schemaName = name.toString(); name = new StringBuffer(); tok = new StringTokenizer(schemaName, String.valueOf(SCHEMA_SEPARATOR_CHAR)); while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); name.append(StringUtils.capitalize(namePart)); } return name.toString(); }