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.frameworkset.orm.engine.model.JavaNameGenerator.java
/** * Converts a database schema name to java object name. Operates * same as underscoreMethod but does not convert anything to * lowercase.// www . j a v a2s . c o m * * @param schemaName name to be converted. * @return converted name. * @see com.frameworkset.orm.engine.model.NameGenerator * @see #underscoreMethod(String) */ protected String javanameField(String schemaName, boolean IGNORE_FIRST_TOKEN) { StringBuffer name = new StringBuffer(); StringTokenizer tok = new StringTokenizer(schemaName, String.valueOf(STD_SEPARATOR_CHAR)); boolean first = true; while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); if (!first) { name.append(StringUtils.capitalize(namePart)); } else { first = false; name.append(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)); first = true; while (tok.hasMoreTokens()) { String namePart = (String) tok.nextElement(); if (!first) { name.append(StringUtils.capitalize(namePart)); } else { first = false; name.append(namePart); } } return name.toString(); }
From source file:com.dac2014equipe3.sujet2.presentation.controller.MemberBean.java
/** * Mettre jour les informations de l'utilisateur *///from w w w .ja v a 2 s . c o m public String updateAccount() { setId(Utilities.getSessionMemberId()); setLoggedIn(Utilities.getSessionMemberLoggedIn()); if (!isLoggedIn()) { Utilities.addMessageToContext(FacesMessage.SEVERITY_ERROR, "Echec de mise jour, Utilisateur non connect"); return "failure"; } else { MemberFacade memberFacade = FacadeFactory.getInstance().getMemberFacade(); MemberVo memberVo = new MemberVo(); memberFacade = FacadeFactory.getInstance().getMemberFacade(); Date datenow = new Date(); if (!getLogin().matches(LOGIN_PATTERN) || !getEmail().matches(EMAIL_PATTERN) || !getPassword().matches(PASSWORD_PATTERN) || !getSex().contentEquals("F") || !getSex().contentEquals("M") || !getFirstName().matches(FIRSTNAME_PATTERN) || !getLastName().matches(LASTNAME_PATTERN) || !getBirthday().after(datenow) || !getProfession().matches(PROFESSION_PATTERN)) { Utilities.addMessageToContext(FacesMessage.SEVERITY_ERROR, "Echec de mise jour (validation des champs)"); return "failure"; } //TODO Nationalit checker memberVo.setMemberId(getId()); memberVo.setMemberLogin(getLogin()); memberVo.setMemberEmail(getEmail()); memberVo.setMemberPassword(getPassword()); memberVo.setMemberNationality(getNationality()); memberVo.setMemberBirthday(getBirthday()); memberVo.setMemberFirstname(StringUtils.capitalize(getFirstName())); memberVo.setMemberLastname(StringUtils.capitalize(getLastName())); memberVo.setMemberProfession(StringUtils.capitalize(getProfession())); memberVo.setMemberJoiningDate(new Date()); memberVo.setMemberSex(getSex()); memberVo.setMemberIsSuppressed(isSuppressed()); memberVo.setMemberIsAdmin(isAdmin()); if (memberFacade.updateMember(memberVo)) { Utilities.addMessageToContext(FacesMessage.SEVERITY_INFO, " Mis jour effectu avec succs "); return "success"; } Utilities.addMessageToContext(FacesMessage.SEVERITY_ERROR, " Echec de mise jour "); return "failure"; } }
From source file:com.adaptris.core.services.jdbc.AllRowsMetadataTranslatorTest.java
public void testServiceWithStyleCapitalize() throws Exception { createDatabase();//w w w . j av a2 s .c o m List<AdapterTypeVersion> dbItems = generate(10); AdapterTypeVersion entry = dbItems.get(0); populateDatabase(dbItems, false); JdbcDataQueryService s = createMetadataService(); s.setStatementCreator(new ConfiguredSQLStatement(ALL_ROWS_QUERY)); s.getStatementParameters().clear(); AllRowsMetadataTranslator t = new AllRowsMetadataTranslator(); t.setColumnNameStyle(ResultSetTranslatorImp.ColumnStyle.Capitalize); s.setResultSetTranslator(t); AdaptrisMessage msg = createMessage(entry); execute(s, msg); String metadataKeyColumnVersion = t.getMetadataKeyPrefix() + t.getSeparator() + StringUtils.capitalize(COLUMN_VERSION) + t.getSeparator(); String metadataKeyColumnType = t.getMetadataKeyPrefix() + t.getSeparator() + StringUtils.capitalize(COLUMN_TYPE) + t.getSeparator(); for (int i = 0; i < 10; i++) { assertTrue(metadataKeyColumnVersion + i, msg.headersContainsKey(metadataKeyColumnVersion + i)); assertTrue(metadataKeyColumnType + i, msg.headersContainsKey(metadataKeyColumnType + i)); } }
From source file:com.aol.advertising.qiao.util.ContextUtils.java
/** * Invoke a class method if exists./*from ww w . j a v a2 s. co m*/ * * @param object * @param fieldName * @param param * @throws BeansException * @throws ClassNotFoundException */ public static void injectMethodSilently(Object object, String fieldName, Object param) throws BeansException, ClassNotFoundException { String mth_name = "set" + StringUtils.capitalize(fieldName); Method mth = findMethod(object.getClass(), mth_name, param.getClass()); if (mth != null) { ReflectionUtils.invokeMethod(mth, object, param); } }
From source file:com.ocs.dynamo.utils.ClassUtils.java
/** * Retrieves a field value/* w w w . ja v a2 s. co m*/ * * @param obj * the object from which to retrieve the field value * @param fieldName * the name of the field * @return */ public static Object getFieldValue(Object obj, String fieldName) { try { int p = fieldName.indexOf("."); if (p >= 0) { String firstProperty = fieldName.substring(0, p); Object first = MethodUtils.invokeMethod(obj, GET + StringUtils.capitalize(firstProperty), new Object[] {}); return getFieldValue(first, fieldName.substring(p + 1)); } else { if (hasMethod(obj, GET + StringUtils.capitalize(fieldName))) { // first check for a getter return MethodUtils.invokeMethod(obj, GET + StringUtils.capitalize(fieldName), new Object[] {}); } else { // next, check for an "is" method in case of a boolean return MethodUtils.invokeMethod(obj, IS + StringUtils.capitalize(fieldName), new Object[] {}); } } } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new OCSRuntimeException(e.getMessage(), e); } }
From source file:io.fabric8.kubernetes.pipeline.devops.ApplyStepExecution.java
private String createDefaultEnvironmentName(String environment) { if (StringUtils.isBlank(environment)) { return environment; }//w w w . j ava 2 s.c o m String[] split = environment.split("-"); String answer = environment; if (split != null && split.length > 0) { answer = split[split.length - 1]; } return StringUtils.capitalize(answer); }
From source file:ch.puzzle.itc.mobiliar.presentation.resourcesedit.EditResourceView.java
public String getCapitalizedResourceTypeName() { return StringUtils.capitalize(getResourceType().getName().toLowerCase()); }
From source file:io.swagger.inflector.utils.ReflectionUtils.java
public String getMethodName(String path, String httpMethod, Operation operation) { String output = operation.getOperationId(); if (output != null) { return sanitizeToJava(output); }//from w w w . j a v a 2 s .co m String tmpPath = path; tmpPath = tmpPath.replaceAll("\\{", ""); tmpPath = tmpPath.replaceAll("\\}", ""); String[] parts = (tmpPath + "/" + httpMethod).split("/"); StringBuilder builder = new StringBuilder(); if ("/".equals(tmpPath)) { // must be root tmpPath builder.append("root"); } for (int i = 0; i < parts.length; i++) { String part = parts[i]; if (part.length() > 0) { if (builder.toString().length() == 0) { part = Character.toLowerCase(part.charAt(0)) + part.substring(1); } else { part = StringUtils.capitalize(part); } builder.append(part); } } output = builder.toString(); LOGGER.warn("generated operationId " + output); return output; }
From source file:com.haulmont.cuba.core.config.ConfigUtil.java
/** * Get the default value of a configuration interface method. If a * {@link Default} annotation is present then that string is converted * to the appropriate type using the {@link TypeFactory} class. * Otherwise, for the type Foo, this searches for a FooDefault * annotation. If such an annotation is present then its value is * returned.//from www .ja v a2 s .c o m * * @param configInterface The configuration interface. * @param method The method. * @return The default value, or null. */ public static String getDefaultValue(Class<?> configInterface, Method method) { // TODO: returnType.cast()? try { Default defaultValue = method.getAnnotation(Default.class); if (defaultValue != null) { return defaultValue.value(); } else { Class<?> type = method.getReturnType(); if (EnumClass.class.isAssignableFrom(type)) { @SuppressWarnings("unchecked") Class<EnumClass> enumeration = (Class<EnumClass>) type; EnumStore mode = getAnnotation(configInterface, method, EnumStore.class, true); if (mode != null && EnumStoreMode.ID == mode.value()) { Class<?> idType = getEnumIdType(enumeration); String name = "Default" + StringUtils.capitalize(ClassUtils.getShortClassName(idType)); Object value = getAnnotationValue(method, name); if (value != null) { Method fromId = enumeration.getDeclaredMethod("fromId", idType); TypeStringify stringConverter = TypeStringify.getInstance(configInterface, method); return stringConverter.stringify(fromId.invoke(null, value)); } return NO_DEFAULT; } } String name = "Default" + StringUtils.capitalize(ClassUtils.getShortClassName(type)); Object value = getAnnotationValue(method, name); if (value != null) { TypeStringify stringConverter = TypeStringify.getInstance(configInterface, method); return stringConverter.stringify(value); } } return NO_DEFAULT; } catch (Exception ex) { throw new RuntimeException("Default value error", ex); } }
From source file:com.adobe.acs.commons.wcm.impl.ComponentHelperImpl.java
public String getEditIconImgTag(ComponentEditType.Type editType) { final String title = StringUtils.capitalize(editType.getName()); return "<img src=\"/libs/cq/ui/resources/0.gif\"" + " " + "class=\"" + editType.getCssClass() + "\"" + " " + "alt=\"" + title + "\" " + "title=\"" + title + "\" />"; }