Java Doc for SAXalizer.java in  » Web-Framework » RSF » uk » org » ponder » saxalizer » 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 » Web Framework » RSF » uk.org.ponder.saxalizer 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.xml.sax.HandlerBase
      uk.org.ponder.saxalizer.SAXalizer

SAXalizer
public class SAXalizer extends HandlerBase (Code)
The SAXalizer class is used to deserialize a tree of XML tags into a tree of Java objects. Please note that this class is over 5 years old and is due for a very major sandblasting - many comments are extremely out of date, in addition to its using the extremely obsolete SAX1 interface. See wiki for general comments on roadmap for this dinosaur.

Note from January '06 - this code is just getting worse and worse! More than anything it exemplifies the all-engulphing "ball of wax" pattern where poor design in one area simply proliferates and sucks more and more neighbouring infrastructure down with it. Will there EVER be time to fix it... or replace it with JiBX or comparable mature solution. Will the SAXalizer reach it's 6th birthday alive??!

Every class that wishes to be SAXalized must implement (at least) the interface SAXalizable, which allows the class to report the set methods it supports for attaching subobjects to itself that correspond to XML subtags. It may also support the interface SAXalizableAttrs in order to receive the attributes of the XML tag it corresponds to -- if it does not, any such attributes are thrown away. Note that the class of a SAXalizing object may also implement the DeSAXalizable interface. In this case, if an existing subobject is present and can be delivered through the interface, SAXalizing subobjects will be delivered onto the existing subobject rather than a new one created afresh.

Two "helper" base classes are called GenericSAXImpl, which allows a Java class to store arbitary XML subtags, and SAXalizableExtraAttrs, which allows it to store arbitrary XML attributes. Note that GenericSAXImpl itself implements SAXalizableExtraAttrs. With these two helper classes, the line is blurred between serializable Java objects and objects representing a DOM-like document structure. We can even have a class which uses both styles at once; implementing named methods for particular tags it is interested in, and storing the rest in a "pool" of GenericSAXImpl.

Note that a useful modification of the standard use of SAXAccessMethodSpec to specify a set method is to use "*" as the parameter for the set method argument type. This will instruct the SAXalizer to use the exact tag name of any subtags as the argument to the Class.forName() reflection method; the class thus referenced must a) exist, and b) be a subclass of the actual argument type of the set method specified.

At the bottom (err, top) of the XML tag tree we stop using the SAXalizable interface, since there will be no further subobjects to deliver. Instead, we use a scheme that externally encodes these object's leafiness so that we can efficiently use primitive Java types to represent them such as String and Date. A global registry class called SAXLeafParser stores a hashtable of Class objects to mechanisms which can parse that type from a String. If the SAXalizer discovers the argument type supplied through the SAXalizable interface for a set method is registered with the SAXLeafParser, it uses that mechanism for parsing any character data attached to the tag into a Java object rather than continuing creating SAXalizable objects.

Note that any character data arriving for non--leaf nodes is currently ignored. Should we ever do any true DOM-style parsing using the SAXalizer, a new interface type will be required to deliver it.


Inner Class :static class ParseContext

Field Summary
 SAXalizerCallbackcallback
    
 EntityResolverStashentityresolverstash
    

Constructor Summary
public  SAXalizer(SAXalizerMappingContext mappingcontext)
    

Method Summary
public  voidblastState()
     Blasts any parse-specific state held by this SAXalizer object, making it ready to start a fresh parse.
public  voidcharacters(char[] ch, int start, int length)
     Implements the DocumentHandler interface.
public  voidendElement(String tagname)
     Implements the DocumentHandler interface.
public  voidproduceSubtree(Object rootobj, AttributeList attrlist, SAXalizerCallback callback)
     Produce a subtree of objects from a SAX stream.
public static  StringrenderLocator(Locator torender)
    
public  InputSourceresolveEntity(String publicID, String systemID)
    
public  voidsetDocumentLocator(Locator locator)
    
public  voidsetEntityResolverStash(EntityResolverStash entityresolverstash)
     Sets the EntityResolverStash this SAXalizer will use to resolve entities referred to by the XML document to be parsed.
