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.systemsx.cisd.openbis.generic.server.business.bo.DataAccessExceptionTranslator.java

/**
 * Analyzes given <code>DataAccessException</code> and converts it into a
 * <code>UserFailureException</code>.
 * <p>// w  w w  .  j a  v  a  2 s  .c  o m
 * This method is typically used by <i>creator</i> methods (methods which inserts a new object
 * into the database) and <i>deletion</i> methods.
 * </p>
 * 
 * @param subject short description of the object that got blessed by the unique/foreign key
 *            violation constraint.
 * @param entityKindOrNull entity kind of the subject object (if specified can make the error
 *            message more detailed especially for foreign key violation upon deletion)
 */
public final static void throwException(final DataAccessException exception, final String subject,
        final EntityKind entityKindOrNull) throws UserFailureException {
    assert StringUtils.isNotBlank(subject) : "Given subject can not be blank.";
    throwExceptionWithMsg(exception, StringUtils.capitalize(subject), entityKindOrNull);
}

From source file:info.magnolia.cms.taglibs.util.ImgTagBeanInfo.java

/**
 * Instantiate a property descriptor for the given property.
 * @param propertyName property name//  w  w  w  .j a v  a 2s . co m
 * @return property descriptor
 * @throws IntrospectionException if the given property is not valid
 */
private PropertyDescriptor createPropertyDescriptor(String propertyName) throws IntrospectionException {
    return new PropertyDescriptor(propertyName, ImgTag.class, null,
            "set" + StringUtils.capitalize(propertyName));
}

From source file:com.bcpv.webapp.displaytag.decorators.ListObject.java

/**
 * Constructor for ListObject./*ww w . j a v  a 2  s.c  om*/
 */
