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

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

Introduction

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

Prototype

public static String capitalize(final 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.cyberduck.ui.cocoa.ProgressController.java

@Override
public void stop(final Transfer transfer) {
    invoke(new DefaultMainAction() {
        @Override/*from ww w. ja va 2s  .c o m*/
        public void run() {
            progressBar.stopAnimation(null);
            progressBar.setIndeterminate(true);
            progressBar.setHidden(true);
            message(StringUtils.EMPTY);
            progress(MessageFormat.format(LocaleFactory.localizedString("{0} of {1}"),
                    sizeFormatter.format(transfer.getTransferred()), sizeFormatter.format(transfer.getSize())));
            status(LocaleFactory.localizedString(LocaleFactory.localizedString(transfer.isComplete()
                    ? String.format("%s complete", StringUtils.capitalize(transfer.getType().name()))
                    : "Transfer incomplete", "Status"), "Status"));
            statusIconView.setImage(transfer.isComplete() ? GREEN_ICON : RED_ICON);
        }
    });
}

From source file:io.openmessaging.rocketmq.utils.BeanUtils.java

public static <T> T populate(final Properties properties, final T obj) {
    Class<?> clazz = obj.getClass();
    try {//from w w  w . java  2s  .  c o m

        Set<Map.Entry<Object, Object>> entries = properties.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            String entryKey = entry.getKey().toString();
            String[] keyGroup = entryKey.split("\\.");
            for (int i = 0; i < keyGroup.length; i++) {
                keyGroup[i] = keyGroup[i].toLowerCase();
                keyGroup[i] = StringUtils.capitalize(keyGroup[i]);
            }
            String beanFieldNameWithCapitalization = StringUtils.join(keyGroup);
            try {
                setProperties(clazz, obj, "set" + beanFieldNameWithCapitalization, entry.getValue());
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
                //ignored...
            }
        }
    } catch (RuntimeException e) {
        log.warn("Error occurs !", e);
    }
    return obj;
}

From source file:io.proleap.vb6.asg.runner.impl.VbParserRunnerImpl.java

protected String getModuleName(final File inputFile) {
    return StringUtils.capitalize(FilenameUtils.removeExtension(inputFile.getName()));
}

From source file:ch.cyberduck.ui.cocoa.controller.ProgressController.java

/**
 * Resets both the progress and status field
 *///from   www .  j  a  v  a 2 s  .c  o m
@Override
public void awakeFromNib() {
    this.setProgress(MessageFormat.format(LocaleFactory.localizedString("{0} of {1}"),
            sizeFormatter.format(transfer.getTransferred()), sizeFormatter.format(transfer.getSize())));
    this.setMessage(StringUtils.EMPTY);
    this.setStatus(LocaleFactory.localizedString(transfer.isComplete()
            ? String.format("%s complete", StringUtils.capitalize(transfer.getType().name()))
            : "Transfer incomplete", "Status"));
    super.awakeFromNib();
}

From source file:kenh.expl.Environment.java

/**
 * Load <code>Function</code>. 
 * /*  w  ww.  j  a v a 2s .c  o m*/
 * @param funcPackage  The function package.
 * @param funcName     The function name.
 * @return      Use <code>funcPackage + funcName</code> to load class, if not find, return null.
 */
private Function getFunction_(String funcPackage, String funcName) {
    if (StringUtils.isBlank(funcPackage))
        return null;
    if (StringUtils.isBlank(funcName))
        return null;

    funcPackage = StringUtils.trimToEmpty(funcPackage);
    funcName = StringUtils.trimToEmpty(funcName);

    try {
        if (StringUtils.isNotBlank(funcPackage)) {
            Function function = (Function) Class.forName(funcPackage + "." + StringUtils.capitalize(funcName))
                    .newInstance();
            return function;
        }
    } catch (Throwable e) {
    }
    return null;
}

From source file:com.robertsmieja.test.utils.junit.GettersAndSettersUtils.java

static String accessorMethodNameForField(String accessorPrefix, Field field) {
    return accessorPrefix + StringUtils.capitalize(field.getName());
}

From source file:info.magnolia.ui.admincentral.shellapp.favorites.FavoritesPresenterTest.java

