Java Doc for TypeFormat.java in  » Development » Javolution » javolution » text » 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 » Development » Javolution » javolution.text 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   javolution.text.TypeFormat

TypeFormat
final public class TypeFormat (Code)

This class provides utility methods to parse CharSequence into primitive types and to format primitive types into any Appendable.

Methods from this class do not create temporary objects and are typically faster than standard library methods (see benchmark).

The number of digits when formatting floating point numbers can be specified. The default setting for double is 17 digits or even 16 digits when the conversion is lossless back and forth (mimic the standard library formatting). For example:[code] TypeFormat.format(0.2, a) = "0.2" // 17 or 16 digits (as long as lossless conversion), remove trailing zeros. TypeFormat.format(0.2, 17, false, false, a) = "0.20000000000000001" // Closest 17 digits number. TypeFormat.format(0.2, 19, false, false, a) = "0.2000000000000000111" // Closest 19 digits. TypeFormat.format(0.2, 4, false, false, a) = "0.2" // Fixed-point notation, remove trailing zeros. TypeFormat.format(0.2, 4, false, true, a) = "0.2000" // Fixed-point notation, fixed number of digits. TypeFormat.format(0.2, 4, true, false, a) = "2.0E-1" // Scientific notation, remove trailing zeros. TypeFormat.format(0.2, 4, true, true, a) = "2.000E-1" // Scientific notation, fixed number of digits. [/code]

For non-primitive objects, formatting is typically performed using specialized TextFormat instances.


author:
   Jean-Marie Dautelle
version:
   4.1, November 30, 2006




Method Summary
public static  Appendableformat(boolean b, Appendable a)
     Formats the specified boolean and appends the resulting text to the Appendable argument.
Parameters:
  b - a boolean.
Parameters:
  a - the Appendable to append.
public static  Appendableformat(int i, Appendable a)
     Formats the specified int and appends the resulting text (decimal representation) to the Appendable argument.

Note: This method is preferred to Appendable.append(int) as it does not create temporary String objects (several times faster for small numbers).


Parameters:
  i - the int number.
Parameters:
  a - the Appendable to append.
public static  Appendableformat(int i, int radix, Appendable a)
     Formats the specified int in the specified radix and appends the resulting text to the Appendable argument.
Parameters:
  i - the int number.
Parameters:
  radix - the radix.
Parameters:
  a - the Appendable to append.
public static  Appendableformat(long l, Appendable a)
     Formats the specified long and appends the resulting text (decimal representation) to the Appendable argument.

Note: This method is preferred to Appendable.append(long) as it does not create temporary String objects (several times faster for small numbers).


Parameters:
  l - the long number.
Parameters:
  a - the Appendable to append.
public static  Appendableformat(long l, int radix, Appendable a)
     Formats the specified long in the specified radix and appends the resulting text to the Appendable argument.
Parameters:
  l - the long number.
Parameters:
  radix - the radix.
Parameters:
  a - the Appendable to append.
public static  booleanparseBoolean(CharSequence csq)
     Parses the specified character sequence as a boolean.
Parameters:
  csq - the character sequence to parse.
public static  booleanparseBoolean(String csq)
     Equivalent to TypeFormat.parseBoolean(CharSequence) (for J2ME compatibility).
public static  booleanparseBoolean(CharSequence csq, Cursor cursor)
     Parses the specified character sequence from the specified position as a boolean.
Parameters:
  csq - the character sequence to parse.
Parameters:
  cursor - the current cursor position (being maintained).
public static  byteparseByte(CharSequence csq)
     Parses the specified character sequence as a signed decimal byte.
Parameters:
  csq - the character sequence to parse.
public static  byteparseByte(CharSequence csq, int radix)
     Parses the specified character sequence as a signed byte in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
public static  byteparseByte(CharSequence csq, int radix, Cursor cursor)
     Parses the specified character sequence from the specified position as a signed byte in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained).
public static  intparseInt(CharSequence csq)
     Parses the specified character sequence as a signed int.
Parameters:
  csq - the character sequence to parse.
