Java Doc for CharSetUtils.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.CharSetUtils

CharSetUtils
public class CharSetUtils (Code)

Operations on CharSets.

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


See Also:   CharSet
author:
   Stephen Colebourne
author:
   Phil Steitz
author:
   Gary Gregory
since:
   1.0
version:
   $Id: CharSetUtils.java 471626 2006-11-06 04:02:09Z bayard $



Constructor Summary
public  CharSetUtils()
    

CharSetUtils instances should NOT be constructed in standard programming.


Method Summary
public static  intcount(String str, String set)
    
public static  intcount(String str, String[] set)
    
public static  Stringdelete(String str, String set)
    
public static  Stringdelete(String str, String[] set)
    
public static  CharSetevaluateSet(String[] set)
    

Creates a CharSet instance which allows a certain amount of set logic to be performed.

The syntax is:

  • "aeio" which implies 'a','e',..
  • "^e" implies not e.
  • "ej-m" implies e,j->m.
public static  Stringkeep(String str, String set)
    
public static  Stringkeep(String str, String[] set)
    
public static  Stringsqueeze(String str, String set)
    
public static  Stringsqueeze(String str, String[] set)
    
public static  Stringtranslate(String str, String searchChars, String replaceChars)
    

Translate characters in a String.



Constructor Detail
CharSetUtils
public CharSetUtils()(Code)

CharSetUtils instances should NOT be constructed in standard programming. Instead, the class should be used as CharSetUtils.evaluateSet(null);.

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





Method Detail
count
public static int count(String str, String set)(Code)

Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.

 CharSetUtils.count(null, *)        = 0
 CharSetUtils.count("", *)          = 0
 CharSetUtils.count(*, null)        = 0
 CharSetUtils.count(*, "")          = 0
 CharSetUtils.count("hello", "k-p") = 3
 CharSetUtils.count("hello", "a-e") = 1
 

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - String to count characters in, may be null
Parameters:
  set - String set of characters to count, may be null character count, zero if null string input



count
public static int count(String str, String[] set)(Code)

Takes an argument in set-syntax, see evaluateSet, and returns the number of characters present in the specified string.

An example would be:

  • count("hello", {"c-f", "o"}) returns 2.

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - String to count characters in, may be null
Parameters:
  set - String[] set of characters to count, may be null character count, zero if null string input



delete
public static String delete(String str, String set)(Code)

Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.

 CharSetUtils.delete(null, *)        = null
 CharSetUtils.delete("", *)          = ""
 CharSetUtils.delete(*, null)        = *
 CharSetUtils.delete(*, "")          = *
 CharSetUtils.delete("hello", "hl")  = "eo"
 CharSetUtils.delete("hello", "le")  = "ho"
 

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - String to delete characters from, may be null
Parameters:
  set - String set of characters to delete, may be null modified String, null if null string input



delete
public static String delete(String str, String[] set)(Code)

Takes an argument in set-syntax, see evaluateSet, and deletes any of characters present in the specified string.

An example would be:

  • delete("hello", {"c-f", "o"}) returns "hll"

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - String to delete characters from, may be null
Parameters:
  set - String[] set of characters to delete, may be null modified String, null if null string input



evaluateSet
public static CharSet evaluateSet(String[] set)(Code)

Creates a CharSet instance which allows a certain amount of set logic to be performed.

The syntax is:

  • "aeio" which implies 'a','e',..
  • "^e" implies not e.
  • "ej-m" implies e,j->m. e,j,k,l,m.
 CharSetUtils.evaluateSet(null)    = null
 CharSetUtils.evaluateSet([])      = CharSet matching nothing
 CharSetUtils.evaluateSet(["a-e"]) = CharSet matching a,b,c,d,e
 

Parameters:
  set - the set, may be null a CharSet instance, null if null inputCharSet.getInstance(String)



keep
public static String keep(String str, String set)(Code)

Takes an argument in set-syntax, see evaluateSet, and keeps any of characters present in the specified string.

 CharSetUtils.keep(null, *)        = null
 CharSetUtils.keep("", *)          = ""
 CharSetUtils.keep(*, null)        = ""
 CharSetUtils.keep(*, "")          = ""
 CharSetUtils.keep("hello", "hl")  = "hll"
 CharSetUtils.keep("hello", "le")  = "ell"
 

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - String to keep characters from, may be null
Parameters:
  set - String set of characters to keep, may be null modified String, null if null string input
since:
   2.0



keep
public static String keep(String str, String[] set)(Code)

Takes an argument in set-syntax, see evaluateSet, and keeps any of characters present in the specified string.

An example would be:

  • keep("hello", {"c-f", "o"}) returns "eo"

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - String to keep characters from, may be null
Parameters:
  set - String[] set of characters to keep, may be null modified String, null if null string input
since:
   2.0



squeeze
public static String squeeze(String str, String set)(Code)

Squeezes any repetitions of a character that is mentioned in the supplied set.

 CharSetUtils.squeeze(null, *)        = null
 CharSetUtils.squeeze("", *)          = ""
 CharSetUtils.squeeze(*, null)        = *
 CharSetUtils.squeeze(*, "")          = *
 CharSetUtils.squeeze("hello", "k-p") = "helo"
 CharSetUtils.squeeze("hello", "a-e") = "hello"
 

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - the string to squeeze, may be null
Parameters:
  set - the character set to use for manipulation, may be null modified String, null if null string input



squeeze
public static String squeeze(String str, String[] set)(Code)

Squeezes any repetitions of a character that is mentioned in the supplied set.

An example is:

  • squeeze("hello", {"el"}) => "helo"

See Also:   CharSetUtils.evaluateSet(java.lang.String[])
See Also:    for set-syntax.
Parameters:
  str - the string to squeeze, may be null
Parameters:
  set - the character set to use for manipulation, may be null modified String, null if null string input



translate
public static String translate(String str, String searchChars, String replaceChars)(Code)

Translate characters in a String. This is a multi character search and replace routine.

An example is:

  • translate("hello", "ho", "jy") => jelly

If the length of characters to search for is greater than the length of characters to replace, then the last character is used.

 CharSetUtils.translate(null, *, *) = null
 CharSetUtils.translate("", *, *)   = ""
 

Parameters:
  str - String to replace characters in, may be null
Parameters:
  searchChars - a set of characters to search for, must not be null
Parameters:
  replaceChars - a set of characters to replace, must not be null or empty ("") translated String, null if null string input
throws:
  NullPointerException - if searchChars or replaceChars is null
throws:
  ArrayIndexOutOfBoundsException - if replaceChars is empty ("")StringUtils.replaceChars(StringStringString)



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.