Java Doc for WordUtils.java in  » Library » Apache-common-lang » org » apache » commons » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common lang » org.apache.commons.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.lang.WordUtils

WordUtils
public class WordUtils (Code)

Operations on Strings that contain words.

This class tries to handle null input gracefully. An exception will not be thrown for a null input. Each method documents its behaviour in more detail.


author:
   Apache Jakarta Velocity
author:
   Stephen Colebourne
author:
   Henning P. Schmiedehausen
author:
   Gary Gregory
since:
   2.0
version:
   $Id: WordUtils.java 471626 2006-11-06 04:02:09Z bayard $



Constructor Summary
public  WordUtils()
    

WordUtils instances should NOT be constructed in standard programming.


Method Summary
public static  Stringcapitalize(String str)
    

Capitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.

public static  Stringcapitalize(String str, char[] delimiters)
    

Capitalizes all the delimiter separated words in a String. Only the first letter of each word is changed.

public static  StringcapitalizeFully(String str)
    

Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

public static  StringcapitalizeFully(String str, char[] delimiters)
    

Converts all the delimiter separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

public static  Stringinitials(String str)
    

Extracts the initial letters from each word in the String.

The first letter of the string and all first letters after whitespace are returned as a new string.

public static  Stringinitials(String str, char[] delimiters)
    

Extracts the initial letters from each word in the String.

The first letter of the string and all first letters after the defined delimiters are returned as a new string.

public static  StringswapCase(String str)
    

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) .

public static  Stringuncapitalize(String str)
    

Uncapitalizes all the whitespace separated words in a String.

public static  Stringuncapitalize(String str, char[] delimiters)
    

Uncapitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.

The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be uncapitalized.

public static  Stringwrap(String str, int wrapLength)
    

Wraps a single line of text, identifying words by ' '.

New lines will be separated by the system property line separator.

public static  Stringwrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords)
    

Wraps a single line of text, identifying words by ' '.

Leading spaces on a new line are stripped.



Constructor Detail
WordUtils
public WordUtils()(Code)

WordUtils instances should NOT be constructed in standard programming. Instead, the class should be used as WordUtils.wrap("foo bar", 20);.

This constructor is public to permit tools that require a JavaBean instance to operate.





Method Detail
capitalize
public static String capitalize(String str)(Code)

Capitalizes all the whitespace separated words in a String. Only the first letter of each word is changed. To convert the rest of each word to lowercase at the same time, use WordUtils.capitalizeFully(String) .

Whitespace is defined by Character.isWhitespace(char) . A null input String returns null. Capitalization uses the unicode title case, normally equivalent to upper case.

 WordUtils.capitalize(null)        = null
 WordUtils.capitalize("")          = ""
 WordUtils.capitalize("i am FINE") = "I Am FINE"
 

Parameters:
  str - the String to capitalize, may be null capitalized String, null if null String input
See Also:   WordUtils.uncapitalize(String)
See Also:   WordUtils.capitalizeFully(String)



capitalize
public static String capitalize(String str, char[] delimiters)(Code)

Capitalizes all the delimiter separated words in a String. Only the first letter of each word is changed. To convert the rest of each word to lowercase at the same time, use WordUtils.capitalizeFully(String,char[]) .

The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized.

A null input String returns null. Capitalization uses the unicode title case, normally equivalent to upper case.

 WordUtils.capitalize(null, *)            = null
 WordUtils.capitalize("", *)              = ""
 WordUtils.capitalize(*, new char[0])     = *
 WordUtils.capitalize("i am fine", null)  = "I Am Fine"
 WordUtils.capitalize("i aM.fine", {'.'}) = "I aM.Fine"
 

Parameters:
  str - the String to capitalize, may be null
Parameters:
  delimiters - set of characters to determine capitalization, null means whitespace capitalized String, null if null String input
See Also:   WordUtils.uncapitalize(String)
See Also:   WordUtils.capitalizeFully(String)
since:
   2.1



capitalizeFully
public static String capitalizeFully(String str)(Code)

Converts all the whitespace separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

Whitespace is defined by Character.isWhitespace(char) . A null input String returns null. Capitalization uses the unicode title case, normally equivalent to upper case.

 WordUtils.capitalizeFully(null)        = null
 WordUtils.capitalizeFully("")          = ""
 WordUtils.capitalizeFully("i am FINE") = "I Am Fine"
 

Parameters:
  str - the String to capitalize, may be null capitalized String, null if null String input



capitalizeFully
public static String capitalizeFully(String str, char[] delimiters)(Code)

Converts all the delimiter separated words in a String into capitalized words, that is each word is made up of a titlecase character and then a series of lowercase characters.

The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be capitalized.