public static  intparseInt(String str)
     Equivalent to TypeFormat.parseInt(CharSequence) (for J2ME compatibility).
public static  intparseInt(CharSequence csq, int radix)
     Parses the specified character sequence as a signed int in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
public static  intparseInt(String str, int radix)
     Equivalent to TypeFormat.parseInt(CharSequence,int) (for J2ME compatibility).
public static  intparseInt(CharSequence csq, int radix, Cursor cursor)
     Parses the specified character sequence from the specified position as a signed int in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained) ornull if the whole character sequence is parsed.
public static  longparseLong(CharSequence csq)
     Parses the specified character sequence as a decimal long.
Parameters:
  csq - the character sequence to parse.
public static  longparseLong(String str)
     Equivalent to TypeFormat.parseLong(CharSequence) (for J2ME compatibility).
public static  longparseLong(CharSequence csq, int radix)
     Parses the specified character sequence as a signed long in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
public static  longparseLong(String str, int radix)
     Equivalent to TypeFormat.parseLong(CharSequence,int) (for J2ME compatibility).
public static  longparseLong(CharSequence csq, int radix, Cursor cursor)
     Parses the specified character sequence from the specified position as a signed long in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained) ornull if the whole character sequence is parsed.
public static  shortparseShort(CharSequence csq)
     Parses the specified character sequence as a signed decimal short.
Parameters:
  csq - the character sequence to parse.
public static  shortparseShort(CharSequence csq, int radix)
     Parses the specified character sequence as a signed short in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
public static  shortparseShort(CharSequence csq, int radix, Cursor cursor)
     Parses the specified character sequence from the specified position as a signed short in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained).



Method Detail
format
public static Appendable format(boolean b, Appendable a) throws IOException(Code)
Formats the specified boolean and appends the resulting text to the Appendable argument.
Parameters:
  b - a boolean.
Parameters:
  a - the Appendable to append. the specified StringBuffer object.
throws:
  IOException - if an I/O exception occurs.
See Also:   TypeFormat.parseBoolean



format
public static Appendable format(int i, Appendable a) throws IOException(Code)
Formats the specified int and appends the resulting text (decimal representation) to the Appendable argument.

Note: This method is preferred to Appendable.append(int) as it does not create temporary String objects (several times faster for small numbers).


Parameters:
  i - the int number.
Parameters:
  a - the Appendable to append. the specified Appendable object.
throws:
  IOException - if an I/O exception occurs.
See Also:   TypeFormat.parseInt



format
public static Appendable format(int i, int radix, Appendable a) throws IOException(Code)
Formats the specified int in the specified radix and appends the resulting text to the Appendable argument.
Parameters:
  i - the int number.
Parameters:
  radix - the radix.
Parameters:
  a - the Appendable to append. the specified Appendable object.
throws:
  IllegalArgumentException - if radix is not in [2 .. 36] range.
throws:
  IOException - if an I/O exception occurs.
See Also:   TypeFormat.parseInt(CharSequence,int)



format
public static Appendable format(long l, Appendable a) throws IOException(Code)
Formats the specified long and appends the resulting text (decimal representation) to the Appendable argument.

Note: This method is preferred to Appendable.append(long) as it does not create temporary String objects (several times faster for small numbers).


Parameters:
  l - the long number.
Parameters:
  a - the Appendable to append. the specified Appendable object.
throws:
  IOException - if an I/O exception occurs.
See Also:   TypeFormat.parseLong



format
public static Appendable format(long l, int radix, Appendable a) throws IOException(Code)
Formats the specified long in the specified radix and appends the resulting text to the Appendable argument.
Parameters:
  l - the long number.
Parameters:
  radix - the radix.
Parameters:
  a - the Appendable to append. the specified Appendable object.
throws:
  IllegalArgumentException - if radix is not in [2 .. 36] range.
throws:
  IOException - if an I/O exception occurs.
See Also:   TypeFormat.parseLong(CharSequence,int)



parseBoolean
public static boolean parseBoolean(CharSequence csq)(Code)
Parses the specified character sequence as a boolean.
Parameters:
  csq - the character sequence to parse. the corresponding boolean value.
