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:com.adobe.cq.wcm.core.components.internal.models.v1.form.ButtonImpl.java

@Override
public String getTitle() {
    if (StringUtils.isBlank(this.title)) {
        this.title = (i18n != null ? i18n.getVar(StringUtils.capitalize(this.typeString))
                : StringUtils.capitalize(this.typeString));
    }//  w ww. ja  v a2s.c o m
    return this.title;
}

From source file:info.magnolia.configuration.app.overview.data.DefinitionProviderId.java

@Override
public Map<String, Object> getProperties() {
    final Map<String, Object> result = Maps.newHashMap();
    result.put(ConfigConstants.TITLE_PID, getName());
    result.put(ConfigConstants.MODULE_PID, provider.getMetadata().getModule());
    final String type = String.valueOf(provider.getMetadata().getType().name());
    result.put(ConfigConstants.TYPE_PID, StringUtils.capitalize(type.toLowerCase()));
    result.put(ConfigConstants.ORIGIN_PID, originName);

    if (!getValue().isValid()) {
        result.put(ConfigConstants.VALUE_PID, Joiner.on(" ").join(getValue().getErrorMessages()));
    }//from  w  w w.  j  a v a2  s.  c  om
    return result;
}

From source file:ch.cyberduck.core.AbstractExceptionMappingService.java

public StringBuilder append(final StringBuilder buffer, final String message) {
    final StringAppender appender = new StringAppender(buffer);
    appender.append(StringUtils.capitalize(message));
    return buffer;
}

From source file:com.moto.miletus.application.tabs.CommandsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_commands);

    if (!(Thread.getDefaultUncaughtExceptionHandler() instanceof CustomExceptionHandler)) {
        Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(this));
    }/* ww w.j  a  va 2s  .  c om*/

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);

    final Bundle state = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
    mComponent = state.getParcelable(Strings.EXTRA_KEY_DEVICE_COMPONENT);
    mDevice = state.getParcelable(Strings.EXTRA_KEY_DEVICE);
    if (mDevice == null || mComponent == null) {
        throw new IllegalArgumentException("Error in intent extra");
    }

    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
        actionBar.setTitle(StringUtils.capitalize(
                mDevice.getDevice().getName().replace(com.moto.miletus.utils.Strings.mSearchName, "")));
        actionBar.setSubtitle(StringUtils.capitalize(getComponent().getTraitName().replace("_", "")));
    }
}

From source file:com.github.dozermapper.core.converters.JAXBElementConverter.java

/**
 * Convert the specified input object into an output object of the
 * specified type.//from   w w  w  .j av  a2s.c o  m
 *
 * @param type  Data type to which this value should be converted
 * @param value The input value to be converted
 * @return The converted value
 * @throws org.apache.commons.beanutils.ConversionException if conversion cannot be performed successfully
 */
@Override
public Object convert(Class type, Object value) {

    Object result;
    Object factory = objectFactory(destObjClass, beanContainer);
    Class<?> factoryClass = factory.getClass();
    Class<?> destClass = value.getClass();
    Class<?> valueClass = value.getClass();

    String methodName = "create" + destObjClass.substring(destObjClass.lastIndexOf(".") + 1)
            + StringUtils.capitalize(destFieldName);
    Method method = null;
    try {
        method = ReflectionUtils.findAMethod(factoryClass, methodName, beanContainer);
        Class<?>[] parameterTypes = method.getParameterTypes();
        for (Class<?> parameterClass : parameterTypes) {
            if (!valueClass.equals(parameterClass)) {
                destClass = parameterClass;
                break;
            }
        }

        Class<?>[] paramTypes = { destClass };
        method = ReflectionUtils.getMethod(factoryClass, methodName, paramTypes);
    } catch (NoSuchMethodException e) {
        MappingUtils.throwMappingException(e);
    }

    Object param = value;
    Converter converter;
    if (java.util.Date.class.isAssignableFrom(valueClass) && !destClass.equals(XMLGregorianCalendar.class)) {
        converter = new DateConverter(dateFormat);
        param = converter.convert(destClass, param);
    } else if (java.util.Calendar.class.isAssignableFrom(valueClass)
            && !destClass.equals(XMLGregorianCalendar.class)) {
        converter = new CalendarConverter(dateFormat);
        param = converter.convert(destClass, param);
    } else if (XMLGregorianCalendar.class.isAssignableFrom(valueClass)
            || XMLGregorianCalendar.class.isAssignableFrom(destClass)) {
        converter = new XMLGregorianCalendarConverter(dateFormat);
        param = converter.convert(destClass, param);
    }

    Object[] paramValues = { param };
    result = ReflectionUtils.invoke(method, factory, paramValues);
    return result;
}

From source file:com.github.viktornar.task.PrintTask.java

private String getCommand(Atlas atlas, int row, int column) {
    String _hostname = DEFAULT_HOSTNAME;
    String _contextPath = DEFAULT_CONTEXT_PATH;
    String _port = DEFAULT_PORT;/*from   ww w  .ja v a2 s .  c o  m*/

    if (hostname != null) {
        _hostname = hostname;
    }

    if (contextPath != null) {
        _contextPath = contextPath;
    }

    if (port != null) {
        _port = port;
    }

    return String.format(Locale.US, DEFAULT_PRINT_CMD, StringUtils.capitalize(atlas.getSize()),
            StringUtils.capitalize(atlas.getOrientation()), _hostname, _port, _contextPath,
            atlas.getExtent().getXmin(), atlas.getExtent().getYmin(), atlas.getExtent().getXmax(),
            atlas.getExtent().getYmax(), atlas.getSize(), atlas.getOrientation(), atlas.getAtlasFolder(),
            atlas.getAtlasName(), row, column);
}

