Example usage for org.apache.commons.lang StringUtils capitalize

List of usage examples for org.apache.commons.lang StringUtils capitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils capitalize.

Prototype

public static String capitalize(String str) 

Source Link

Document

Capitalizes a String changing the first letter to title case as per Character#toTitleCase(char) .

Usage

From source file:ch.entwine.weblounge.common.content.page.PagePreviewMode.java

/**
 * Parses the page preview./*from   ww w.  ja va2  s. com*/
 * 
 * @param mode
 *          the mode
 * @return the page preview
 */
public static PagePreviewMode parse(String mode) {
    if (mode == null)
        throw new IllegalArgumentException("Mode must not be null");
    mode = StringUtils.capitalize(mode.toLowerCase());
    return PagePreviewMode.valueOf(mode);
}

From source file:de.erdesignerng.generator.openxava.OpenXavaOptions.java

public String createPropertyName(String aName) {
    return StringUtils.capitalize(aName.toLowerCase());
}

From source file:net.servicefixture.util.ReflectionUtils.java

public static Class getAttributeType(Object object, String attributeName) {
    try {//from w  w  w  .j a  v a 2 s.  co m
        Method method = object.getClass().getMethod("get" + StringUtils.capitalize(attributeName));
        return method.getReturnType();
    } catch (Exception e) {
        throw new ServiceFixtureException(
                "Unable to find the attribute:" + attributeName + " in class: " + object.getClass().getName());
    }
}

From source file:com.liferay.ide.ui.snippets.AddModelEntitySnippetInsertion.java