throws:
  IllegalArgumentException - if the specified character sequence is different from "true" or "false" ignoring cases.



parseBoolean
public static boolean parseBoolean(String csq)(Code)
Equivalent to TypeFormat.parseBoolean(CharSequence) (for J2ME compatibility).



parseBoolean
public static boolean parseBoolean(CharSequence csq, Cursor cursor)(Code)
Parses the specified character sequence from the specified position as a boolean.
Parameters:
  csq - the character sequence to parse.
Parameters:
  cursor - the current cursor position (being maintained). the next boolean value.
throws:
  IllegalArgumentException - if the character sequence from the specified position is different from "true" or "false" ignoringcases.



parseByte
public static byte parseByte(CharSequence csq)(Code)
Parses the specified character sequence as a signed decimal byte.
Parameters:
  csq - the character sequence to parse. parseByte(csq, 10)
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable byte.
See Also:   TypeFormat.parseByte(CharSequence,int)



parseByte
public static byte parseByte(CharSequence csq, int radix)(Code)
Parses the specified character sequence as a signed byte in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing. the corresponding byte.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable byte.



parseByte
public static byte parseByte(CharSequence csq, int radix, Cursor cursor)(Code)
Parses the specified character sequence from the specified position as a signed byte in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained). the corresponding byte.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable byte.



parseInt
public static int parseInt(CharSequence csq)(Code)
Parses the specified character sequence as a signed int.
Parameters:
  csq - the character sequence to parse. parseInt(csq, 10)
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable int.
See Also:   TypeFormat.parseInt(CharSequence,int)



parseInt
public static int parseInt(String str)(Code)
Equivalent to TypeFormat.parseInt(CharSequence) (for J2ME compatibility).



parseInt
public static int parseInt(CharSequence csq, int radix)(Code)
Parses the specified character sequence as a signed int in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing. the corresponding int.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable int.



parseInt
public static int parseInt(String str, int radix)(Code)
Equivalent to TypeFormat.parseInt(CharSequence,int) (for J2ME compatibility).



parseInt
public static int parseInt(CharSequence csq, int radix, Cursor cursor)(Code)
Parses the specified character sequence from the specified position as a signed int in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained) ornull if the whole character sequence is parsed. the corresponding int.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable int.



parseLong
public static long parseLong(CharSequence csq)(Code)
Parses the specified character sequence as a decimal long.
Parameters:
  csq - the character sequence to parse. parseLong(csq, 10)
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable long.
See Also:   TypeFormat.parseLong(CharSequence,int)



parseLong
public static long parseLong(String str)(Code)
Equivalent to TypeFormat.parseLong(CharSequence) (for J2ME compatibility).



parseLong
public static long parseLong(CharSequence csq, int radix)(Code)
Parses the specified character sequence as a signed long in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing. the corresponding long.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable long.



parseLong
public static long parseLong(String str, int radix)(Code)
Equivalent to TypeFormat.parseLong(CharSequence,int) (for J2ME compatibility).



parseLong
public static long parseLong(CharSequence csq, int radix, Cursor cursor)(Code)
Parses the specified character sequence from the specified position as a signed long in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained) ornull if the whole character sequence is parsed. the corresponding long.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable long.



parseShort
public static short parseShort(CharSequence csq)(Code)
Parses the specified character sequence as a signed decimal short.
Parameters:
  csq - the character sequence to parse. parseShort(csq, 10)
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable short.
See Also:   TypeFormat.parseShort(CharSequence,int)



parseShort
public static short parseShort(CharSequence csq, int radix)(Code)
Parses the specified character sequence as a signed short in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing. the corresponding short.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable short.



parseShort
public static short parseShort(CharSequence csq, int radix, Cursor cursor)(Code)
Parses the specified character sequence from the specified position as a signed short in the specified radix.
Parameters:
  csq - the character sequence to parse.
Parameters:
  radix - the radix to be used while parsing.
Parameters:
  cursor - the current cursor position (being maintained). the corresponding short.
throws:
  NumberFormatException - if the specified character sequencedoes not contain a parsable short.



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.