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:eu.carrade.amaury.BallsOfSteel.game.BoSEquipmentManager.java

/**
 * Unlocks a tool for a player./*from   w w w . ja  v  a 2s  .c om*/
 *
 * @param playerID The player UUID
 * @param tool     The tool to unlock.
 */
private void unlock(final UUID playerID, final ToolsType tool) {
    // Unlocked only if enabled in the config
    if (isToolEnabled(tool)) {
        final Set<ToolsType> unlockedTools = getUnlockedTools(playerID);
        if (unlockedTools.contains(tool))
            return; // Already unlocked

        unlockedTools.add(tool);

        // Player notification
        final Player player = Bukkit.getPlayer(playerID);
        if (player.isOnline()) {
            final Set<ToolsType> leftToUnlock = new HashSet<>();
            for (final ToolsType toolType : ToolsType.values())
                if (isToolEnabled(toolType) && !unlockedTools.contains(toolType))
                    leftToUnlock.add(toolType);

            player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1l, 1l);

            final RawTextPart notification = new RawText("").then(I.t("\u272F Tool unlocked:"))
                    .color(ChatColor.YELLOW).then(" ").then(tool.getName()).color(ChatColor.GOLD)
                    .hover(new ItemStackBuilder(Material.POTATO_ITEM)
                            .title(ChatColor.GOLD, ChatColor.BOLD + tool.getName())
                            .longLore(ChatColor.GRAY, I.t(
                                    "You'll obtain this tool on every respawn now. You'll no longer have to craft it."))
                            .item())
                    .then(".").color(ChatColor.YELLOW);

            if (!leftToUnlock.isEmpty()) {
                ItemStackBuilder leftToUnlockHover = new ItemStackBuilder(Material.POTATO_ITEM)
                        .title(ChatColor.GOLD, ChatColor.BOLD + I.t("What's left to unlock"))
                        .longLore(ChatColor.GRAY, I.t(
                                "You can still unlock these, by crafting them one time to get them on every respawn."));

                for (final ToolsType toolToUnlock : leftToUnlock)
                    leftToUnlockHover.loreLine(ChatColor.DARK_GRAY + "- ",
                            ChatColor.WHITE + StringUtils.capitalize(toolToUnlock.getName().toLowerCase()));

                notification.then(" ").then(I.t("Hover here to see what's next...")).color(ChatColor.GRAY)
                        .hover(leftToUnlockHover.item());
            }

            RawMessage.send(player, notification.build());
        }
    }
}

From source file:adalid.core.jee.AbstractJavaWebModule.java

private String pageSetName(Entity entity, EntityReference reference) {
    String name = entity.getName();
    if (reference != null) {
        name += BY + StringUtils.capitalize(reference.getName());
    }//from ww w  . j a v a  2 s.  c o  m
    logger.debug("pageset=" + name);
    return name;
}

From source file:com.manydesigns.elements.fields.search.SelectSearchField.java

public void valueToXhtmlAutocomplete(XhtmlBuffer xb) {
    xb.writeLabel(StringUtils.capitalize(label), id, ATTR_NAME_HTML_CLASS);

    xb.openElement("div");
    xb.addAttribute("class", "controls");

    Object value = selectionModel.getValue(selectionModelIndex);
    String stringValue = OgnlUtils.convertValueToString(value);
    xb.writeInputHidden(id, inputName, stringValue);
    String label = selectionModel.getOption(selectionModelIndex, value, true);

    xb.openElement("input");
    xb.addAttribute("id", autocompleteId);
    xb.addAttribute("type", "text");
    xb.addAttribute("name", autocompleteInputName);
    xb.addAttribute("value", label);
    xb.addAttribute("class", null);
    xb.addAttribute("size", null);
    xb.closeElement("input");

    String js = composeAutocompleteJs();
    xb.writeJavaScript(js);/*w ww  .  ja  v a 2s  .  c  o  m*/
    xb.closeElement("div");
}

From source file:hudson.security.HudsonPrivateSecurityRealmTest.java

