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:de.adorsys.forge.gwt.GWTFacet.java

public JavaResource createMVP(String name) {
    HashMap<String, Object> contextData = new HashMap<String, Object>();
    String nameClassPrefix = StringUtils.capitalize(name);
    name = name.toLowerCase();/*  w  ww  .ja  va2s.  co  m*/
    contextData.put("nameClassPrefix", nameClassPrefix);
    contextData.put("name", name);

    JavaResource presenter = createJavaSource("mvp/Presenter.java.vm", contextData);
    createJavaSource("mvp/View.java.vm", contextData);
    createResource("mvp/View.ui.xml.vm", String.format("%s/%sView.ui.xml", name, nameClassPrefix));
    return presenter;
}

From source file:eu.openanalytics.rsb.data.FileCatalogManager.java

@Override
@PreAuthorize("hasPermission(#applicationName, 'CATALOG_ADMIN')")
public Pair<PutCatalogFileResult, File> putCatalogFile(final CatalogSection catalogSection,
        final String applicationName, final String fileName, final InputStream in) throws IOException {
    final File catalogSectionDirectory = getCatalogSectionDirectory(catalogSection, applicationName);

    final File catalogFile = new File(catalogSectionDirectory, fileName);
    final boolean preExistingFile = catalogFile.isFile();

    final FileWriter fw = new FileWriter(catalogFile);
    IOUtils.copy(in, fw);/*from w  w w  .ja va 2s  .  co m*/
    IOUtils.closeQuietly(fw);

    final PutCatalogFileResult putCatalogFileResult = preExistingFile ? PutCatalogFileResult.UPDATED
            : PutCatalogFileResult.CREATED;

    getLogger().info(StringUtils.capitalize(putCatalogFileResult.toString().toLowerCase()) + " " + fileName
            + " in catalog section " + catalogSection.toString() + " as file: " + catalogFile);

    return Pair.of(putCatalogFileResult, catalogFile);
}

From source file:gov.nih.nci.caintegrator.web.action.analysis.biodbnet.BioDbNetSearchAction.java

/**
 * Generates the search inputs in the following manner if case insensitivity has been selected.
 *  - the original inputs/*from   w w  w  . j  a va 2  s  .  c  o  m*/
 *  - inputs are transformed to all upper case
 *  - inputs are transformed to all lower case
 *  - inputs are transformed to 1st letter upper case, all others lower case
 * @return the transformed input strings as comma separated values
 */
private Set<String> handleCaseSensitivity(SearchParameters searchParams) {
    Set<String> inputs = Sets.newTreeSet();
    if (searchParams.isCaseSensitiveSearch() || searchParams.getSearchType() == SearchType.GENE_ID) {
        CollectionUtils.addAll(inputs, StringUtils.split(searchParams.getInputValues(), ','));
        return inputs;
    }
    String[] splitInputs = StringUtils.split(searchParams.getInputValues(), ',');
    for (String input : splitInputs) {
        inputs.add(input);
        inputs.add(StringUtils.upperCase(input));
        inputs.add(StringUtils.lowerCase(input));
        inputs.add(StringUtils.capitalize(input));
    }
    return inputs;
}

From source file:io.proleap.cobol.asg.runner.impl.CobolParserRunnerImpl.java

protected String getCompilationUnitName(final File inputFile) {
    return StringUtils.capitalize(FilenameUtils.removeExtension(inputFile.getName()));
}

From source file:net.pms.util.GenericIcons.java

public DLNAThumbnailInputStream getGenericIcon(DLNAResource resource) {
    ImageFormat imageFormat = ImageFormat.JPEG;

    if (resource == null) {
        ImageIO.setUseCache(false);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {/*from  w  w  w. ja v  a2 s. co m*/
            ImageIOTools.imageIOWrite(genericUnknownIcon, imageFormat.toString(), out);
            return DLNAThumbnailInputStream.toThumbnailInputStream(out.toByteArray());
        } catch (IOException e) {
            LOGGER.warn("Unexpected error while generating generic thumbnail for null resource: {}",
                    e.getMessage());
            LOGGER.trace("", e);
            return null;
        }
    }

    IconType iconType = IconType.UNKNOWN;
    if (resource.getMedia() != null) {
        if (resource.getMedia().isAudio()) {
            iconType = IconType.AUDIO;
        } else if (resource.getMedia().isImage()) {
            iconType = IconType.IMAGE;
        } else if (resource.getMedia().isVideo()) {
            // FFmpeg parses images as video, try to rectify
            if (resource.getFormat() != null && resource.getFormat().isImage()) {
                iconType = IconType.IMAGE;
            } else {
                iconType = IconType.VIDEO;
            }
        }
    } else if (resource.getFormat() != null) {
        if (resource.getFormat().isAudio()) {
            iconType = IconType.AUDIO;
        } else if (resource.getFormat().isImage()) {
            iconType = IconType.IMAGE;
        } else if (resource.getFormat().isVideo()) {
            iconType = IconType.VIDEO;
        }
    }

    DLNAThumbnail image = null;
    cacheLock.lock();
    try {
        if (!cache.containsKey(imageFormat)) {
            cache.put(imageFormat, new HashMap<IconType, Map<String, DLNAThumbnail>>());
        }
        Map<IconType, Map<String, DLNAThumbnail>> typeCache = cache.get(imageFormat);

        if (!typeCache.containsKey(iconType)) {
            typeCache.put(iconType, new HashMap<String, DLNAThumbnail>());
        }
        Map<String, DLNAThumbnail> imageCache = typeCache.get(iconType);

        String label = getLabelFromImageFormat(resource.getMedia());
        if (label == null) {
            label = getLabelFromFormat(resource.getFormat());
        }
        if (label == null) {
            label = getLabelFromContainer(resource.getMedia());
        }
        if (label != null && label.length() < 5) {
            label = label.toUpperCase(Locale.ROOT);
        } else if (label != null && label.toLowerCase(Locale.ROOT).equals(label)) {
            label = StringUtils.capitalize(label);
        }

        if (imageCache.containsKey(label)) {
            return DLNAThumbnailInputStream.toThumbnailInputStream(imageCache.get(label));
        }

        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Creating generic {} thumbnail for {} ({})", iconType.toString().toLowerCase(),
                    label.toUpperCase(), imageFormat);
        }

        try {
            image = addFormatLabelToImage(label, imageFormat, iconType);
        } catch (IOException e) {
            LOGGER.warn("Unexpected error while generating generic thumbnail for \"{}\": {}",
                    resource.getName(), e.getMessage());
            LOGGER.trace("", e);
        }

        imageCache.put(label, image);
    } finally {
        cacheLock.unlock();
    }

    return DLNAThumbnailInputStream.toThumbnailInputStream(image);
}

