Example usage for org.apache.commons.lang StringUtils uncapitalize

List of usage examples for org.apache.commons.lang StringUtils uncapitalize

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils uncapitalize.

Prototype

public static String uncapitalize(String str) 

Source Link

Document

Uncapitalizes a String changing the first letter to title case as per Character#toLowerCase(char) .

Usage

From source file:net.sourceforge.fenixedu.presentationTier.Action.operator.OperatorValidatePartyContactsDA.java

@Atomic
private void sendPhysicalAddressValidationEmail(PhysicalAddressValidation physicalAddressValidation) {
    final Person person = (Person) physicalAddressValidation.getPartyContact().getParty();
    final String subject = BundleUtil.getString(Bundle.MANAGER,
            "label.contacts.validation.operator.email.subject", Unit.getInstitutionAcronym());
    final String state = StringUtils.uncapitalize(physicalAddressValidation.getState().getPresentationName());
    String body = BundleUtil.getString(Bundle.MANAGER, "label.contacts.validation.operator.email.body",
            physicalAddressValidation.getPartyContact().getPresentationValue(), state);
    final String description = physicalAddressValidation.getDescription();
    if (!StringUtils.isEmpty(description)) {
        body += "\n" + description;
    }/*w  w w .j  a v a 2  s. c o m*/
    final String sendingEmail = person.getEmailForSendingEmails();
    if (!StringUtils.isEmpty(sendingEmail)) {
        new Message(Bennu.getInstance().getSystemSender(), Collections.EMPTY_LIST, Collections.EMPTY_LIST,
                subject, body, sendingEmail);
    }
}

From source file:ch.algotrader.esper.SpringServiceResolver.java

@Override
public void resolve(final EPStatement statement, final String subscriberExpression) {

    if (StringUtils.isBlank(subscriberExpression)) {
        throw new IllegalArgumentException("Subscriber is empty");
    }//www  .j av a  2  s.  c o m

    PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("${", "}", ",", false);
    String s = placeholderHelper.replacePlaceholders(subscriberExpression, name -> {
        if (name.equalsIgnoreCase("strategyName")) {
            return this.strategyName;
        } else {
            return this.configParams.getString(name, "null");
        }
    });

    final Matcher matcher = SUBSCRIBER_NOTATION.matcher(s);
    if (matcher.matches()) {
        // New subscriber notation
        final String beanName = matcher.group(1);
        final String beanMethod = matcher.group(3);
        Object bean = this.applicationContext.getBean(beanName);
        try {
            statement.setSubscriber(bean, beanMethod);
        } catch (EPSubscriberException ex) {
            throw new SubscriberResolutionException("Subscriber expression '" + subscriberExpression
                    + "' could not be resolved to a service method", ex);
        }
    } else {
        // Assuming to be a fully qualified class name otherwise
        try {
            Class<?> cl = Class.forName(s);
            statement.setSubscriber(cl.newInstance());
        } catch (Exception e) {
            // Old notation for backward compatibility
            String serviceName = StringUtils.substringBeforeLast(s, ".");
            if (serviceName.contains(".")) {
                serviceName = StringUtils.remove(StringUtils.remove(
                        StringUtils.uncapitalize(StringUtils.substringAfterLast(serviceName, ".")), "Base"),
                        "Impl");
            }
            String beanMethod = StringUtils.substringAfterLast(s, ".");
            Object bean = this.applicationContext.getBean(serviceName);
            statement.setSubscriber(bean, beanMethod);
        }
    }
}

From source file:net.servicefixture.fitnesse.FixtureTemplateCreator.java

/**
 * Generates the parameter name based on the type. If the type is an array
 * type, return the array syntaxed parameter name.
 *
 * @param class1/*from   w ww .j a  va2 s  .  co m*/
 * @return
 */
private String getParameterName(Class type) {
    //Get the object type if it is the collection type.
    Class objectType = CollectionBuilderFactory.getElementType(type);
    int index = objectType.getName().lastIndexOf(".");
    String varName = objectType.getName().substring(index + 1);
    varName = StringUtils.uncapitalize(varName);
    if (CollectionBuilderFactory.isCollectionType(type)) {
        varName = varName + "[0]" + ReflectionUtils.getExtraMultiDimensionalArraySuffix(type);
    }
    return varName;
}

From source file:airlift.util.AirliftUtil.java

/**
 * Lower the first character.//from w  w  w.  j  a va  2  s .c o  m
 *
 * @param _string the _string
 * @return the string
 */
public static String lowerTheFirstCharacter(String _string) {
    return StringUtils.uncapitalize(_string);
}

