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:com.cloudera.whirr.cm.cmd.BaseCommand.java
public String getLabel() { return WordUtils.capitalize(getName().replace("-", " ").replace("_", " ")).replace(" ", ""); }
From source file:Controlador.ControladorAmbiente.java
/** * Verifica si un ambiente ya existe, verifica si el nombre del ambiente por * el que se pregunta ya esta almacenado o no. * * @param o El ambiente a consultar./*w w w . j ava 2 s . c o m*/ * @return True si existe. */ public boolean existe(Ambiente o) { o.setNombre(WordUtils.capitalize(o.getNombre())); List<Ambiente> lista = ambienteDAO.buscar(o.getNombre()); for (Ambiente m : lista) { if (m.getNombre().equals(o.getNombre())) { return m.getIdAmbiente() != o.getIdAmbiente(); } } return false; }
From source file:ac.elements.parser.ExtendedFunctions.java
/** * Capitalize.// www. ja v a 2 s. co m * * @param input * the input * * @return the string */ public static String capitalize(String input) { if (input == null) return input; input = input.toLowerCase(); return WordUtils.capitalize(input); }
From source file:ac.elements.parser.ExtendedFunctions.java
/** * The main method.//www. j a v a 2 s . c o m * * @param args * the arguments */ public static void main(String[] args) { java.math.BigInteger myInt = new java.math.BigInteger("1223"); System.out.println(myInt); System.out.println(ExtendedFunctions.timePeriod(myInt)); myInt = new java.math.BigInteger("59000"); System.out.println(myInt); System.out.println(ExtendedFunctions.timePeriod(myInt)); myInt = new java.math.BigInteger("59900"); System.out.println(myInt); System.out.println(ExtendedFunctions.timePeriod(myInt)); myInt = new java.math.BigInteger("5990000"); System.out.println(myInt); System.out.println(ExtendedFunctions.timePeriod(myInt)); myInt = new java.math.BigInteger("599000000"); System.out.println(myInt); System.out.println(ExtendedFunctions.timePeriod(myInt)); myInt = new java.math.BigInteger("59900000000"); System.out.println(myInt); System.out.println(ExtendedFunctions.timePeriod(myInt)); String sql = "select * from domain where `this`='test' and this2=\"test\""; System.out.println(ExtendedFunctions.escapeSql(sql)); String unformattedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><QueryMessage\n" + " xmlns=\"http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message\"\n" + " xmlns:query=\"http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query\">\n" + " <Query>\n" + " <query:CategorySchemeWhere>\n" + " \t\t\t\t\t <query:AgencyID>ECB\n\n\n\n</query:AgencyID>\n" + " </query:CategorySchemeWhere>\n" + " </Query>\n\n\n\n\n" + "</QueryMessage>"; System.out.println(ExtendedFunctions.formatXml(unformattedXml)); String company = "international business MACHINES. iag is here."; System.out.println(ExtendedFunctions.capitalize(company)); String url = "\u1087\u1088\u1077\u1076\u1089"; System.out.println(url); System.out.println(ExtendedFunctions.escUniJs(url)); System.out.println(ExtendedFunctions.toUnicodeHTML(url)); ExtendedFunctions.trim(url); url = "http://news.google.com/news?hl=en&client=safari&rls=en-us&q=get%20part%20of%20paragraph%20words%20google%20algorithm&um=1&ie=UTF-8&sa=N&tab=wn"; System.out.println(ExtendedFunctions.chopUrl(url, 30)); url = "http://www.pcplus.co.uk/node/3061/"; System.out.println(ExtendedFunctions.chopUrl(url, 30)); url = "http://www.opent.net/forum/security-problem-with-ot-script-on-ssl-t159.html"; System.out.println(ExtendedFunctions.chopUrl(url, 30)); System.out.println(ExtendedFunctions.escapeJavaScript("escapeJavas'\"cript")); System.err.println(StringUtils.abbreviate("Take time off working", 0, 10)); System.err.println(StringUtils.capitalize("how is vandersar doing?")); String unescapedJava = "Are you \" for real?"; System.err.println(StringEscapeUtils.escapeJava(unescapedJava)); String unescapedJavaScript = "What's in a name?"; System.err.println(ExtendedFunctions.escapeJavaScript(unescapedJavaScript)); String unescapedSql = "Mc'Williams"; System.err.println(StringEscapeUtils.escapeSql(unescapedSql)); String unescapedXML = "<data>"; System.err.println(StringEscapeUtils.escapeXml(unescapedXML)); String unescapedHTML = "the data is <data>"; System.err.println(StringEscapeUtils.escapeHtml(unescapedHTML)); System.err.println(WordUtils.capitalize(unescapedHTML)); System.err.println(WordUtils.swapCase(unescapedHTML)); }
From source file:edu.mayo.cts2.framework.webapp.rest.view.jsp.Beans.java
public static String capitalize(String string) { return WordUtils.capitalize(string); }
From source file:com.liferay.mobile.sdk.json.Action.java
public String getServiceClassName() { if (serviceClassName == null) { StringBuilder sb = new StringBuilder(); String className = ClassNames.className(filter); if (className == null) { className = WordUtils.capitalize(filter); }//from w ww. ja va2 s. co m sb.append(className); sb.append(SERVICE_CLASS_NAME_SUFFIX); serviceClassName = sb.toString(); } return serviceClassName; }
From source file:com.googlecode.jmxtrans.model.ResultAttributeTests.java
@Test public void attributeNamesFromResultAreWrittenToMap() throws Exception { for (ResultAttribute resultAttribute : ResultAttribute.values()) { resultAttribute.addAttribute(attributeMap, result); String attributeName = enumValueToAttribute(resultAttribute); Method m = result.getClass().getMethod("get" + WordUtils.capitalize(attributeName)); String expectedValue = (String) m.invoke(result); assertThat(attributeMap).containsEntry(attributeName, expectedValue); }/*from ww w . jav a 2s. c o m*/ }
From source file:ExternalTools.java
public static String queryBabel(String input, BabelNet babel) { String parse = ""; List<BabelSynset> syn = babel.getSynsets(input, Language.EN); // Collects all BabelGlosses in the given source for this BabelSynset. if (syn.size() > 0) { List<BabelGloss> glosses = syn.get(0).getGlosses(); String[] tmp;//from w w w.j a v a 2 s . c om if (glosses.size() > 1) { parse = glosses.get(1).toString(); // usually shorter and better if (glosses.get(0).toString().length() < parse.length()) parse = glosses.get(0).toString(); } else if (glosses.size() == 1) { parse = glosses.get(0).toString(); } else { return ""; } try { tmp = parse.split(" is a | is an | is the "); if (tmp.length > 1) { tmp = tmp[1].toLowerCase().split("who|currently|based|with|\\(|,"); parse = tmp[0]; } } catch (Exception e) { } try { tmp = parse.split(" name of the "); if (tmp.length > 1) { parse = tmp[1]; } } catch (Exception e) { } try { if (parse.charAt(parse.length() - 1) == '.' | parse.charAt(parse.length() - 1) == ')' | parse.charAt(parse.length() - 1) == ',') parse = parse.substring(0, parse.length() - 1); } catch (Exception e) { } try { if (parse.contains("competition") | parse.contains("rock") | parse.contains("tournament") | parse.contains("event") | parse.contains("film") | parse.contains("sculpture") | parse.contains("people") | parse.contains("language") | parse.contains("descent") | parse.contains("station")) return ""; } catch (Exception e) { } try { // still too long? if (parse.length() > 10) return ""; } catch (Exception e) { } return WordUtils.capitalize(parse); } return ""; }
From source file:metabup.metamodel.edit.actions.AddRootClassAction.java
@Override public MetaModel editMetaModel(MetaModel mm) { MetaClass root = null;// ww w .j a va 2 s. c o m for (MetaClass mc : mm.getClasses()) { if (mc.isAnnotated(Root.NAME)) { root = mc; break; } } if (root == null) { // add it if there is no one root = MetamodelFactory.eINSTANCE.createMetaClass(); root.annotate(Root.NAME); root.setName(WordUtils.capitalize(Root.NAME)); } for (MetaClass tar : mm.getClasses()) { if (tar != root) { if (root.references(tar, 1, -1, 0, ReferenceImpl.CONTAINMENT, true, true, null)) continue; if (tar.isTop() && tar.getIncomingRefs(true, true, ReferenceImpl.CONTAINMENT).isEmpty()) { //System.out.println(tar.getName() + " <- root" ); Reference r = MetamodelFactory.eINSTANCE.createReference(); r.setMin(0); r.setMax(-1); r.setName(tar.getName().toLowerCase()); r.annotate(Composition.NAME); r.setReference(tar); root.getFeatures().add(r); } } } // TODO - las clases ya contenidas, no necesitan volver a serlo //System.out.println(root.getReferences().size()); mm.getClasses().add(root); return mm; }
From source file:Controlador.ControladorAmbiente.java
/** * Busca un ambiente por su nombre./*from www.j a va 2s . c o m*/ * * @param nombre El nombre del ambiente. * @return El ambiente encontrado. */ public Ambiente getOne(String nombre) { nombre = WordUtils.capitalize(nombre); return ambienteDAO.buscar(nombre).get(0); }