From source file:io.github.swagger2markup.markup.builder.internal.confluenceMarkup.ConfluenceMarkupBuilder.java

@Override
public MarkupDocBuilder block(String text, final MarkupBlockStyle style, String title,
        MarkupAdmonition admonition) {/*w  w  w. ja v  a2s  .co  m*/

    String block = BLOCK_STYLE.get(style);

    boolean admonitionBlock = block.equals(">ADMONITION_BLOCK");
    if (admonitionBlock) {
        block = ADMONITION_BLOCK_STYLE.get(admonition);
    }

    boolean supportTitle = false;
    if (block.endsWith(":")) {
        supportTitle = true;
        block = StringUtils.stripEnd(block, ":");
    }

    String titleString = null;
    if (admonition != null && !admonitionBlock) {
        titleString = StringUtils.capitalize(admonition.name().toLowerCase());
    }
    if (title != null) {
        titleString = (titleString == null ? "" : titleString + " | ") + title;
    }

    final String finalBlock = block;
    Markup blockMarkup = new Markup() {
        @Override
        public String toString() {
            return String.format("{%s}", finalBlock);
        }
    };

    if (!supportTitle) {
        if (titleString != null)
            documentBuilder.append(titleString).append(" : ").append(newLine);
        delimitedBlockText(blockMarkup, text);
    } else {
        final String finalTitleString = titleString;
        delimitedBlockText(new Markup() {
            @Override
            public String toString() {
                if (finalTitleString == null)
                    return String.format("{%s}", finalBlock);
                else
                    return String.format("{%s:title=%s}", finalBlock, finalTitleString);
            }
        }, text, blockMarkup);
    }

    return this;
}

From source file:com.handany.base.generator.Generator.java

private static String delDash(String str) {
    String lowerCaseStr = str.toLowerCase();
    String[] noDashArray = lowerCaseStr.split("_");
    StringBuilder sb = new StringBuilder(noDashArray[0]);

    for (int i = 1; i < noDashArray.length; i++) {
        sb.append(StringUtils.capitalize(noDashArray[i]));
    }//from www.  ja  va 2 s . c  o m

    return sb.toString();
}

From source file:be.nille.generator.parser.ParserService.java

private String upperCaseFirst(String string) {
    return StringUtils.capitalize(string);

}

From source file:at.gridtec.lambda4j.generator.processors.impl.MethodProcessor.java

/**
 * A helper method to append {@link #AS_IDENTIFIER} to given {@link StringBuilder}. This happens only, if the given
 * lambda has a primitive return type.//  w w  w.ja v a 2s.  com
 *
 * @param builder The {@code StringBuilder} to which to append the identifier and the primitive lambda return type
 * name
 * @param lambda The lambda to be used for checking
 * @param lambdaReturnType The return type to be checked for primitiveness
 * @throws NullPointerException If one of the given arguments is {@code null}
 * @implSpec The implementation required the return type be primitive. Only if this occasion is met, the identifier
 * will be appended.
 */
private void asIdentifier(@Nonnull final StringBuilder builder, @Nonnull final LambdaEntity lambda,
        @Nonnull final TypeEntity lambdaReturnType) {
    Objects.requireNonNull(builder);
    Objects.requireNonNull(lambda);
    Objects.requireNonNull(lambdaReturnType);
    if (LambdaUtils.isPrimitiveType(lambdaReturnType)) {
        builder.append(AS_IDENTIFIER);
        builder.append(StringUtils.capitalize(lambdaReturnType.getTypeSimpleName()));
    }
}

From source file:io.openmessaging.rocketmq.utils.BeanUtils.java

public static <T> T populate(final KeyValue properties, final T obj) {
    Class<?> clazz = obj.getClass();
    try {//from ww w.  j a  v a 2  s.  c om

        final Set<String> keySet = properties.keySet();
        for (String key : keySet) {
            String[] keyGroup = key.split("[\\._]");
            for (int i = 0; i < keyGroup.length; i++) {
                keyGroup[i] = keyGroup[i].toLowerCase();
                keyGroup[i] = StringUtils.capitalize(keyGroup[i]);
            }
            String beanFieldNameWithCapitalization = StringUtils.join(keyGroup);
            try {
                setProperties(clazz, obj, "set" + beanFieldNameWithCapitalization, properties.getString(key));
            } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
                //ignored...
            }
        }
    } catch (RuntimeException e) {
        log.warn("Error occurs !", e);
    }
    return obj;
}