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:info.magnolia.integrationtests.uitest.SecurityAppUITest.java

/**
 * Renames existing user.//from  www .  j a va2 s  .c o m
 */
private void renameSecurityAppItem(String itemTypeCaption, String itemName, String newItemName) {
    refreshTreeView();
    if (!isTreeTableItemSelected(itemName)) {
        getTreeTableItem(itemName).click();
    }
    getActionBarItem(getEditItemActionName(itemTypeCaption)).click();
    waitUntil(dialogIsOpen(StringUtils.capitalize(itemTypeCaption)));

    getDialogInputByLabel(getItemNameFieldLabel(itemTypeCaption)).clear();
    sendKeysToDialogField(getItemNameFieldLabel(itemTypeCaption), newItemName);

    delay("Let the name change propagate");
    getDialogCommitButton().click();

    waitUntil(dialogIsClosed(StringUtils.capitalize(itemTypeCaption)));
}

From source file:info.magnolia.integrationtests.uitest.SecurityAppUITest.java

private String getItemNameFieldLabel(String itemTypeId) {
    return StringUtils.capitalize(itemTypeId) + " name";
}

From source file:knowledgeMiner.mining.SentenceParserHeuristic.java

public static synchronized Parse parseLine(String cleanSentence) {
    Parse parse = null;//  w ww.  jav  a2s .  c o m
    while (parse == null) {
        parse = OpenNLP.parseLine(cleanSentence);
        // Could not parse
        if (parse.getType().equals("INC")) {
            try {
                IOManager.getInstance().writeFirstSentence(-1, cleanSentence);
            } catch (IOException e) {
                e.printStackTrace();
            }

            // Simplify the sentence
            for (Pattern p : SENTENCE_SIMPLIFIER) {
                String simplifiedSentence = p.matcher(cleanSentence).replaceFirst("");
                // Replace the clean sentence
                if (!simplifiedSentence.equals(cleanSentence)) {
                    cleanSentence = StringUtils.capitalize(simplifiedSentence);
                    parse = null;
                    break;
                }
            }
        }
    }
    return parse;
}

From source file:info.magnolia.security.app.dialog.field.WorkspaceAccessFieldFactory.java

protected void openChooseDialog(final TextField textField) {
    final ConfiguredChooseDialogDefinition def = new ConfiguredChooseDialogDefinition();
    final ConfiguredJcrContentConnectorDefinition contentConnectorDefinition = new ConfiguredJcrContentConnectorDefinition();
    contentConnectorDefinition.setWorkspace(getFieldDefinition().getWorkspace());
    contentConnectorDefinition.setRootPath("/");
    contentConnectorDefinition.setDefaultOrder(ModelConstants.JCR_NAME);
    // node types
    contentConnectorDefinition.setNodeTypes(resolveNodeTypes());
    def.setContentConnector(contentConnectorDefinition);

    final WorkbenchDefinition wbDef = resolveWorkbenchDefinition();
    final WorkbenchFieldDefinition fieldDef = new WorkbenchFieldDefinition();
    fieldDef.setWorkbench(wbDef);//from   w ww . j  av a 2  s .c o m
    def.setField(fieldDef);

    // create chooseDialogComponentProvider and get new instance of presenter from there
    ComponentProvider chooseDialogComponentProvider = ChooseDialogComponentProviderUtil
            .createChooseDialogComponentProvider(def, componentProvider);
    workbenchChooseDialogPresenter = chooseDialogComponentProvider.newInstance(def.getPresenterClass(),
            chooseDialogComponentProvider);

    // Define selected ItemId

    ChooseDialogView chooseDialogView = workbenchChooseDialogPresenter.start(new ChooseDialogCallback() {
        @Override
        public void onItemChosen(String actionName, Object value) {
            try {
                if (value instanceof JcrItemId) {
                    JcrItemId jcrItemId = (JcrItemId) value;
                    textField.setValue(JcrItemUtil.getJcrItem(jcrItemId).getPath());
                } else {
                    textField.setValue("/");
                }
            } catch (RepositoryException e) {
                log.error("Failed to read chosen node", e);
            }
        }

        @Override
        public void onCancel() {
        }
    }, def, uiContext, textField.getValue());
    chooseDialogView.setCaption(StringUtils.capitalize(getFieldDefinition().getWorkspace()));
}

