Example usage for org.apache.commons.lang WordUtils swapCase

List of usage examples for org.apache.commons.lang WordUtils swapCase

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils swapCase.

Prototype

public static String swapCase(String str) 

Source Link

Document

Swaps the case of a String using a word based algorithm.

  • Upper case character converts to Lower case
  • Title case character converts to Lower case
  • Lower case character after Whitespace or at start converts to Title case
  • Other Lower case character converts to Upper case

Whitespace is defined by Character#isWhitespace(char) .

Usage

From source file:ac.elements.parser.ExtendedFunctions.java

/**
 * The main method.//from   w w w  .j a v  a  2 s .c  om
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args) {

    java.math.BigInteger myInt = new java.math.BigInteger("1223");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("59000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("59900");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("5990000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("599000000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));
    myInt = new java.math.BigInteger("59900000000");
    System.out.println(myInt);
    System.out.println(ExtendedFunctions.timePeriod(myInt));

    String sql = "select * from domain where `this`='test' and this2=\"test\"";

    System.out.println(ExtendedFunctions.escapeSql(sql));

    String unformattedXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><QueryMessage\n"
            + "        xmlns=\"http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message\"\n"
            + "        xmlns:query=\"http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query\">\n"
            + "    <Query>\n" + "        <query:CategorySchemeWhere>\n"
            + "   \t\t\t\t\t         <query:AgencyID>ECB\n\n\n\n</query:AgencyID>\n"
            + "        </query:CategorySchemeWhere>\n" + "    </Query>\n\n\n\n\n" + "</QueryMessage>";

    System.out.println(ExtendedFunctions.formatXml(unformattedXml));

    String company = "international business MACHINES. iag is here.";
    System.out.println(ExtendedFunctions.capitalize(company));

    String url = "\u1087\u1088\u1077\u1076\u1089";

    System.out.println(url);
    System.out.println(ExtendedFunctions.escUniJs(url));
    System.out.println(ExtendedFunctions.toUnicodeHTML(url));
    ExtendedFunctions.trim(url);
    url = "http://news.google.com/news?hl=en&client=safari&rls=en-us&q=get%20part%20of%20paragraph%20words%20google%20algorithm&um=1&ie=UTF-8&sa=N&tab=wn";
    System.out.println(ExtendedFunctions.chopUrl(url, 30));
    url = "http://www.pcplus.co.uk/node/3061/";
    System.out.println(ExtendedFunctions.chopUrl(url, 30));
    url = "http://www.opent.net/forum/security-problem-with-ot-script-on-ssl-t159.html";
    System.out.println(ExtendedFunctions.chopUrl(url, 30));
    System.out.println(ExtendedFunctions.escapeJavaScript("escapeJavas'\"cript"));
    System.err.println(StringUtils.abbreviate("Take time off working", 0, 10));
    System.err.println(StringUtils.capitalize("how is vandersar doing?"));
    String unescapedJava = "Are you \" for real?";
    System.err.println(StringEscapeUtils.escapeJava(unescapedJava));

    String unescapedJavaScript = "What's in a name?";
    System.err.println(ExtendedFunctions.escapeJavaScript(unescapedJavaScript));

    String unescapedSql = "Mc'Williams";
    System.err.println(StringEscapeUtils.escapeSql(unescapedSql));

    String unescapedXML = "<data>";
    System.err.println(StringEscapeUtils.escapeXml(unescapedXML));

    String unescapedHTML = "the data is <data>";
    System.err.println(StringEscapeUtils.escapeHtml(unescapedHTML));
    System.err.println(WordUtils.capitalize(unescapedHTML));
    System.err.println(WordUtils.swapCase(unescapedHTML));
}

From source file:ac.elements.parser.ExtendedFunctions.java

/**
 * Swap case.//from www .  jav  a  2s  . co  m
 * 
 * @param str
 *            the str
 * 
 * @return the string
 */
public static String swapCase(String str) {
    return WordUtils.swapCase(str);
}