A null input String returns null. Capitalization uses the unicode title case, normally equivalent to upper case.

 WordUtils.capitalizeFully(null, *)            = null
 WordUtils.capitalizeFully("", *)              = ""
 WordUtils.capitalizeFully(*, null)            = *
 WordUtils.capitalizeFully(*, new char[0])     = *
 WordUtils.capitalizeFully("i aM.fine", {'.'}) = "I am.Fine"
 

Parameters:
  str - the String to capitalize, may be null
Parameters:
  delimiters - set of characters to determine capitalization, null means whitespace capitalized String, null if null String input
since:
   2.1



initials
public static String initials(String str)(Code)

Extracts the initial letters from each word in the String.

The first letter of the string and all first letters after whitespace are returned as a new string. Their case is not changed.

Whitespace is defined by Character.isWhitespace(char) . A null input String returns null.

 WordUtils.initials(null)             = null
 WordUtils.initials("")               = ""
 WordUtils.initials("Ben John Lee")   = "BJL"
 WordUtils.initials("Ben J.Lee")      = "BJ"
 

Parameters:
  str - the String to get initials from, may be null String of initial letters, null if null String input
See Also:   WordUtils.initials(String,char[])
since:
   2.2



initials
public static String initials(String str, char[] delimiters)(Code)

Extracts the initial letters from each word in the String.

The first letter of the string and all first letters after the defined delimiters are returned as a new string. Their case is not changed.

If the delimiters array is null, then Whitespace is used. Whitespace is defined by Character.isWhitespace(char) . A null input String returns null. An empty delimiter array returns an empty String.

 WordUtils.initials(null, *)                = null
 WordUtils.initials("", *)                  = ""
 WordUtils.initials("Ben John Lee", null)   = "BJL"
 WordUtils.initials("Ben J.Lee", null)      = "BJ"
 WordUtils.initials("Ben J.Lee", [' ','.']) = "BJL"
 WordUtils.initials(*, new char[0])         = ""
 

Parameters:
  str - the String to get initials from, may be null
Parameters:
  delimiters - set of characters to determine words, null means whitespace String of initial letters, null if null String input
See Also:   WordUtils.initials(String)
since:
   2.2



swapCase
public static String swapCase(String str)(Code)

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) . A null input String returns null.

 StringUtils.swapCase(null)                 = null
 StringUtils.swapCase("")                   = ""
 StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"
 

Parameters:
  str - the String to swap case, may be null the changed String, null if null String input



uncapitalize
public static String uncapitalize(String str)(Code)

Uncapitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.

Whitespace is defined by Character.isWhitespace(char) . A null input String returns null.

 WordUtils.uncapitalize(null)        = null
 WordUtils.uncapitalize("")          = ""
 WordUtils.uncapitalize("I Am FINE") = "i am fINE"
 

Parameters:
  str - the String to uncapitalize, may be null uncapitalized String, null if null String input
See Also:   WordUtils.capitalize(String)



uncapitalize
public static String uncapitalize(String str, char[] delimiters)(Code)

Uncapitalizes all the whitespace separated words in a String. Only the first letter of each word is changed.

The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter character after a delimiter will be uncapitalized.

Whitespace is defined by Character.isWhitespace(char) . A null input String returns null.

 WordUtils.uncapitalize(null, *)            = null
 WordUtils.uncapitalize("", *)              = ""
 WordUtils.uncapitalize(*, null)            = *
 WordUtils.uncapitalize(*, new char[0])     = *
 WordUtils.uncapitalize("I AM.FINE", {'.'}) = "i AM.fINE"
 

Parameters:
  str - the String to uncapitalize, may be null
Parameters:
  delimiters - set of characters to determine uncapitalization, null means whitespace uncapitalized String, null if null String input
See Also:   WordUtils.capitalize(String)
since:
   2.1



wrap
public static String wrap(String str, int wrapLength)(Code)

Wraps a single line of text, identifying words by ' '.

New lines will be separated by the system property line separator. Very long words, such as URLs will not be wrapped.

Leading spaces on a new line are stripped. Trailing spaces are not stripped.

 WordUtils.wrap(null, *) = null
 WordUtils.wrap("", *) = ""
 

Parameters:
  str - the String to be word wrapped, may be null
Parameters:
  wrapLength - the column to wrap the words at, less than 1 is treated as 1 a line with newlines inserted, null if null input



wrap
public static String wrap(String str, int wrapLength, String newLineStr, boolean wrapLongWords)(Code)

Wraps a single line of text, identifying words by ' '.

Leading spaces on a new line are stripped. Trailing spaces are not stripped.

 WordUtils.wrap(null, *, *, *) = null
 WordUtils.wrap("", *, *, *) = ""
 

Parameters:
  str - the String to be word wrapped, may be null
Parameters:
  wrapLength - the column to wrap the words at, less than 1 is treated as 1
Parameters:
  newLineStr - the string to insert for a new line, null uses the system property line separator
Parameters:
  wrapLongWords - true if long words (such as URLs) should be wrapped a line with newlines inserted, null if null input



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.