private void createFirstAccount(String login) throws Exception {
    assertNull(User.getById(login, false));

    JenkinsRule.WebClient wc = j.createWebClient();

    HudsonPrivateSecurityRealm.SignupInfo info = new HudsonPrivateSecurityRealm.SignupInfo();
    info.username = login;/*from   www . j av  a 2s  .  c  o  m*/
    info.password1 = login;
    info.password2 = login;
    info.fullname = StringUtils.capitalize(login);

    WebRequest request = new WebRequest(new URL(wc.getContextPath() + "securityRealm/createFirstAccount"),
            HttpMethod.POST);
    request.setRequestParameters(Arrays.asList(new NameValuePair("username", login),
            new NameValuePair("password1", login), new NameValuePair("password2", login),
            new NameValuePair("fullname", StringUtils.capitalize(login)),
            new NameValuePair("email", login + "@" + login + ".com")));

    HtmlPage p = wc.getPage(request);
    assertEquals(200, p.getWebResponse().getStatusCode());
    assertTrue(p.getDocumentElement().getElementsByAttribute("div", "class", "error").isEmpty());

    assertNotNull(User.getById(login, false));
}

From source file:com.adaptris.core.services.jdbc.FirstRowMetadataTranslatorTest.java

public void testServiceWithStyleCapitalize() throws Exception {
    createDatabase();//from  www  .j  a  v a  2 s  . co m
    List<AdapterTypeVersion> dbItems = generate(10);
    AdapterTypeVersion entry = dbItems.get(0);

    populateDatabase(dbItems, false);
    JdbcDataQueryService s = createMetadataService();
    FirstRowMetadataTranslator t = new FirstRowMetadataTranslator();
    t.setColumnNameStyle(ResultSetTranslatorImp.ColumnStyle.Capitalize);
    s.setResultSetTranslator(t);
    AdaptrisMessage msg = createMessage(entry);
    execute(s, msg);
    assertEquals(XML_PAYLOAD_PREFIX + entry.getUniqueId() + XML_PAYLOAD_SUFFIX, msg.getContent());
    assertTrue(msg
            .containsKey(t.getMetadataKeyPrefix() + t.getSeparator() + StringUtils.capitalize(COLUMN_VERSION)));
    assertEquals(entry.getVersion(), msg.getMetadataValue(
            t.getMetadataKeyPrefix() + t.getSeparator() + StringUtils.capitalize(COLUMN_VERSION)));
    assertTrue(
            msg.containsKey(t.getMetadataKeyPrefix() + t.getSeparator() + StringUtils.capitalize(COLUMN_TYPE)));
    assertEquals(entry.getTranslatorType(), msg.getMetadataValue(
            t.getMetadataKeyPrefix() + t.getSeparator() + StringUtils.capitalize(COLUMN_TYPE)));
}

From source file:com.qcadoo.model.internal.classconverter.ModelXmlToClassConverterImpl.java

private String getGetterForField(final String fieldName) {
    return "get" + StringUtils.capitalize(fieldName) + "()";
}

From source file:com.google.gdt.eclipse.designer.uibinder.model.util.EventHandlerProperty.java

/**
 * @return the existing or new {@link MethodDeclaration} for this event.
 *///from   w  w  w  .jav a 2 s  .  c  om
private MethodDeclaration createMethodDeclaration0() throws Exception {
    String name = NameSupport.ensureName(m_object);
    String eventTypeName = m_handler.getEventTypeName();
    // prepare name of method
    String methodName;
    {
        String eventName = StringUtils.removeStart(m_handler.getMethodName(), "on");
        String baseName = "on" + StringUtils.capitalize(name) + eventName;
        methodName = m_editor.getUniqueMethodName(baseName);
    }
    // add method
    String uiHandlerAnnotation = "@com.google.gwt.uibinder.client.UiHandler(\"" + name + "\")";
    String header = "void " + methodName + "(" + eventTypeName + " event)";
    MethodDeclaration method = m_editor.addMethodDeclaration(ImmutableList.<String>of(uiHandlerAnnotation),
            header, ImmutableList.<String>of(), new BodyDeclarationTarget(m_typeDeclaration, false));
    // done
    return method;
}