From source file:net.servicefixture.util.ReflectionUtils.java

/**
 * Gets the attributes of a type.//from   w w  w  .  j  a  v  a  2s. c o m
 * 
 * @param type
 * @return
 */
public static Map<String, Class> getAttributes(Class type) {
    Map<String, Class> attributes = new HashMap<String, Class>();
    Method[] methods = type.getMethods();
    for (int i = 0; i < methods.length; i++) {
        if (methods[i].getName().startsWith("get") && !"getClass".equals(methods[i].getName())
                && methods[i].getName().length() > 3 && methods[i].getParameterTypes().length == 0) {
            String attributeName = StringUtils.uncapitalize(methods[i].getName().substring(3));
            Class returnType = methods[i].getReturnType();
            if (CollectionBuilderFactory.isCollectionType(returnType)) {
                attributeName = attributeName + "[0]" + getExtraMultiDimensionalArraySuffix(returnType);
                returnType = CollectionBuilderFactory.getElementType(returnType);
            }
            attributes.put(attributeName, returnType);
        }
    }
    return attributes;
}

From source file:com.haulmont.cuba.gui.CompanionDependencyInjector.java

private void doInjection(AnnotatedElement element, Class annotationClass) {
    Class<?> type;/*from  w  w  w. ja va  2  s  .co  m*/
    String name = null;
    if (annotationClass == Named.class)
        name = element.getAnnotation(Named.class).value();
    else if (annotationClass == Resource.class)
        name = element.getAnnotation(Resource.class).name();

    if (element instanceof Field) {
        type = ((Field) element).getType();
        if (StringUtils.isEmpty(name))
            name = ((Field) element).getName();
    } else if (element instanceof Method) {
        Class<?>[] types = ((Method) element).getParameterTypes();
        if (types.length != 1)
            throw new IllegalStateException("Can inject to methods with one parameter only");
        type = types[0];
        if (StringUtils.isEmpty(name)) {
            if (((Method) element).getName().startsWith("set"))
                name = StringUtils.uncapitalize(((Method) element).getName().substring(3));
            else
                name = ((Method) element).getName();
        }
    } else
        throw new IllegalStateException("Can inject to fields and setter methods only");

    Object instance = getInjectedInstance(type, name, element);
    if (instance == null) {
        log.warn("Unable to find an instance of type " + type + " named " + name);
    } else {
        assignValue(element, instance);
    }
}

From source file:hr.fer.zemris.vhdllab.platform.manager.editor.impl.AbstractEditor.java

@Override
public String getTitle() {
    String beanName = StringUtils.uncapitalize(metadata.getClass().getSimpleName());
    beanName = beanName.replace("Metadata", "");
    Object[] args = new Object[] { getFileName(), getProjectName() };
    return getMessage(beanName + ".title", args);
}

From source file:hr.fer.zemris.vhdllab.platform.manager.editor.impl.AbstractEditor.java

@Override
public String getCaption() {
    String beanName = StringUtils.uncapitalize(metadata.getClass().getSimpleName());
    beanName = beanName.replace("Metadata", "");
    String editableMessage;// ww  w  . j  ava  2s.com
    if (metadata.isEditable()) {
        editableMessage = container.getMessage("editor.editable.caption");
    } else {
        editableMessage = container.getMessage("editor.readonly.caption");
    }
    Object[] args = new Object[] { getFileName(), getProjectName(), editableMessage };
    return getMessage(beanName + ".caption", args);
}

From source file:com.smbtec.xo.tinkerpop.blueprints.impl.TinkerPopMetadataFactory.java

@Override
public EdgeMetadata createRelationMetadata(final AnnotatedElement<?> annotatedElement,
        final Map<Class<?>, TypeMetadata> metadataByType) {
    Edge relationAnnotation;//www .  j  a  va 2  s . c o  m
    if (annotatedElement instanceof PropertyMethod) {
        relationAnnotation = ((PropertyMethod) annotatedElement).getAnnotationOfProperty(Edge.class);
    } else {
        relationAnnotation = annotatedElement.getAnnotation(Edge.class);
    }
    String name = null;
    if (relationAnnotation != null) {
        final String value = relationAnnotation.value();
        if (!Edge.DEFAULT_VALUE.equals(value)) {
            name = value;
        }
    }
    if (name == null) {
        name = StringUtils.uncapitalize(annotatedElement.getName());
    }
    return new EdgeMetadata(name);
}

From source file:com.zuora.api.object.Dynamic.java

protected String toPropertyName(String name) {
    return StringUtils.uncapitalize(name);
}