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:org.beanfuse.model.EntityUtils.java

public static String getCommandName(Object obj) {
    String name = obj.getClass().getName();
    int dollar = name.indexOf('$');
    if (-1 != dollar) {
        name = name.substring(name.lastIndexOf('.') + 1, dollar);
    } else {/* w w w .  ja  v a2 s.com*/
        name = name.substring(name.lastIndexOf('.') + 1);
    }
    return StringUtils.uncapitalize(name);
}

From source file:org.beanfuse.struts2.route.impl.DefaultActionNameBuilder.java

/**
 * ?classprofilectl/action????<br>
 * profileuriStyle,????????<br>//from ww w.  j  a  v  a 2 s.c  om
 * ???.?URI?????<br>
 * ??URL,/
 * 
 * @param clazz
 * @return
 */
public String build(String className) {
    Profile profile = profileService.getProfile(className);
    StringBuilder sb = new StringBuilder();
    if (SHORT.equals(profile.getUriStyle())) {
        String simpleName = className.substring(className.lastIndexOf('.') + 1);
        sb.append(StringUtils.uncapitalize(
                simpleName.substring(0, simpleName.length() - profile.getActionSuffix().length())));
    } else if (SIMPLE.equals(profile.getUriStyle())) {
        sb.append(Convention.separator).append(profile.getInfix(className));
    } else if (SEO.equals(profile.getUriStyle())) {
        sb.append(Convention.separator).append(StringUtil.unCamel(profile.getInfix(className)));
    } else {
        throw new RuntimeException("unsupported uri style " + profile.getUriStyle());
    }
    if (null != profile.getUriExtension()) {
        sb.append('.').append(profile.getUriExtension());
    }
    return sb.toString();
}

From source file:org.beangle.model.util.EntityUtils.java

public static String getCommandName(Class<?> clazz) {
    String name = clazz.getName();
    return StringUtils.uncapitalize(name.substring(name.lastIndexOf('.') + 1));
}

From source file:org.beangle.model.util.EntityUtils.java

public static String getCommandName(Object obj) {
    String name = obj.getClass().getName();
    int dollar = name.indexOf('$');
    if (-1 == dollar) {
        name = name.substring(name.lastIndexOf('.') + 1);
    } else {/*w  ww . ja  va  2s.  co  m*/
        name = name.substring(name.lastIndexOf('.') + 1, dollar);
    }
    return StringUtils.uncapitalize(name);
}

From source file:org.beangle.struts2.convention.route.impl.DefaultActionBuilder.java

/**
 * ?classprofilectl/action????<br>
 * profileuriStyle,????????<br>/*from w  ww.  j  a va 2 s.c  om*/
 * ???.?URI?????<br>
 * ??URL,/
 * 
 * @param clazz
 * @return
 */
public Action build(String className) {
    Profile profile = profileService.getProfile(className);
    Action action = new Action();
    StringBuilder sb = new StringBuilder();
    // namespace
    sb.append(profile.getUriPath());
    if (Constants.SHORT_URI.equals(profile.getUriPathStyle())) {
        String simpleName = className.substring(className.lastIndexOf('.') + 1);
        sb.append(StringUtils.uncapitalize(
                simpleName.substring(0, simpleName.length() - profile.getActionSuffix().length())));
    } else if (Constants.SIMPLE_URI.equals(profile.getUriPathStyle())) {
        sb.append(profile.getInfix(className));
    } else if (Constants.SEO_URI.equals(profile.getUriPathStyle())) {
        sb.append(StrUtils.unCamel(profile.getInfix(className)));
    } else {
        throw new RuntimeException("unsupported uri style " + profile.getUriPathStyle());
    }
    action.path(sb.toString()).method(profile.getDefaultMethod()).extention(profile.getUriExtension());
    return action;
}

From source file:org.beangle.struts2.convention.route.Profile.java

public String getSimpleName(String className) {
    String postfix = getActionSuffix();
    String simpleName = className.substring(className.lastIndexOf('.') + 1);
    if (StringUtils.contains(simpleName, postfix)) {
        simpleName = StringUtils.uncapitalize(simpleName.substring(0, simpleName.length() - postfix.length()));
    } else {//from   www.  j ava 2 s. c om
        simpleName = StringUtils.uncapitalize(simpleName);
    }

    StringBuilder infix = new StringBuilder();
    infix.append(StringUtils.substringBeforeLast(className, "."));
    if (infix.length() == 0)
        return simpleName;
    infix.append('.');
    infix.append(simpleName);
    // .??/
    for (int i = 0; i < infix.length(); i++) {
        if (infix.charAt(i) == '.') {
            infix.setCharAt(i, '/');
        }
    }
    return infix.toString();
}

From source file:org.beangle.struts2.convention.route.Profile.java

/**
 * ???.?/<br>//from   w  ww . jav a 2s . co m
 * ?/
 * 
 * @param clazz
 * @param profile
 * @return
 */
public String getInfix(String className) {
    String postfix = getActionSuffix();
    String simpleName = className.substring(className.lastIndexOf('.') + 1);
    if (StringUtils.contains(simpleName, postfix)) {
        simpleName = StringUtils.uncapitalize(simpleName.substring(0, simpleName.length() - postfix.length()));
    } else {
        simpleName = StringUtils.uncapitalize(simpleName);
    }

    MatchInfo match = getCtlMatchInfo(className);
    StringBuilder infix = new StringBuilder(match.getReserved().toString());
    if (infix.length() > 0) {
        infix.append('.');
    }
    String remainder = StringUtils.substring(StringUtils.substringBeforeLast(className, "."),
            match.getStartIndex() + 1);
    if (remainder.length() > 0) {
        infix.append(remainder).append('.');
    }
    if (infix.length() == 0)
        return simpleName;
    infix.append(simpleName);

    // .??/
    for (int i = 0; i < infix.length(); i++) {
        if (infix.charAt(i) == '.') {
            infix.setCharAt(i, '/');
        }
    }
    return infix.toString();
}

From source file:org.beangle.struts2.view.component.Component.java

public <T> T getBean(Class<T> cls) {
    try {/*  w  w w .ja  v a  2  s.  c  om*/
        ApplicationContext ctx = WebApplicationContextUtils
                .getWebApplicationContext(ServletActionContext.getServletContext());
        String name = StringUtils.uncapitalize(StringUtils.substringAfterLast(cls.getName(), "."));
        @SuppressWarnings("unchecked")
        T t = (T) ctx.getBean(name);
        return t;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}

From source file:org.beangle.struts2.view.template.Theme.java

public static String getTemplateName(Class<?> clazz) {
    String name = defaultNames.get(clazz);
    if (null == name) {
        name = StringUtils.uncapitalize(clazz.getSimpleName());
        defaultNames.put(clazz, name);//from  w ww  .jav  a 2s.  c  o  m
    }
    return name;
}

From source file:org.betaconceptframework.astroboa.engine.definition.XSSchemaItem.java

private XSSchemaItem(String prefix, String url) {
    //Uncapitalize first letter
    xsSchemaItem = new ItemQNameImpl(prefix, url, StringUtils.uncapitalize(this.name()));
}