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.agimatec.validation.jsr303.util.SecureActions.java
/** * Returns the <b>public method</b> with the specified name or null if it does not exist. * * @return Returns the method or null if not found. *//*from w w w . j av a2s .c om*/ public static Method getGetter(final Class<?> clazz, final String methodName) { return run(new PrivilegedAction<Method>() { public Method run() { try { String methodName0 = StringUtils.capitalize(methodName); try { return clazz.getMethod("get" + methodName0); } catch (NoSuchMethodException e) { return clazz.getMethod("is" + methodName0); } } catch (NoSuchMethodException e) { return null; } } }); }
From source file:com.github.jdot.file.builder.BeanBuilder.java
private String getGetterMethod(String propertyName, String type) { String capitalizedName = StringUtils.capitalize(propertyName); String getterName = null;//w ww . j a v a 2 s . c om if ("boolean".equals(type) || "java.lang.Boolean".equals(type)) { getterName = "is" + capitalizedName; } else { getterName = "get" + capitalizedName; } return getterName; }
From source file:com.vionto.vithesaurus.BaseformFinder.java
private String joinAllButLast(List<String> parts, String lastPartBaseForm) { final StringBuilder sb = new StringBuilder(); for (int i = 0; i < parts.size() - 1; i++) { final String part = parts.get(i); if (i == 0) { sb.append(StringUtils.capitalize(part)); } else {/* ww w . ja va 2 s .co m*/ sb.append(part); } } sb.append(lastPartBaseForm.toLowerCase()); return sb.toString(); }
From source file:com.abiquo.model.util.ModelTransformer.java
private static Method setter(final String fieldName, final Class clazz, final Class type) throws Exception { String name = "set" + StringUtils.capitalize(fieldName); Method method = clazz.getMethod(name, new Class[] { type }); if (method != null) { method.setAccessible(true);/* ww w .j ava 2 s . co m*/ } return method; }
From source file:com.manydesigns.elements.fields.search.RangeSearchField.java
public void toXhtml(@NotNull XhtmlBuffer xb) { xb.openElement("div"); xb.addAttribute("class", "control-group"); xb.openElement("label"); xb.addAttribute("for", minId); xb.addAttribute("class", ATTR_NAME_HTML_CLASS); xb.write(StringUtils.capitalize(label)); xb.closeElement("label"); xb.openElement("div"); xb.addAttribute("class", "controls"); rangeEndToXhtml(xb, minId, minInputName, minStringValue, getText("elements.search.range.from")); rangeEndToXhtml(xb, maxId, maxInputName, maxStringValue, getText("elements.search.range.to")); xb.closeElement("div"); xb.closeElement("div"); }
From source file:edu.northwestern.bioinformatics.studycalendar.domain.ScheduledActivityMode.java
public String getDisplayName() { return StringUtils.capitalize(getName()); }
From source file:com.wibidata.shopping.bulkimport.ProductBulkImporter.java
/** * Kiji will call this method once for each line in the input text file. * Each line in the input text file is a JSON object that has fields describing the product. * * This method should parse the JSON text line to extract relevant * information about the product. These facts about the product should be * written to the columns of a row in the kiji_shopping_product table. * * @param line The input text line of JSON. * @param context A helper object used to write to the KijiTable. * @throws IOException/*w ww . j av a2 s .c o m*/ */ @Override public void produce(LongWritable offset, Text line, KijiTableContext context) throws IOException { final JsonNode json = parseJson(line.toString()); // Parse the ID of the product. if (null == json.get("Id")) { return; } final String productId = json.get("Id").getTextValue(); // Use the ID of the dish as the ID of the WibiTable row. final EntityId entityId = context.getEntityId(productId); context.put(entityId, "info", "id", productId); if (null == json.get("Name")) { return; } context.put(entityId, "info", "name", json.get("Name").getTextValue()); if (null != json.get("DescriptionHtmlComplete")) { context.put(entityId, "info", "description", json.get("DescriptionHtmlComplete").getTextValue()); } if (null != json.get("DescriptionHtmlSimple")) { String simpleDesc = json.get("DescriptionHtmlSimple").getTextValue(); String shortDesc = StringUtils.split(simpleDesc, '\n')[0]; context.put(entityId, "info", "description_short", shortDesc); } if (null != json.get("Category")) { String category = json.get("Category").getTextValue().toLowerCase(); context.put(entityId, "info", "category", StringUtils.capitalize(category)); } if (null != json.get("Images").get("PrimaryMedium")) { context.put(entityId, "info", "thumbnail", json.get("Images").get("PrimaryMedium").getTextValue()); } if (null != json.get("Images").get("PrimaryExtraLarge")) { context.put(entityId, "info", "thumbnail_xl", json.get("Images").get("PrimaryExtraLarge").getTextValue()); } if (null != json.get("ListPrice")) { context.put(entityId, "info", "price", json.get("ListPrice").getDoubleValue()); } if (null != json.get("Skus").get(0).get("QuantityAvailable")) { context.put(entityId, "info", "inventory", json.get("Skus").get(0).get("QuantityAvailable").getLongValue()); } List<CharSequence> words = new ArrayList<CharSequence>(); for (JsonNode word : json.get("DescriptionWords")) { words.add(word.getTextValue().toLowerCase()); } DescriptionWords prodWords = DescriptionWords.newBuilder().setWords(words).build(); context.put(entityId, "info", "description_words", prodWords); }
From source file:jp.primecloud.auto.ui.mock.MockBeanContext.java
protected Object getBean(String id) { try {//from w w w .j a v a2s . c om String className = getClass().getPackage().getName() + ".service.Mock" + StringUtils.capitalize(id); return Class.forName(className).newInstance(); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:net.sourceforge.fenixedu.presentationTier.docs.academicAdministrativeOffice.Diploma.java
@Override protected void fillReport() { super.fillReport(); final DiplomaRequest diplomaRequest = getDocumentRequest(); String universityName = getUniversity(diplomaRequest.getRequestDate()).getPartyName().getPreferedContent(); addParameter("registryCode", diplomaRequest.hasRegistryCode() ? diplomaRequest.getRegistryCode().getCode() : null); addParameter("documentNumber", BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.diploma.documentNumber")); addParameter("conclusionDate", diplomaRequest.getConclusionDate().toString(getDatePattern(), getLocale())); addParameter("day", MessageFormat.format( BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.diploma.university.actualDate"), universityName, getFormatedCurrentDate())); if (diplomaRequest.hasFinalAverageDescription()) { addParameter("finalAverageDescription", StringUtils.capitalize(BundleUtil.getString(Bundle.ENUMERATION, getLocale(), diplomaRequest.getFinalAverage().toString()))); addParameter("finalAverageQualified", diplomaRequest.getFinalAverageQualified()); } else if (diplomaRequest.hasDissertationTitle()) { addParameter("dissertationTitle", diplomaRequest.getDissertationThesisTitle()); }/*w w w . java 2s.c o m*/ String finalAverage = BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "diploma.finalAverage"); addParameter("finalAverageDescription", MessageFormat.format(finalAverage, BundleUtil.getString(Bundle.ENUMERATION, getLocale(), diplomaRequest.getFinalAverage().toString()), diplomaRequest.getFinalAverage().toString(), BundleUtil.getString(Bundle.ACADEMIC, getLocale(), getQualifiedAverageGrade(getLocale())))); addParameter("conclusionStatus", MessageFormat.format( BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.diploma.conclusionStatus"), getConclusionStatusAndDegreeType(diplomaRequest, getRegistration()))); addParameter("degreeFilteredName", diplomaRequest.getDegreeFilteredName()); String graduateTitle = diplomaRequest.getGraduateTitle(getLocale()); if (graduateTitle.contains("Graduated")) { graduateTitle = graduateTitle.replace("Graduated", "Licenciado"); } if (graduateTitle.contains("Master")) { graduateTitle = graduateTitle.replace("Master", "Mestre"); } addParameter("graduateTitle", graduateTitle); addParameter("message1", BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.diploma.message1")); addParameter("message2", BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.diploma.message2")); addParameter("message3", BundleUtil.getString(Bundle.ACADEMIC, getLocale(), "label.diploma.message3")); }
From source file:com.opengamma.language.object.BeanFunctionProvider.java
private <T extends Bean> Collection<PublishedFunction> createBeanFunctions(Class<T> beanClass) { final Collection<PublishedFunction> functions = new ArrayList<PublishedFunction>(); final String simpleBeanName = beanClass.getSimpleName(); functions.add(new CreateBeanFunction(simpleBeanName, beanClass)); final MetaBean metaBean = JodaBeanUtils.metaBean(beanClass); final MetaParameter beanParameter = new MetaParameter(StringUtils.uncapitalize(simpleBeanName), JavaTypeInfo.builder(beanClass).get()); beanParameter.setDescription("is the " + simpleBeanName + " to query"); for (MetaProperty<?> property : metaBean.metaPropertyIterable()) { final String accessorFunctionName = "Get" + simpleBeanName + StringUtils.capitalize(property.name()); functions.add(new GetBeanPropertyFunction(accessorFunctionName, property, beanParameter)); }/*from ww w.j a v a 2s.co m*/ s_logger.debug("Created function definitions: " + functions); return functions; }