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

CharUtils
public class CharUtils (Code)

Operations on char primitives and Character objects.

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:
   Stephen Colebourne
since:
   2.1
version:
   $Id: CharUtils.java 437554 2006-08-28 06:21:41Z bayard $


Field Summary
final public static  charCR
     carriage return CR ('\r').
final public static  charLF
     linefeed LF ('\n').

Constructor Summary
public  CharUtils()
    

CharUtils instances should NOT be constructed in standard programming.


Method Summary
public static  booleanisAscii(char ch)
    
public static  booleanisAsciiAlpha(char ch)
    
public static  booleanisAsciiAlphaLower(char ch)
    
public static  booleanisAsciiAlphaUpper(char ch)
    
public static  booleanisAsciiAlphanumeric(char ch)
    
public static  booleanisAsciiControl(char ch)
    
public static  booleanisAsciiNumeric(char ch)
    
public static  booleanisAsciiPrintable(char ch)
    
public static  chartoChar(Character ch)
    
public static  chartoChar(Character ch, char defaultValue)
    
public static  chartoChar(String str)
    
public static  chartoChar(String str, char defaultValue)
    
public static  CharactertoCharacterObject(char ch)
    
public static  CharactertoCharacterObject(String str)
    
public static  inttoIntValue(char ch)
    
public static  inttoIntValue(char ch, int defaultValue)
    
public static  inttoIntValue(Character ch)
    
public static  inttoIntValue(Character ch, int defaultValue)
    
public static  StringtoString(char ch)
    
public static  StringtoString(Character ch)
    
public static  StringunicodeEscaped(char ch)
    
public static  StringunicodeEscaped(Character ch)
    

Field Detail
CR
final public static char CR(Code)
carriage return CR ('\r').
See Also:    JLF: Escape Sequences * for Character and String Literals
since:
   2.2



LF
final public static char LF(Code)
linefeed LF ('\n').
See Also:    JLF: Escape Sequences * for Character and String Literals
since:
   2.2




Constructor Detail
CharUtils
public CharUtils()(Code)

CharUtils instances should NOT be constructed in standard programming. Instead, the class should be used as CharUtils.toString('c');.

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





Method Detail
isAscii
public static boolean isAscii(char ch)(Code)

Checks whether the character is ASCII 7 bit.

 CharUtils.isAscii('a')  = true
 CharUtils.isAscii('A')  = true
 CharUtils.isAscii('3')  = true
 CharUtils.isAscii('-')  = true
 CharUtils.isAscii('\n') = true
 CharUtils.isAscii('©') = false
 

Parameters:
  ch - the character to check true if less than 128



isAsciiAlpha
public static boolean isAsciiAlpha(char ch)(Code)

Checks whether the character is ASCII 7 bit alphabetic.

 CharUtils.isAsciiAlpha('a')  = true
 CharUtils.isAsciiAlpha('A')  = true
 CharUtils.isAsciiAlpha('3')  = false
 CharUtils.isAsciiAlpha('-')  = false
 CharUtils.isAsciiAlpha('\n') = false
 CharUtils.isAsciiAlpha('©') = false
 

Parameters:
  ch - the character to check true if between 65 and 90 or 97 and 122 inclusive



isAsciiAlphaLower
public static boolean isAsciiAlphaLower(char ch)(Code)

Checks whether the character is ASCII 7 bit alphabetic lower case.

 CharUtils.isAsciiAlphaLower('a')  = true
 CharUtils.isAsciiAlphaLower('A')  = false
 CharUtils.isAsciiAlphaLower('3')  = false
 CharUtils.isAsciiAlphaLower('-')  = false
 CharUtils.isAsciiAlphaLower('\n') = false
 CharUtils.isAsciiAlphaLower('©') = false
 

Parameters:
  ch - the character to check true if between 97 and 122 inclusive



isAsciiAlphaUpper
public static boolean isAsciiAlphaUpper(char ch)(Code)

Checks whether the character is ASCII 7 bit alphabetic upper case.

 CharUtils.isAsciiAlphaUpper('a')  = false
 CharUtils.isAsciiAlphaUpper('A')  = true
 CharUtils.isAsciiAlphaUpper('3')  = false
 CharUtils.isAsciiAlphaUpper('-')  = false
 CharUtils.isAsciiAlphaUpper('\n') = false
 CharUtils.isAsciiAlphaUpper('©') = false
 