From source file:info.magnolia.integrationtests.uitest.SecurityAppUITest.java

/**
 * Adds arbitrary security app item (user/system user/group/role).
 *//*  www .j  a  v  a  2s .com*/
private void addSecurityAppItem(String itemTypeCaption, String itemName) {
    getEnabledActionBarItem(getAddItemActionName(itemTypeCaption)).click();
    waitUntil(dialogIsOpen(StringUtils.capitalize(itemTypeCaption)));

    sendKeysToDialogField(getItemNameFieldLabel(itemTypeCaption), itemName);

    getDialogCommitButton().click();
    waitUntil(dialogIsClosed(StringUtils.capitalize(itemTypeCaption)));

    // de-select created item
    if (isTreeTableItemSelected(itemName)) {
        getTreeTableItem(itemName).click();
    }
}

From source file:com.cryart.sabbathschool.viewmodel.SSReadingViewModel.java

public String getLessonInterval() {
    if (ssLessonInfo != null) {
        String startDateOut = DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT_OUTPUT).print(DateTimeFormat
                .forPattern(SSConstants.SS_DATE_FORMAT).parseLocalDate(ssLessonInfo.lesson.start_date));

        String endDateOut = DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT_OUTPUT).print(DateTimeFormat
                .forPattern(SSConstants.SS_DATE_FORMAT).parseLocalDate(ssLessonInfo.lesson.end_date));

        return StringUtils.capitalize(startDateOut) + " - " + StringUtils.capitalize(endDateOut);
    }//w w w.  j  av  a 2  s .c o  m
    return "";
}

From source file:com.google.dart.engine.services.internal.correction.CorrectionUtils.java

/**
 * @return the possible names for variable with initializer of the given {@link StringLiteral}.
 *///from ww  w  .j av a  2s.co  m
public static String[] getVariableNameSuggestions(String text, Set<String> excluded) {
    // filter out everything except of letters and white spaces
    {
        CharMatcher matcher = CharMatcher.JAVA_LETTER.or(CharMatcher.WHITESPACE);
        text = matcher.retainFrom(text);
    }
    // make single camel-case text
    {
        String[] words = StringUtils.split(text);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < words.length; i++) {
            String word = words[i];
            if (i > 0) {
                word = StringUtils.capitalize(word);
            }
            sb.append(word);
        }
        text = sb.toString();
    }
    // split camel-case into separate suggested names
    Set<String> res = Sets.newLinkedHashSet();
    addAll(excluded, res, getVariableNameSuggestions(text));
    return res.toArray(new String[res.size()]);
}

From source file:com.github.dozermapper.core.util.ReflectionUtils.java

/**
 * Finds non-standard setters {@link PropertyUtils#getPropertyDescriptors} does not find.
 * The non-standard setters include://from  www.  j  ava  2 s  . c  o m
 * <ul>
 * <li> Setters that return something instead of {@code void}</li>
 * <li> Setters that take a wrapper argument (e.g. Boolean) when the field is of primitive type (e.g. boolean) - or the other way around.
 * </ul>
 *
 * @param clazz     The class to find non-standard setters from
 * @param fieldName The field to find a non-standard setter for
 * @return The non-standard setter or {@code null}
 */
public static Method getNonStandardSetter(Class<?> clazz, String fieldName) {
    Field field;

    try {
        field = getFieldFromBean(clazz, fieldName);
    } catch (MappingException me) {
        return null;
    }

    String methodName = "set" + StringUtils.capitalize(fieldName);

    for (Method method : clazz.getMethods()) {
        if (isNonVoidSetter(method, methodName) || isAutoboxingSetter(method, methodName, field)) {
            return method;
        }
    }

    return null;
}

From source file:de.escalon.hypermedia.spring.de.escalon.hypermedia.spring.jackson.LinkListSerializer.java