public ListObject() {
    this.id = random.nextInt(99998) + 1;
    this.money = (random.nextInt(999998) + 1) / 100;

    String firstName = RandomSampleUtil.getRandomWord();
    String lastName = RandomSampleUtil.getRandomWord();

    this.name = StringUtils.capitalize(firstName) + ' ' + StringUtils.capitalize(lastName);

    this.email = firstName + '-' + lastName + '@' + RandomSampleUtil.getRandomWord() + ".com"; //$NON-NLS-1$

    this.date = RandomSampleUtil.getRandomDate();

    this.description = RandomSampleUtil.getRandomWord() + ' ' //
            + RandomSampleUtil.getRandomWord() + "..."; //$NON-NLS-1$

    this.longDescription = RandomSampleUtil.getRandomSentence(10);

    this.status = RandomSampleUtil.getRandomWord().toUpperCase();

    // added sublist for testing of nested tables
    this.subList = new ArrayList();
    this.subList.add(new SubListItem());
    this.subList.add(new SubListItem());
    this.subList.add(new SubListItem());

    this.url = "http://www." + lastName + ".org/"; //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:edu.cornell.mannlib.vitro.webapp.web.directives.WidgetDirective.java

@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
        throws TemplateException, IOException {

    if (loopVars.length != 0) {
        throw new TemplateModelException("The dump directive doesn't allow loop variables.");
    }//from w  ww  . j a v  a 2s.  c  om
    if (body != null) {
        throw new TemplateModelException("The dump directive doesn't allow nested content.");
    }

    Object nameParam = params.get("name");
    if (!(nameParam instanceof SimpleScalar)) {
        throw new TemplateModelException("Value of parameter 'name' must be a string.");
    }
    String widgetName = nameParam.toString();

    // Optional param
    Object includeParam = params.get("include");
    String methodName;
    // If include param is missing, or something other than "assets", 
    // assign default value "markup"
    if (includeParam == null) {
        methodName = "markup";
    } else {
        methodName = includeParam.toString();
        if (!("assets".equals(methodName))) {
            methodName = "markup";
        }
    }
    methodName = "do" + StringUtils.capitalize(methodName);

    try {
        String widgetClassName = WIDGET_PACKAGE + "." + StringUtils.capitalize(widgetName) + "Widget";
        Class<?> widgetClass = Class.forName(widgetClassName);
        Widget widget = (Widget) widgetClass.newInstance();
        Method method = widgetClass.getMethod(methodName, Environment.class, Map.class);

        // Right now it seems to me that we will always be producing a string for the widget calls. If we need greater
        // flexibility, we can return a ResponseValues object and deal with different types here.
        String output = (String) method.invoke(widget, env, params);

        // If we're in the body template, automatically invoke the doAssets() method, so it
        // doesn't need to be called explicitly from the enclosing template.
        String templateType = env.getDataModel().get("templateType").toString();
        if ("doMarkup".equals(methodName) && FreemarkerHttpServlet.BODY_TEMPLATE_TYPE.equals(templateType)) {
            output += widgetClass.getMethod("doAssets", Environment.class, Map.class).invoke(widget, env,
                    params);
        }

        Writer out = env.getOut();
        out.write(output);

    } catch (ClassNotFoundException e) {
        log.error("Widget " + widgetName + " not found.");
    } catch (IOException e) {
        log.error("Error writing output for widget " + widgetName, e);
    } catch (Exception e) {
        log.error("Error invoking widget " + widgetName, e);
    }

}

From source file:com.legstar.protobuf.cobol.ProtoCobolUtils.java

/**
 * The java class name derived from the proto file name.
 * //from w ww .j  a v  a2 s  .c  o m
 * @param protoFile the proto file
 * @return the java class name
 */
public static String getDefaultJavaClassName(File protoFile) {
    return StringUtils.capitalize(FilenameUtils.getBaseName(protoFile.getName())) + ".java";
}

From source file:com.googlecode.gmaps4jsf.jsfplugin.digester.Attribute.java

public String getCapitalizedName() {
    return StringUtils.capitalize(name);
}

From source file:itvector.wineguide.ui.wines.MainActivity.java

@Override
public void onShowDescription(WineModel wineModels) {
    AlertDialog builder = new AlertDialog.Builder(this).setCancelable(true)
            .setTitle(R.string.dialog_title_description)
            .setMessage(StringUtils.capitalize(wineModels.getWine_type()))
            .setPositiveButton(R.string.button_ok, (dialog, id) -> dialog.dismiss()).create();
    builder.show();//from   www .  jav a2 s  .  c  om

    TextView textView = (TextView) builder.findViewById(android.R.id.message);
    textView.setTextSize(getResources().getDimension(R.dimen.dialog_message_description));
}

From source file:cn.fastmc.core.utils.ReflectionUtils.java

/**
 * Setter.//w ww  .j a va2s  . com
 * 
 * @param target
 *            Object
 * @param value
 *            
 * @param FieldType
 *            Setter,valueClass.
 */
public static void invokeSetterMethod(Object target, String propertyName, Object value, Class<?> FieldType) {
    Class<?> type = FieldType != null ? FieldType : value.getClass();
    String setterMethodName = "set" + StringUtils.capitalize(propertyName);
    invokeMethod(target, setterMethodName, new Class[] { type }, new Object[] { value });
}

From source file:at.ac.tuwien.big.momot.problem.unit.parameter.increment.IncrementalStringValue.java

@Override
public String nextValue() {
    String toReturn = next;/* w  ww  . j ava 2 s  . co m*/
    next = TextUtil.increment(next);

    switch (mode) {
    case CAPITALIZED:
        toReturn = StringUtils.capitalize(toReturn);
        break;
    case UPPER:
        toReturn = toReturn.toUpperCase();
        break;
    default:
        break;
    }
    return getPrefix() + toReturn + getSuffix();
}

From source file:com.ecyrd.jspwiki.ui.admin.SimpleAdminBean.java

/**
 *  By default, this method creates a blob of HTML, listing
 *  all the attributes which can be read or written to.  If the
 *  attribute is read-only, a readonly input widget is created.
 *  The value is determined by the toString() method of the attribute.
 *//* w w  w. j a  v a  2s .co  m*/
public String doGet(WikiContext context) {
    MBeanInfo info = getMBeanInfo();
    MBeanAttributeInfo[] attributes = info.getAttributes();
    StringBuffer sb = new StringBuffer();

    for (int i = 0; i < attributes.length; i++) {
        sb.append("<div class='block'>\n");

        sb.append("<label>" + StringUtils.capitalize(attributes[i].getName()) + "</label>\n");

        try {
            Object value = getAttribute(attributes[i].getName());
            if (attributes[i].isWritable()) {
                sb.append("<input type='text' name='question' size='30' value='" + value + "' />\n");
            } else {
                sb.append("<input type='text' class='readonly' readonly='true' size='30' value='" + value
                        + "' />\n");
            }
        } catch (Exception e) {
            sb.append("Exception: " + e.getMessage());
        }

        sb.append("<div class='description'>" + attributes[i].getDescription() + "</div>\n");

        sb.append("</div>\n");
    }
    return sb.toString();
}