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

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

Introduction

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

Prototype

public static String capitalize(String str) 

Source Link

Document

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

Usage

From source file:com.carteblanche.kwd.driver.KeywordDrivenDriver.java

public static void main(String[] args) {
    File[] listOfFiles;/*from w w  w .  ja  v a  2s. c o  m*/

    File folder = new File(testDirectory + testSuiteName + "/");
    String testSuiteName = folder.getName();
    testSuiteName = StringUtils
            .capitalize(StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(testSuiteName), ' '));
    listOfFiles = folder.listFiles();
    TestNGDriver testNGDriver = new TestNGDriver();

    int i = 0;
    for (File csv : listOfFiles) {
        KWDTestCase testCase = TestCaseParser.parse(csv, cvsSplitBy);
        testNGDriver.runTests(testCase, testSuiteName + i, folder.getName());
        i++;
    }

}

From source file:TasteOfThingsV1.java

 public static void main(String args[]) throws Exception {
   prepareData();/*  www  . ja  va2 s. c om*/

   HashBag myBag = new HashBag(testMap.values());

   System.err.println("How many Boxes? " + myBag.getCount("Boxes"));
   myBag.add("Boxes", 5);
   System.err.println("How many Boxes now? " + myBag.getCount("Boxes"));

   Method method =
     testBean.getClass().getDeclaredMethod("getTestMap", new Class[0]);
   HashMap reflectionMap =
     (HashMap)method.invoke(testBean, new Object[0]);
   System.err.println("The value of the 'squ' key using reflection: " +
     reflectionMap.get("squ"));

   String squ = BeanUtils.getMappedProperty(testBean, "testMap", "squ");
   squ = StringUtils.capitalize(squ);

   PropertyUtils.setMappedProperty(testBean, "testMap", "squ", squ);

   System.err.println("The value of the 'squ' key is: " +
     BeanUtils.getMappedProperty(testBean, "testMap", "squ"));

   String box = (String)testMap.get("box");
   String caps =
     Character.toTitleCase(box.charAt(0)) +
     box.substring(1, box.length());
   System.err.println("Capitalizing boxes by Java: " + caps);
}

From source file:com.rslakra.java.string.TestApacheStringUtils.java

public static void main(String args[]) {

    System.err.println(StringUtils.abbreviate("Take time off working", 0, 10));
    System.err.println(StringUtils.capitalize("vanderLust"));
    System.err.println(StringUtils.center("MTV", 7, '='));
    System.err.println(StringUtils.chomp("temperature", "ure"));
    System.err.println(StringUtils.chop("Dane"));
    System.err.println(StringUtils.contains("Dorothy", "oro"));
    System.err.println(StringUtils.containsNone("r u m t", new char[] { 'r', 'o' }));
    System.err.println(StringUtils.containsOnly("r u m t", new char[] { 'r', 'o' }));
    System.err.println(StringUtils.countMatches("arthur", "r"));
    System.err.println(StringUtils.deleteWhitespace("f f f f"));
    System.err.println(StringUtils.difference("govern", "government"));
    System.err.println(StringUtils.getLevenshteinDistance("govern", "government"));

}

From source file:com.mmounirou.spotirss.SpotiRss.java

/**
 * @param args/*from  ww  w .j  a  v  a  2  s  . com*/
 * @throws IOException 
 * @throws ClassNotFoundException 
 * @throws IllegalAccessException 
 * @throws InstantiationException 
 * @throws SpotifyClientException 
 * @throws ChartRssException 
 * @throws SpotifyException 
 */