protected String getPreparedText(AbstractModelWizard wizard) {
    String text = super.getPreparedText(wizard);

    StringBuffer fields = new StringBuffer();
    String[] propColumns = wizard.getPropertyColumns();
    String var = wizard.getVarName();

    if (!CoreUtil.isNullOrEmpty(propColumns)) {
        for (String prop : propColumns) {
            fields.append(var + ".set" + StringUtils.capitalize(prop) + "(" + prop + ");\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }/*w w w.  j  a  va 2s  . c  o m*/
    }

    String fieldsVal = fields.toString();
    text = StringUtils.replace(text, "${fields}", //$NON-NLS-1$
            CoreUtil.isNullOrEmpty(fieldsVal) ? StringPool.EMPTY : fieldsVal);

    return text;
}

From source file:de.tu.darmstadt.lt.ner.feature.extractor.CamelCaseFeatureExtractor.java

@Override
public List<Feature> apply(Feature feature) {

    Object featureValue = feature.getValue();

    if (featureValue == null) {
        return Collections.singletonList(new Feature("CapsFeature", "CapsFeature_null"));
    }//from w  ww  .  j a v a 2 s.  c  o  m

    String value = featureValue.toString();
    if (value == null || value.length() == 0) {
        return Collections.singletonList(new Feature("CapsFeature", "CapsFeature_null"));
    }

    if (StringUtils.isAllUpperCase(value)) {
        return Collections
                .singletonList(new Feature("CapsFeature", StringUtils.capitalize(value.toLowerCase())));
    } else {
        return Collections.singletonList(new Feature("CapsFeature", value));
    }

}

From source file:au.com.jwatmuff.eventmanager.util.GUIUtils.java

public static boolean confirmAction(Frame parent, String verb, String object) {
    int status = JOptionPane.showConfirmDialog(parent, "Are you sure you wish to " + verb + " " + object + "?",
            "Confirm " + StringUtils.capitalize(verb), JOptionPane.YES_NO_OPTION);
    return (status == JOptionPane.YES_OPTION);
}

From source file:com.haulmont.cuba.core.sys.persistence.DbmsSpecificFactory.java

public static <T> T create(Class<T> intf, String dbmsType, String dbmsVersion) {
    String intfName = intf.getName();
    String packageName = intfName.substring(0, intfName.lastIndexOf('.') + 1);

    String name = packageName + StringUtils.capitalize(dbmsType) + dbmsVersion + intf.getSimpleName();
    Class<?> aClass;/*w ww  .  j  a  v a 2 s . c  o  m*/
    try {
        aClass = ReflectionHelper.loadClass(name);
    } catch (ClassNotFoundException e) {
        name = packageName + StringUtils.capitalize(dbmsType) + intf.getSimpleName();
        try {
            aClass = ReflectionHelper.loadClass(name);
        } catch (ClassNotFoundException e1) {
            throw new RuntimeException("Error creating " + intfName + " implementation", e1);
        }
    }
    try {
        //noinspection unchecked
        return (T) aClass.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
        throw new RuntimeException("Error creating " + intfName + " implementation", e);
    }
}

From source file:com.xhsoft.framework.common.utils.ReflectUtil.java

/**
 * <p>Description:ReflectionMap?</p>
 * @param target//  ww w .  ja  v a2  s. co  m
 * @return Map<String,Object>
 * @author wanggq
 * @since  2009-9-9
 */
@SuppressWarnings("unchecked")
public static Map<String, Object> getMapFieldData(Object target) {
    Map<String, Object> map = new HashMap<String, Object>();
    Class clazz = target.getClass();
    Field[] fields = clazz.getDeclaredFields();
    Method[] methods = clazz.getDeclaredMethods();
    for (Field field : fields) {
        String fieldName = field.getName();

        if ("messageTypeId".equals(fieldName)) {
            continue;
        }

        String getMethod = "get" + StringUtils.capitalize(fieldName);
        for (Method method : methods) {
            if (method.getName().equals(getMethod)) {

                try {
                    Object ret = method.invoke(target, null);
                    map.put(fieldName, ret);
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }

            }

        }

    }

    return map;
}

From source file:com.haulmont.cuba.core.sys.CubaAnnotationsLoader.java

private boolean propertyBelongsTo(Field field, MetaProperty metaProperty, List<Class> systemInterfaces) {
    String getterName = "get" + StringUtils.capitalize(metaProperty.getName());

    Class<?> aClass = field.getDeclaringClass();
    //noinspection unchecked
    List<Class> allInterfaces = ClassUtils.getAllInterfaces(aClass);
    for (Class intf : allInterfaces) {
        Method[] methods = intf.getDeclaredMethods();
        for (Method method : methods) {
            if (method.getName().equals(getterName) && method.getParameterTypes().length == 0) {
                if (systemInterfaces.contains(intf))
                    return true;
            }//from  w ww  .ja va 2  s.c  om
        }
    }
    return false;
}

From source file:gov.nih.nci.cabig.caaers.web.ae.SubmitterTab.java

private InputFieldGroup createPersonGroup(String person, String name) {
    String groupName = name == null ? person : name;
    InputFieldGroup group = new DefaultInputFieldGroup(groupName, StringUtils.capitalize(person) + " details");
    String base = person + '.';
    group.getFields().add(InputFieldFactory.createTextField(base + "firstName", "First name", true));
    group.getFields().add(InputFieldFactory.createTextField(base + "middleName", "Middle name", false));
    group.getFields().add(InputFieldFactory.createTextField(base + "lastName", "Last name", true));

    group.getFields().add(createContactField(base, ReportPerson.EMAIL, "E-mail address",
            FieldValidator.EMAIL_VALIDATOR, FieldValidator.NOT_NULL_VALIDATOR));
    InputField phoneField = createCustomPhoneTextField(base, ReportPerson.PHONE, "Phone", true);
    InputFieldAttributes.setSize(phoneField, 21);
    InputField faxField = createCustomPhoneTextField(base, ReportPerson.FAX, "Fax", true);
    InputFieldAttributes.setSize(faxField, 21);

    faxField.getAttributes().put(InputField.EXTRA_VALUE_PARAMS, "phone-number");

    group.getFields().add(phoneField);//from www  .j  av  a2s.  co m
    group.getFields().add(faxField);

    return group;
}