From source file:com.ykun.commons.utils.excel.ExcelUtils.java

/**
 * xlsheaders/*from w  w w . j a v a2  s .com*/
 *
 * @param list    the list
 * @param headers the headers
 * @param out     the out
 */
public static <T> void export(List<T> list, List<String> headers, OutputStream out) {
    // ?
    if (list == null || list.size() == 0) {
        return;
    }

    try {
        Workbook workbook = new XSSFWorkbook(); // XSSFWorkbook
        Sheet sheet = workbook.createSheet(); // ?Sheet

        // ?
        int rowNo = 0;
        CellStyle headerStyle = createHeaderStyle(workbook);
        if (headers != null && headers.size() > 0) {
            Row row = sheet.createRow(rowNo++);
            for (int i = 0; i < headers.size(); i++) {
                Cell cell = row.createCell(i);
                cell.setCellStyle(headerStyle);
                cell.setCellValue(headers.get(i));
            }
        }

        // ?
        CellStyle normalStyle = createNormalStyle(workbook);
        for (T t : list) {
            Row row = sheet.createRow(rowNo++);
            Field[] fields = t.getClass().getDeclaredFields();
            int column = 0;
            for (int i = 0; i < fields.length; i++) {
                Object value;
                Field field = fields[i];
                ExcelField excelField = field.getAnnotation(ExcelField.class);
                if (excelField != null && !excelField.ignore()) {
                    String methodName = PREFIX_GETTER + StringUtils.capitalize(field.getName()); // get???getisEnable?
                    Method method = t.getClass().getMethod(methodName, new Class[] {});
                    value = method.invoke(t, new Object[] {});
                } else if (excelField != null && excelField.ignore()) {
                    continue;
                } else {
                    String methodName = PREFIX_GETTER + StringUtils.capitalize(field.getName()); // get???getisEnable?
                    Method method = t.getClass().getMethod(methodName, new Class[] {});
                    value = method.invoke(t, new Object[] {});
                }
                row.setRowStyle(normalStyle);
                addCell(row, column++, value, excelField);
            }
        }
        workbook.write(out);
    } catch (Exception e) {
        logger.error("Export error:", e);
        throw new RuntimeException(e);
    }
}

From source file:forge.game.mana.ManaPool.java

/**
 * <p>//  w ww. ja  v  a2s . co m
 * willManaBeLostAtEndOfPhase.
 * 
 * @return - whether floating mana will be lost if the current phase ended right now
 * </p>
 */
public final boolean willManaBeLostAtEndOfPhase() {
    if (floatingMana.isEmpty()
            || owner.getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.manapoolsDontEmpty)
            || owner.hasKeyword("Convert unused mana to Colorless")) {
        return false;
    }

    int safeMana = 0;
    for (final byte c : MagicColor.WUBRG) {
        final String captName = StringUtils.capitalize(MagicColor.toLongString(c));
        if (owner.hasKeyword(captName + " mana doesn't empty from your mana pool as steps and phases end.")) {
            safeMana += getAmountOfColor(c);
        }
    }

    if (totalMana() == safeMana) {
        return false; //won't lose floating mana if all mana is of colors that aren't going to be emptied
    }
    return true;
}

From source file:com.thoughtworks.go.config.exceptions.EntityType.java

public String notFoundMessage(String id) {
    return format("%s %s '%s' was not found!", StringUtils.capitalize(this.entityType),
            this.nameOrId.descriptor, id);
}

From source file:com.neatresults.mgnltweaks.ui.action.AddBookmarkAction.java

@Override
public void execute() throws ActionExecutionException {
    try {//  www.j  a  v  a2s.  c om
        final String path = item.getJcrItem().getPath();

        Session session = MgnlContext.getJCRSession("config");
        Node bar = NodeUtil.createPath(session.getNode(
                "/modules/neat-tweaks-developers/apps/neatconfiguration/subApps/browser/actionbar/sections/folders/groups"),
                "bookmarksActions/items", NodeTypes.ContentNode.NAME);
        String name = "bkmk" + StringUtils.capitalize(item.getJcrItem().getName());
        bar.addNode(name, NodeTypes.ContentNode.NAME);
        Node actions = session
                .getNode("/modules/neat-tweaks-developers/apps/neatconfiguration/subApps/browser/actions");
        Node action = actions.addNode(name, NodeTypes.ContentNode.NAME);
        action.setProperty("extends", "../manageBookmarks");
        action.setProperty("icon", "icon-favorites");
        action.setProperty("path", path);
        action.setProperty("label", item.getJcrItem().getName());
        session.save();
        uiContext.openConfirmation(MessageStyleTypeEnum.INFO, "Wanna wait?",
                "To add a bookmark, one need to refresh the app, to refresh the app, one must kill it. To make this harder, observation kicks in only every 4 seconds so you got to wait for the refresh.",
                "OK, I'll take a nap", "no way", false, new ConfirmationCallback() {

                    @Override
                    public void onCancel() {
                        // just do nothing :D
                    }

                    @Override
                    public void onSuccess() {
                        try {
                            Thread.sleep(4000);
                        } catch (InterruptedException e) {
                            // meh
                        }
                        // stop the app
                        appController.stopCurrentApp();
                        // start the app and select item that was selected before stopping
                        BrowserLocation location = new BrowserLocation("neatconfiguration", "helperBrowser",
                                path + ":treeview:");
                        eventBus.fireEvent(new LocationChangedEvent(location));
                        // open selected node
                        ContentChangedEvent cce = new ContentChangedEvent(item.getItemId(), true);
                        eventBus.fireEvent(cce);
                    }

                });
    } catch (RepositoryException e) {
        log.error("Ooops, failed to add bookmark for {} with {}.", item, e.getMessage(), e);
    }

}