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:org.dbgl.util.searchengine.PouetSearchEngine.java

private List<WebProfile> extractSingleEntry(String html) {
    List<WebProfile> allEntries = new ArrayList<WebProfile>();

    int canonicalIndex = html.indexOf("<link rel=\"canonical\"");
    String url = extractNextHrefContent(html, canonicalIndex);

    int titleIdx = html.indexOf("<span id='title'>", canonicalIndex);
    String gameTitleData = extractNextContent(html, titleIdx, "<big>", "</big>");
    String title = StringUtils.capitalize(unescapeHtml(removeAllTags(gameTitleData)));

    String developerName = (html.indexOf("</big> by ", titleIdx) != -1)
            ? StringUtils.capitalize(extractNextContent(html, titleIdx, HTML_ANCHOR_OPEN, HTML_ANCHOR_CLOSE))
            : "";

    int platformIdx = html.indexOf("<td>platform :</td>", titleIdx);

    int categoryIdx = html.indexOf("<td>type :</td>", platformIdx);
    String category = StringUtils
            .capitalize(extractNextContent(html, categoryIdx, HTML_SPAN_OPEN, HTML_SPAN_CLOSE));

    int yearIdx = html.indexOf("<td>release date :</td>", categoryIdx);
    String dateValue = extractNextContent(html, yearIdx + 24, HTML_TD_OPEN, HTML_TD_CLOSE);
    String year = !dateValue.contains("n/a") ? StringUtils.right(dateValue, 4) : "";

    int scoreEndIdx = html.indexOf("<div id='alltimerank'>", yearIdx);
    int scoreStartIdx = html.lastIndexOf("&nbsp;", scoreEndIdx);
    int rank = 0;
    try {/*from  w ww . j a  va2 s . co  m*/
        String score = html.substring(scoreStartIdx + 6, scoreEndIdx);
        int l = score.indexOf("</li>");
        if (l != -1)
            score = score.substring(0, l);
        rank = (int) ((Double.parseDouble(score) + 1.0) * 50.0);
    } catch (Exception e) {
    }

    String details = html.substring(platformIdx, categoryIdx);
    platformIdx = details.indexOf("<span class='platform ");

    while (platformIdx != -1) {
        String platform = extractNextContent(details, platformIdx, HTML_SPAN_OPEN, HTML_SPAN_CLOSE);

        WebProfile gameEntry = new WebProfile();
        gameEntry.setTitle(title);
        gameEntry.setUrl(url);
        gameEntry.setPlatform(platform);
        gameEntry.setPublisherName("");
        gameEntry.setDeveloperName(developerName);
        gameEntry.setYear(year);
        gameEntry.setGenre(category);
        gameEntry.setRank(rank);
        gameEntry.setNotes("");
        allEntries.add(gameEntry);

        platformIdx = details.indexOf("<span class='platform ", platformIdx + 1);
    }

    return allEntries;
}

From source file:org.dozer.util.ReflectionUtils.java

public static Method getNonVoidSetter(Class<?> clazz, String fieldName) {
    String methodName = "set" + StringUtils.capitalize(fieldName);
    for (Method method : clazz.getMethods()) {
        if (method.getName().equals(methodName) && method.getParameterTypes().length == 1
                && method.getReturnType() != Void.TYPE) {
            return method;
        }/*from   ww  w  .j a  v  a2s  .  c om*/
    }
    return null;
}

From source file:org.dozer.util.ReflectionUtils.java

public static Method getSetter(Class<?> clazz, String fieldName) {
    String methodName = "set" + StringUtils.capitalize(fieldName);
    for (Method method : clazz.getMethods()) {
        if (method.getName().equals(methodName) && method.getParameterTypes().length == 1) {
            return method;
        }/*  w  ww.  j a  v a  2  s .c  om*/
    }
    return null;
}

From source file:org.eclipse.vorto.codegen.examples.coap.common.tasks.JavaFBOperationParamSetGeneratorTask.java

public JavaFBOperationParamSetGeneratorTask(String className, String javaFileExtension, String path,
        String classPackage, String... imports) {
    this.className = StringUtils.capitalize(className);
    this.javaFileExtension = javaFileExtension;
    this.path = path;
    this.classPackage = classPackage;
    this.imports = imports;
}

From source file:org.eclipse.vorto.codegen.examples.coap.common.tasks.JavaFBOperationParamSetGeneratorTask.java

@Override
public String getFileName(Operation im) {
    return StringUtils.capitalize(className) + javaFileExtension;
}

From source file:org.eclipse.vorto.codegen.examples.coap.common.tasks.JavaFBOperationReturnPrimitiveTypeWrapperGeneratorTask.java

public JavaFBOperationReturnPrimitiveTypeWrapperGeneratorTask(String className, String javaFileExtension,
        String path, String classPackage) {
    this.className = StringUtils.capitalize(className);
    this.javaFileExtension = javaFileExtension;
    this.path = path;
    this.classPackage = classPackage;
}

From source file:org.eclipse.vorto.codegen.examples.coap.common.tasks.JavaFBPropertyPrimitiveParamWrapperGeneratorTask.java

public JavaFBPropertyPrimitiveParamWrapperGeneratorTask(String className, String javaFileExtension, String path,
        String classPackage) {//from   w ww.  j  a v a  2 s .c o  m
    this.className = StringUtils.capitalize(className);
    this.javaFileExtension = javaFileExtension;
    this.path = path;
    this.classPackage = classPackage;
}

From source file:org.eclipse.vorto.codegen.examples.coap.common.tasks.JavaFBPropertyPrimitiveParamWrapperGeneratorTask.java

@Override
public String getFileName(Property im) {
    return StringUtils.capitalize(className) + javaFileExtension;
}

From source file:org.eclipse.vorto.codegen.examples.latex.tasks.LatexInformationModelGeneratorTask.java

@Override
public String getFileName(InformationModel im) {
    return StringUtils.capitalize(im.getName()) + markdownFileExtension;
}

From source file:org.eclipse.vorto.codegen.examples.webui.tasks.ModuleUtil.java

public static String getCamelCase(String string) {
    return StringUtils.capitalize(string);
}