From source file:mrcg.MRCGInstance.java

private void createEditJSPs() throws Exception {
    for (JavaClass jclass : types.values()) {
        if (!(jclass.isEnum() || jclass.isMapping() || skipGui(jclass))) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("basePackage", basePackage);
            map.put("classUpper", StringUtils.capitalize(jclass.getName()));
            map.put("classUpperSpaced", Utils.toSpacedCamelCase(StringUtils.capitalize(jclass.getName())));
            map.put("classLower", jclass.getName().toLowerCase());
            map.put("classLowerCamel", StringUtils.uncapitalize(jclass.getName()));
            map.put("fields", jclass.getNonAutoHandledInstanceFields());
            //            map.put("mappings", convertToJspEditCode(jclass));
            map.put("tagLibPrefix", tagLibPrefix);
            File file = new File(webPath + "admin/" + jclass.getName().toLowerCase() + "/edit.jsp");
            velocity(file, getResourcePath("edit-jsp.vel"), map, false);

            file = new File(webPath + "admin/" + jclass.getName().toLowerCase() + "/edit-layout.jsp");
            velocity(file, getResourcePath("edit-layout-jsp.vel"), map, true);

        }//www . j  a  va  2 s .com
    }
}

From source file:com.manydesigns.elements.fields.search.SelectSearchField.java

private void valueToXhtmlCheckbox(XhtmlBuffer xb) {
    xb.writeLabel(StringUtils.capitalize(label), id, ATTR_NAME_HTML_CLASS);

    xb.openElement("div");
    xb.addAttribute("class", "controls");

    Object[] values = getValues();
    Map<Object, SelectionModel.Option> options = selectionModel.getOptions(selectionModelIndex);
    int counter = 0;
    for (Map.Entry<Object, SelectionModel.Option> option : options.entrySet()) {
        if (!option.getValue().active) {
            continue;
        }//from  w  ww . ja  v  a  2 s  .c  o m
        Object optionValue = option.getKey();
        String optionStringValue = OgnlUtils.convertValueToString(optionValue);
        String optionLabel = option.getValue().label;
        boolean checked = ArrayUtils.contains(values, optionValue);
        String checkboxId = id + "_" + counter;
        xb.openElement("label");
        xb.addAttribute("class", "checkbox");
        xb.addAttribute("for", checkboxId);
        xb.writeNbsp();
        xb.write(optionLabel);
        xb.writeNbsp();
        xb.writeInputCheckbox(checkboxId, inputName, optionStringValue, checked);
        xb.writeNbsp();
        xb.closeElement("label");
        counter++;
    }
    xb.closeElement("div");
}

From source file:com.evolveum.midpoint.prism.parser.PrismBeanInspector.java

private <T> Method findPropertyGetterUncached(Class<T> classType, String propName) {
    if (propName.startsWith("_")) {
        propName = propName.substring(1);
    }/*  w w w. j av  a2s. com*/
    for (Method method : classType.getDeclaredMethods()) {
        XmlElement xmlElement = method.getAnnotation(XmlElement.class);
        if (xmlElement != null && xmlElement.name() != null && xmlElement.name().equals(propName)) {
            return method;
        }
        XmlAttribute xmlAttribute = method.getAnnotation(XmlAttribute.class);
        if (xmlAttribute != null && xmlAttribute.name() != null && xmlAttribute.name().equals(propName)) {
            return method;
        }
    }
    String getterName = "get" + StringUtils.capitalize(propName);
    try {
        return classType.getDeclaredMethod(getterName);
    } catch (NoSuchMethodException e) {
        // nothing found
    }
    getterName = "is" + StringUtils.capitalize(propName);
    try {
        return classType.getDeclaredMethod(getterName);
    } catch (NoSuchMethodException e) {
        // nothing found
    }
    Class<? super T> superclass = classType.getSuperclass();
    if (superclass.equals(Object.class)) {
        return null;
    }
    return findPropertyGetter(superclass, propName);
}