private void writePossiblePropertyValues(JsonGenerator jgen, String currentVocab,
        ActionInputParameter actionInputParameter, Object[] possiblePropertyValues) throws IOException {
    // Enable the following to list possible values.
    // Problem: how to express individuals only for certain hydra:options
    // not all hydra:options should be taken as uris, sometimes they might be just literals
    // how to make that clear to the client?
    // maybe we must write them out for options
    //        if (possiblePropertyValues.length > 0) {
    //            jgen.writeArrayFieldStart("hydra:option");
    ////from w w  w.  j av a2  s . c  o  m
    //            for (Object possibleValue : possiblePropertyValues) {
    //                // TODO: apply "hydra:option" : { "@type": "@vocab"} to context for enums
    //                writeScalarValue(jgen, possibleValue, actionInputParameter.getParameterType());
    //            }
    //            jgen.writeEndArray();
    //        }

    if (actionInputParameter.isArrayOrCollection()) {
        jgen.writeBooleanField(getPropertyOrClassNameInVocab(currentVocab, "multipleValues",
                JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:"), true);
    }

    //  valueRequired (hard to say, using @Access on Event is for all update requests - or make
    //     specific request beans for different
    //     purposes rather than always passing an instance of e.g. Event?)
    //       -> update is a different use case than create - or maybe have an @Requires("eventStatus")
    //          annotation alongside requestBody to tell which attributes are required or writable, and use Requires over
    //          bean structure, where ctor with least length of args is required and setters are supported
    //          but optional? The bean structure does say what is writable for updates, but not what is required for creation. Right now setters are supportedProperties. For creation we would have to add constructor arguments as supportedProperties.
    //  (/) defaultValue (pre-filled value, e.g. list of selected items for option)
    //  valueName (for iri templates only)
    //  (/) readonlyValue (true for final public field or absence of setter, send fixed value like hidden field?) -> use hydra:readable, hydra:writable
    //  (/) multipleValues
    //  (/) valueMinLength
    //  (/) valueMaxLength
    //  (/) valuePattern
    //  minValue (DateTime support)
    //  maxValue (DateTime support)
    //  (/) stepValue
    final Map<String, Object> inputConstraints = actionInputParameter.getInputConstraints();

    if (actionInputParameter.hasCallValue()) {
        if (actionInputParameter.isArrayOrCollection()) {
            Object[] callValues = actionInputParameter.getCallValues();
            Class<?> componentType = callValues.getClass().getComponentType();
            // only write defaultValue for array of scalars
            if (DataType.isScalar(componentType)) {
                jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "defaultValue",
                        JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:"));
                jgen.writeStartArray();
                for (Object callValue : callValues) {
                    writeScalarValue(jgen, callValue, componentType);
                }
                jgen.writeEndArray();
            }
        } else {
            jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, "defaultValue",
                    JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:"));

            writeScalarValue(jgen, actionInputParameter.getCallValueFormatted(),
                    actionInputParameter.getNestedParameterType());
        }
    }

    if (!inputConstraints.isEmpty()) {
        final List<String> keysToAppendValue = Arrays.asList(ActionInputParameter.MAX, ActionInputParameter.MIN,
                ActionInputParameter.STEP);
        for (String keyToAppendValue : keysToAppendValue) {
            final Object constraint = inputConstraints.get(keyToAppendValue);
            if (constraint != null) {
                jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab, keyToAppendValue + "Value",
                        JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:"));
                jgen.writeNumber(constraint.toString());
            }
        }

        final List<String> keysToPrependValue = Arrays.asList(ActionInputParameter.MAX_LENGTH,
                ActionInputParameter.MIN_LENGTH, ActionInputParameter.PATTERN);
        for (String keyToPrependValue : keysToPrependValue) {
            final Object constraint = inputConstraints.get(keyToPrependValue);
            if (constraint != null) {
                jgen.writeFieldName(getPropertyOrClassNameInVocab(currentVocab,
                        "value" + StringUtils.capitalize(keyToPrependValue),
                        JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:"));
                if (ActionInputParameter.PATTERN.equals(keyToPrependValue)) {
                    jgen.writeString(constraint.toString());
                } else {
                    jgen.writeNumber(constraint.toString());
                }
            }
        }

    }

}

From source file:com.cryart.sabbathschool.viewmodel.SSReadingViewModel.java

public String formatDate(String date, String DateFormatOutput) {
    return StringUtils.capitalize(DateTimeFormat.forPattern(DateFormatOutput)
            .print(DateTimeFormat.forPattern(SSConstants.SS_DATE_FORMAT).parseLocalDate(date)));
}