public  voidstartElement(String tagname, AttributeList attrlist)
     Implements the DocumentHandler interface.

Field Detail
callback
SAXalizerCallback callback(Code)



entityresolverstash
EntityResolverStash entityresolverstash(Code)




Constructor Detail
SAXalizer
public SAXalizer(SAXalizerMappingContext mappingcontext)(Code)




Method Detail
blastState
public void blastState()(Code)
Blasts any parse-specific state held by this SAXalizer object, making it ready to start a fresh parse.



characters
public void characters(char[] ch, int start, int length) throws SAXException(Code)
Implements the DocumentHandler interface.
Parameters:
  ch - An array holding the character data seen in the SAX stream.
Parameters:
  start - The index of the character data within the supplied array.
Parameters:
  length - The length of the character data within the supplied array.
exception:
  SAXException - If any exception requires to be propagated from thisinterface.



endElement
public void endElement(String tagname) throws SAXException(Code)
Implements the DocumentHandler interface.
Parameters:
  tagname - The tag name for the element just closed in the SAX stream.
exception:
  SAXException - If any exception requires to be propagated from thisinterface.



produceSubtree
public void produceSubtree(Object rootobj, AttributeList attrlist, SAXalizerCallback callback) throws SAXException(Code)
Produce a subtree of objects from a SAX stream. This method produces a subtree of objects from a SAX stream, rooted at an object of the class specified, starting by interpreting the following SAX events as producing an object of the type specified. It is assumed that the startElement event for the root object that will be returned has just been seen on the stream, and that all further events in the SAX stream will be directed at this object until the matching endElement event.
Parameters:
  clazz - Produce an object of this type.
Parameters:
  attrlist - The attribute list that was attached to thestartElement tag that we just saw.
Parameters:
  callback - The caller of this method, who will receive the produced object onseeing of the endElement tag. At this point, heshould stop forwarding DocumentHandler events tothis object. This parameter may be null.
exception:
  SAXException - If an error occured while parsing the supplied input source.



renderLocator
public static String renderLocator(Locator torender)(Code)



resolveEntity
public InputSource resolveEntity(String publicID, String systemID)(Code)
Begin methods for the DocumentHandler interface *******



setDocumentLocator
public void setDocumentLocator(Locator locator)(Code)



setEntityResolverStash
public void setEntityResolverStash(EntityResolverStash entityresolverstash)(Code)
Sets the EntityResolverStash this SAXalizer will use to resolve entities referred to by the XML document to be parsed.
Parameters:
  entityresolverstash - The required EntityResolverStash object.



startElement
public void startElement(String tagname, AttributeList attrlist) throws SAXException(Code)
Implements the DocumentHandler interface.
Parameters:
  tagname - The tag name for the element just seen in the SAX stream.
Parameters:
  attrlist - The attribute list of the tag just seen in the SAX stream.
exception:
  SAXException - If any exception requires to be propagated from thisinterface.



Methods inherited from org.xml.sax.HandlerBase
public void characters(char ch, int start, int length) throws SAXException(Code)(Java Doc)
public void endDocument() throws SAXException(Code)(Java Doc)
public void endElement(String name) throws SAXException(Code)(Java Doc)
public void error(SAXParseException e) throws SAXException(Code)(Java Doc)
public void fatalError(SAXParseException e) throws SAXException(Code)(Java Doc)
public void ignorableWhitespace(char ch, int start, int length) throws SAXException(Code)(Java Doc)
public void notationDecl(String name, String publicId, String systemId)(Code)(Java Doc)
public void processingInstruction(String target, String data) throws SAXException(Code)(Java Doc)
public InputSource resolveEntity(String publicId, String systemId) throws SAXException(Code)(Java Doc)
public void setDocumentLocator(Locator locator)(Code)(Java Doc)
public void startDocument() throws SAXException(Code)(Java Doc)
public void startElement(String name, AttributeList attributes) throws SAXException(Code)(Java Doc)
public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName)(Code)(Java Doc)
public void warning(SAXParseException e) throws SAXException(Code)(Java Doc)

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.