Parameters:
  ch - the character to check true if between 65 and 90 inclusive



isAsciiAlphanumeric
public static boolean isAsciiAlphanumeric(char ch)(Code)

Checks whether the character is ASCII 7 bit numeric.

 CharUtils.isAsciiAlphanumeric('a')  = true
 CharUtils.isAsciiAlphanumeric('A')  = true
 CharUtils.isAsciiAlphanumeric('3')  = true
 CharUtils.isAsciiAlphanumeric('-')  = false
 CharUtils.isAsciiAlphanumeric('\n') = false
 CharUtils.isAsciiAlphanumeric('©') = false
 

Parameters:
  ch - the character to check true if between 48 and 57 or 65 and 90 or 97 and 122 inclusive



isAsciiControl
public static boolean isAsciiControl(char ch)(Code)

Checks whether the character is ASCII 7 bit control.

 CharUtils.isAsciiControl('a')  = false
 CharUtils.isAsciiControl('A')  = false
 CharUtils.isAsciiControl('3')  = false
 CharUtils.isAsciiControl('-')  = false
 CharUtils.isAsciiControl('\n') = true
 CharUtils.isAsciiControl('©') = false
 

Parameters:
  ch - the character to check true if less than 32 or equals 127



isAsciiNumeric
public static boolean isAsciiNumeric(char ch)(Code)

Checks whether the character is ASCII 7 bit numeric.

 CharUtils.isAsciiNumeric('a')  = false
 CharUtils.isAsciiNumeric('A')  = false
 CharUtils.isAsciiNumeric('3')  = true
 CharUtils.isAsciiNumeric('-')  = false
 CharUtils.isAsciiNumeric('\n') = false
 CharUtils.isAsciiNumeric('©') = false
 

Parameters:
  ch - the character to check true if between 48 and 57 inclusive



isAsciiPrintable
public static boolean isAsciiPrintable(char ch)(Code)

Checks whether the character is ASCII 7 bit printable.

 CharUtils.isAsciiPrintable('a')  = true
 CharUtils.isAsciiPrintable('A')  = true
 CharUtils.isAsciiPrintable('3')  = true
 CharUtils.isAsciiPrintable('-')  = true
 CharUtils.isAsciiPrintable('\n') = false
 CharUtils.isAsciiPrintable('©') = false
 

Parameters:
  ch - the character to check true if between 32 and 126 inclusive



toChar
public static char toChar(Character ch)(Code)

Converts the Character to a char throwing an exception for null.

 CharUtils.toChar(null) = IllegalArgumentException
 CharUtils.toChar(' ')  = ' '
 CharUtils.toChar('A')  = 'A'
 

Parameters:
  ch - the character to convert the char value of the Character
throws:
  IllegalArgumentException - if the Character is null



toChar
public static char toChar(Character ch, char defaultValue)(Code)

Converts the Character to a char handling null.

 CharUtils.toChar(null, 'X') = 'X'
 CharUtils.toChar(' ', 'X')  = ' '
 CharUtils.toChar('A', 'X')  = 'A'
 

Parameters:
  ch - the character to convert
Parameters:
  defaultValue - the value to use if the Character is null the char value of the Character or the default if null



toChar
public static char toChar(String str)(Code)

Converts the String to a char using the first character, throwing an exception on empty Strings.

 CharUtils.toChar(null) = IllegalArgumentException
 CharUtils.toChar("")   = IllegalArgumentException
 CharUtils.toChar("A")  = 'A'
 CharUtils.toChar("BA") = 'B'
 

Parameters:
  str - the character to convert the char value of the first letter of the String
throws:
  IllegalArgumentException - if the String is empty



toChar
public static char toChar(String str, char defaultValue)(Code)

Converts the String to a char using the first character, defaulting the value on empty Strings.

 CharUtils.toChar(null, 'X') = 'X'
 CharUtils.toChar("", 'X')   = 'X'
 CharUtils.toChar("A", 'X')  = 'A'
 CharUtils.toChar("BA", 'X') = 'B'
 

Parameters:
  str - the character to convert
Parameters:
  defaultValue - the value to use if the Character is null the char value of the first letter of the String or the default if null