public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException,
        ClassNotFoundException, SpotifyClientException {
    if (args.length == 0) {
        System.err.println("usage : java -jar spotiboard.jar <charts-folder>");
        return;
    }

    Properties connProperties = new Properties();
    InputStream inStream = SpotiRss.class.getResourceAsStream("/spotify-server.properties");
    try {
        connProperties.load(inStream);
    } finally {
        IOUtils.closeQuietly(inStream);
    }

    String host = connProperties.getProperty("host");
    int port = Integer.parseInt(connProperties.getProperty("port"));
    String user = connProperties.getProperty("user");

    final SpotifyClient spotifyClient = new SpotifyClient(host, port, user);
    final Map<String, Playlist> playlistsByTitle = getPlaylistsByTitle(spotifyClient);

    final File outputDir = new File(args[0]);
    outputDir.mkdirs();
    TrackCache cache = new TrackCache();
    try {

        for (String strProvider : PROVIDERS) {
            String providerClassName = EntryToTrackConverter.class.getPackage().getName() + "."
                    + StringUtils.capitalize(strProvider);
            final EntryToTrackConverter converter = (EntryToTrackConverter) SpotiRss.class.getClassLoader()
                    .loadClass(providerClassName).newInstance();
            Iterable<String> chartsRss = getCharts(strProvider);
            final File resultDir = new File(outputDir, strProvider);
            resultDir.mkdir();

            final SpotifyHrefQuery hrefQuery = new SpotifyHrefQuery(cache);
            Iterable<String> results = FluentIterable.from(chartsRss).transform(new Function<String, String>() {

                @Override
                @Nullable
                public String apply(@Nullable String chartRss) {

                    try {

                        long begin = System.currentTimeMillis();
                        ChartRss bilboardChartRss = ChartRss.getInstance(chartRss, converter);
                        Map<Track, String> trackHrefs = hrefQuery.getTrackHrefs(bilboardChartRss.getSongs());

                        String strTitle = bilboardChartRss.getTitle();
                        File resultFile = new File(resultDir, strTitle);
                        List<String> lines = Lists.newLinkedList(FluentIterable.from(trackHrefs.keySet())
                                .transform(Functions.toStringFunction()));
                        lines.addAll(trackHrefs.values());
                        FileUtils.writeLines(resultFile, Charsets.UTF_8.displayName(), lines);

                        Playlist playlist = playlistsByTitle.get(strTitle);
                        if (playlist != null) {
                            playlist.getTracks().clear();
                            playlist.getTracks().addAll(trackHrefs.values());
                            spotifyClient.patch(playlist);
                            LOGGER.info(String.format("%s chart exported patched", strTitle));
                        }

                        LOGGER.info(String.format("%s chart exported in %s in %d s", strTitle,
                                resultFile.getAbsolutePath(),
                                (int) TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - begin)));

                    } catch (Exception e) {
                        LOGGER.error(String.format("fail to export %s charts", chartRss), e);
                    }

                    return "";
                }
            });

            // consume iterables
            Iterables.size(results);

        }

    } finally {
        cache.close();
    }

}

From source file:controllers.hello.HelloController.java

public static Result index(String name) {
    return ok(String.format("Hello %s!", StringUtils.capitalize(name)));
}

From source file:com.opengamma.language.export.WikiDocumentationExporter.java

protected static String sentence(final String text) {
    String s = StringUtils.capitalize(text);
    if (s.charAt(s.length() - 1) != '.') {
        return s + ".";
    } else {/*from  w ww .j  a  v a2  s .co m*/
        return s;
    }
}

From source file:desi.juan.internal.util.MethodGeneratorUtils.java

public static String uriToCammelCase(String uri) {
    uri = uri.replace("{", "/").replace("}", "/");
    StringBuilder result = new StringBuilder();
    for (String word : StringUtils.split(uri, "/")) {
        if (word.contains("_")) {
            word = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, word);
        }/*from  ww w .  j  a  v  a2  s  .c om*/
        result.append(StringUtils.capitalize(word));
    }
    return StringUtils.uncapitalize(result.toString());
}

From source file:com.github.jdot.util.NameUtil.java

public final static String toBuilderMethod(State state) {
    return "with" + StringUtils.capitalize(state.getName());
}

From source file:jp.troter.tags.capture.CaptureUtil.java

/**
 * ????????/*from   ww  w. j a v a 2s. co  m*/
 * @param name
 * @return
 */
public static String captureName(String name) {
    return CaptureUtil.CONTENTS_FOR_PREFIX + StringUtils.capitalize(name);
}

From source file:com.idealista.solrmeter.util.ReflectionUtils.java

/**
 * This method will invoke the getter method of the attribute with the attributeName
 * passed as parameter./*from   www.j a v a  2s  .  c o m*/
 * @param object
 * @param attributeName
 * @return
 */
public static Object getAttribute(Object object, String attributeName) {
    try {
        return object.getClass().getMethod("get" + StringUtils.capitalize(attributeName)).invoke(object);
    } catch (Exception e) {
        throw new RuntimeException("Cant invoke the getter method of the attribute " + attributeName
                + " on the object " + object.toString() + ". Generated method name was " + "get"
                + StringUtils.capitalize(attributeName), e);
    }
}