@Before
public void setUp() throws RegistrationException, URISyntaxException {

    ctx = new MockWebContext();
    MgnlContext.setInstance(ctx);/* w  w w. ja v a 2 s.  com*/

    session = new MockSession(FavoriteStore.WORKSPACE_NAME);
    ctx.addSession(FavoriteStore.WORKSPACE_NAME, session);

    FavoritesView view = mock(FavoritesView.class);

    FavoritesManager favoritesManager = mock(FavoritesManager.class);
    doAnswer(new Answer<JcrNewNodeAdapter>() {

        @Override
        public JcrNewNodeAdapter answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            JcrNewNodeAdapter newFavorite = new JcrNewNodeAdapter(session.getRootNode(), NAME);
            newFavorite.addItemProperty(TITLE, new ObjectProperty<String>((String) args[1]));
            newFavorite.addItemProperty(URL, new ObjectProperty<String>((String) args[0]));
            newFavorite.addItemProperty(ICON,
                    new ObjectProperty<String>(StringUtils.defaultIfEmpty((String) args[2], "icon-app")));
            return newFavorite;
        }
    }).when(favoritesManager).createFavoriteSuggestion(anyString(), anyString(), anyString());

    /**
     * We mock a sample descriptor that would be returned when favorites presenter will ask.
     * We do not set the name/title for sake of testing the i18n functionality.
     */
    AppDescriptorRegistry registry = mock(AppDescriptorRegistry.class);
    ConfiguredAppDescriptor descriptor = new ConfiguredAppDescriptor();
    descriptor.setName("favoritesRandomApp");
    doReturn(descriptor).when(registry).getAppDescriptor(anyString());
    I18nizer i18nizer = mock(I18nizer.class); // simple I18nizer mock which only decorates based on appDescriptor name
    doAnswer(new Answer<AppDescriptor>() {

        @Override
        public AppDescriptor answer(InvocationOnMock invocation) throws Throwable {
            ConfiguredAppDescriptor appDescriptor = (ConfiguredAppDescriptor) invocation.getArguments()[0];
            appDescriptor.setIcon("icon-" + appDescriptor.getName());
            appDescriptor.setLabel(StringUtils.capitalize(appDescriptor.getName()));
            return appDescriptor;
        }
    }).when(i18nizer).decorate(any());

    presenter = new FavoritesPresenter(view, favoritesManager, registry, i18nizer);
}

From source file:io.apiman.gateway.engine.vertx.polling.PolicyConfigLoader.java

@SuppressWarnings("unchecked")
private <T, K> List<T> requireJsonArray(String keyName, JsonObject json, Class<K> klazz) {
    // Contains key.
    Arguments.require(json.containsKey(keyName), String.format("Must provide array of %s objects for key '%s'",
            StringUtils.capitalize(keyName), keyName));
    // Is of type array.
    Arguments.require(json.getValue(keyName) instanceof JsonArray,
            String.format("'%s' must be a Json array", keyName));
    // Transform into List<T>.
    return Json.decodeValue(json.getJsonArray(keyName).encode(), List.class, klazz);
}

From source file:com.jci.utils.CommonUtils.java

/**
 * Gets the header string.//from   www  .  jav a2s .  c o  m
 *
 * @param mapping the mapping
 * @return the header string
 */
public String getHeaderString(HashMap<Integer, String> mapping) {
    StringBuilder line = new StringBuilder();
    for (int i = 0; i < mapping.size(); i++) {
        String str = StringUtils.capitalize(mapping.get(i));
        str = str.substring(0, 1).toUpperCase() + str.substring(1);
        String[] upperStr = str.split("(?<=[a-z])(?=[A-Z])");
        String joined = "#" + String.join(" ", upperStr);
        line.append(joined + "\t");
    }

    return line.toString();
}

From source file:com.discovery.darchrow.lang.StringUtil.java

/**
 * ??? jinxin//from   w  w w.  j a  v  a 2  s.c  o  m
 * 
 * return Jinxin
 * 
 * <pre>
 * StringUtils.capitalize(null)  = null
 * StringUtils.capitalize(&quot;&quot;)    = &quot;&quot;
 * StringUtils.capitalize(&quot;cat&quot;) = &quot;Cat&quot;
 * StringUtils.capitalize(&quot;cAt&quot;) = &quot;CAt&quot;
 * </pre>
 * 
 * @param word
 *            ??
 * @return ???
 * @see org.apache.commons.lang3.StringUtils#swapCase(String)
 * @see org.apache.commons.lang3.StringUtils#capitalize(String)
 */
public static final String firstCharToUpperCase(String word) {
    return StringUtils.capitalize(word);
}