toCharacterObject
public static Character toCharacterObject(char ch)(Code)

Converts the character to a Character.

For ASCII 7 bit characters, this uses a cache that will return the same Character object each time.

 CharUtils.toCharacterObject(' ')  = ' '
 CharUtils.toCharacterObject('A')  = 'A'
 

Parameters:
  ch - the character to convert a Character of the specified character



toCharacterObject
public static Character toCharacterObject(String str)(Code)

Converts the String to a Character using the first character, returning null for empty Strings.

For ASCII 7 bit characters, this uses a cache that will return the same Character object each time.

 CharUtils.toCharacterObject(null) = null
 CharUtils.toCharacterObject("")   = null
 CharUtils.toCharacterObject("A")  = 'A'
 CharUtils.toCharacterObject("BA") = 'B'
 

Parameters:
  str - the character to convert the Character value of the first letter of the String



toIntValue
public static int toIntValue(char ch)(Code)

Converts the character to the Integer it represents, throwing an exception if the character is not numeric.

This method coverts the char '1' to the int 1 and so on.

 CharUtils.toIntValue('3')  = 3
 CharUtils.toIntValue('A')  = IllegalArgumentException
 

Parameters:
  ch - the character to convert the int value of the character
throws:
  IllegalArgumentException - if the character is not ASCII numeric



toIntValue
public static int toIntValue(char ch, int defaultValue)(Code)

Converts the character to the Integer it represents, throwing an exception if the character is not numeric.

This method coverts the char '1' to the int 1 and so on.

 CharUtils.toIntValue('3', -1)  = 3
 CharUtils.toIntValue('A', -1)  = -1
 

Parameters:
  ch - the character to convert
Parameters:
  defaultValue - the default value to use if the character is not numeric the int value of the character



toIntValue
public static int toIntValue(Character ch)(Code)

Converts the character to the Integer it represents, throwing an exception if the character is not numeric.

This method coverts the char '1' to the int 1 and so on.

 CharUtils.toIntValue(null) = IllegalArgumentException
 CharUtils.toIntValue('3')  = 3
 CharUtils.toIntValue('A')  = IllegalArgumentException
 

Parameters:
  ch - the character to convert, not null the int value of the character
throws:
  IllegalArgumentException - if the Character is not ASCII numeric or is null



toIntValue
public static int toIntValue(Character ch, int defaultValue)(Code)

Converts the character to the Integer it represents, throwing an exception if the character is not numeric.

This method coverts the char '1' to the int 1 and so on.

 CharUtils.toIntValue(null, -1) = -1
 CharUtils.toIntValue('3', -1)  = 3
 CharUtils.toIntValue('A', -1)  = -1
 

Parameters:
  ch - the character to convert
Parameters:
  defaultValue - the default value to use if the character is not numeric the int value of the character



toString
public static String toString(char ch)(Code)

Converts the character to a String that contains the one character.

For ASCII 7 bit characters, this uses a cache that will return the same String object each time.

 CharUtils.toString(' ')  = " "
 CharUtils.toString('A')  = "A"
 

Parameters:
  ch - the character to convert a String containing the one specified character



toString
public static String toString(Character ch)(Code)

Converts the character to a String that contains the one character.

For ASCII 7 bit characters, this uses a cache that will return the same String object each time.

If null is passed in, null will be returned.

 CharUtils.toString(null) = null
 CharUtils.toString(' ')  = " "
 CharUtils.toString('A')  = "A"
 

Parameters:
  ch - the character to convert a String containing the one specified character



unicodeEscaped
public static String unicodeEscaped(char ch)(Code)

Converts the string to the unicode format '\u0020'.

This format is the Java source code format.

 CharUtils.unicodeEscaped(' ') = "\u0020"
 CharUtils.unicodeEscaped('A') = "\u0041"
 

Parameters:
  ch - the character to convert the escaped unicode string



unicodeEscaped
public static String unicodeEscaped(Character ch)(Code)

Converts the string to the unicode format '\u0020'.

This format is the Java source code format.

If null is passed in, null will be returned.

 CharUtils.unicodeEscaped(null) = null
 CharUtils.unicodeEscaped(' ')  = "\u0020"
 CharUtils.unicodeEscaped('A')  = "\u0041"
 

Parameters:
  ch - the character to convert, may be null the escaped unicode string, 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.