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

TextFormat
abstract public class TextFormat (Code)

This class represents the base format for text parsing and formatting; it supports CharSequence and javolution.text.Appendable interfaces for greater flexibility.

It is possible to retrieve the format for any class for which the format has been registered (typically during class initialization). For example:[code] public class Complex extends RealtimeObject { private static final TextFormat CARTESIAN = ...; static { // Sets default format to cartesian, users may change it later (e.g. polar). TextFormat.setInstance(Complex.class, CARTESIAN); } public Complex valueOf(CharSequence csq) { return TextFormat.getInstance(Complex.class).parse(csq); } public Text toText() { return TextFormat.getInstance(Complex.class).format(this); } }[/code]

For parsing/formatting of primitive types, the TypeFormat utility class is recommended.

Note: The format behavior may depend upon javolution.context.LocalContext local settings in which case concurrent threads may parse differently!


author:
   Jean-Marie Dautelle
version:
   5.1, July 4, 2007

Inner Class :public static class Cursor extends ParsePosition


Constructor Summary
protected  TextFormat()
     Default constructor.

Method Summary
abstract public  Appendableformat(Object obj, Appendable dest)
     Formats the specified object into an Appendable
Parameters:
  obj - the object to format.
Parameters:
  dest - the appendable destination.
final public  Appendableformat(Object obj, TextBuilder dest)
     Formats the specified object into a TextBuilder (convenience method which does not raise IOException).
final public  Textformat(Object obj)
     Formats the specified object to a Text instance (convenience method).
Parameters:
  obj - the object being formated.
public static  TextFormatgetInstance(Class cls)
     Returns the text format for instances of specified type (class or interface).
abstract public  Objectparse(CharSequence csq, Cursor cursor)
     Parses a portion of the specified CharSequence from the specified position to produce an object.
final public  Objectparse(CharSequence csq)
     Parses a whole character sequence from the beginning to produce an object (convenience method).
public static  voidsetInstance(Class cls, TextFormat format)
     Associates the specified format to the specified type (class or interface).


Constructor Detail
TextFormat
protected TextFormat()(Code)
Default constructor.




Method Detail
format
abstract public Appendable format(Object obj, Appendable dest) throws IOException(Code)
Formats the specified object into an Appendable
Parameters:
  obj - the object to format.
Parameters:
  dest - the appendable destination. the specified Appendable.
throws:
  IOException - if an I/O exception occurs.



format
final public Appendable format(Object obj, TextBuilder dest)(Code)
Formats the specified object into a TextBuilder (convenience method which does not raise IOException).
Parameters:
  obj - the object to format.
Parameters:
  dest - the text builder destination. the specified text builder.



format
final public Text format(Object obj)(Code)
Formats the specified object to a Text instance (convenience method).
Parameters:
  obj - the object being formated. the text representing the specified object.



getInstance
public static TextFormat getInstance(Class cls)(Code)
Returns the text format for instances of specified type (class or interface). The following types are always recognized:
  • java.lang.Boolean
  • java.lang.Character
  • java.lang.Byte
  • java.lang.Short
  • java.lang.Integer
  • java.lang.Long
  • java.lang.Float
  • java.lang.Double
  • java.lang.Class
Users may register additional types using the TextFormat.setInstance TextFormat.setInstance(Class, TextFormat) static method. For example:[code] TextFormat fontFormat = new TextFormat() { public Appendable format(Font font, Appendable dest) throws IOException { return dest.append(font.getName()); } public Font parse(CharSequence csq, Cursor cursor) { CharSequence fontName = csq.subSequence(cursor.getIndex(), cursor.getEndIndex()); cursor.increment(fontName.length()); return Font.decode(fontName.toString()); } }); TextFormat.setInstance(Font.class, fontFormat); // Registers format for java.awt.Font [/code]
Parameters:
  cls - the class for which the default format is returned. the format for instances of the specified class or null if unkown.



parse
abstract public Object parse(CharSequence csq, Cursor cursor)(Code)
Parses a portion of the specified CharSequence from the specified position to produce an object. If parsing succeeds, then the index of the cursor argument is updated to the index after the last character used.
Parameters:
  csq - the CharSequence to parse.
Parameters:
  cursor - the cursor holding the current parsing index. the object parsed from the specified character sub-sequence.
throws:
  RuntimeException - if any problem occurs while parsing the specified character sequence (e.g. illegal syntax).



parse
final public Object parse(CharSequence csq)(Code)
Parses a whole character sequence from the beginning to produce an object (convenience method).
Parameters:
  csq - the whole character sequence to parse. the corresponding object.
throws:
  IllegalArgumentException - if the specified character sequence cannot be fully parsed.



setInstance
public static void setInstance(Class cls, TextFormat format)(Code)
Associates the specified format to the specified type (class or interface).
Parameters:
  cls - the class for which the default format is returned.
Parameters:
  format - the format for instances of the specified calss class.



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.