Java Doc for JRXmlDataSource.java in  » Report » jasperreports-2.0.1 » net » sf » jasperreports » engine » data » 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 » Report » jasperreports 2.0.1 » net.sf.jasperreports.engine.data 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   net.sf.jasperreports.engine.data.JRXmlDataSource

JRXmlDataSource
public class JRXmlDataSource implements JRRewindableDataSource(Code)
XML data source implementation that allows to access the data from a xml document using XPath expressions.

The data source is constructed around a node set (record set) selected by an XPath expression from the xml document.

Each field can provide an additional XPath expresion that will be used to select its value. This expression must be specified using the "fieldDescription" element of the field. The expression is evaluated in the context of the current node thus the expression should be relative to the current node.

To support subreports, sub data sources can be created. There are two different methods for creating sub data sources. The first one allows to create a sub data source rooted at the current node. The current node can be seen as a new document around which the sub data source is created. The second method allows to create a sub data source that is rooted at the same document that is used by the data source but uses a different XPath select expression.

Example:

 <A>
 <B id="0">
 <C>
 <C>
 </B>
 <B id="1">
 <C>
 <C>
 </B>
 <D id="3">
 <E>
 <E>
 </D>
 </A>
 

Data source creation

  • new JRXmlDataSource(document, "/A/B") - creates a data source with two nodes of type /A/B
  • new JRXmlDataSource(document, "/A/D") - creates a data source with two nodes of type /A/D
Field selection
  • @id - will select the "id" attribute from the current node
  • C - will select the value of the first node of type C under the current node.
Sub data source creation
  • "((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/B/C") - in the context of the node B, creates a data source with elements of type /B/C
  • "((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/A/D") - creates a data source with elements of type /A/D

Generally the full power of XPath expression is available. As an example, "/A/B[@id > 0"] will select all the nodes of type /A/B having the id greater than 0. You'll find a short XPath tutorial here.

Note on performance. Due to the fact that all the XPath expression are interpreted the data source performance is not great. For the cases where more speed is required, consider implementing a custom data source that directly accesses the Document through the DOM API.


author:
   Peter Severin (peter_p_s@sourceforge.net, contact@jasperassistant.com)
version:
   $Id: JRXmlDataSource.java 1790 2007-07-26 10:45:46Z lucianc $
See Also:   JRXPathExecuterUtils



Constructor Summary
public  JRXmlDataSource(Document document)
     Creates the data source by parsing the xml document from the given file.
public  JRXmlDataSource(Document document, String selectExpression)
     Creates the data source by parsing the xml document from the given file.
public  JRXmlDataSource(InputStream in)
     Creates the data source by parsing the xml document from the given input stream.
public  JRXmlDataSource(InputStream in, String selectExpression)
     Creates the data source by parsing the xml document from the given input stream.
public  JRXmlDataSource(String uri)
     Creates the data source by parsing the xml document from the given system identifier (URI).
public  JRXmlDataSource(String uri, String selectExpression)
     Creates the data source by parsing the xml document from the given system identifier (URI).
public  JRXmlDataSource(File file)
     Creates the data source by parsing the xml document from the given file.
public  JRXmlDataSource(File file, String selectExpression)
     Creates the data source by parsing the xml document from the given file.

Method Summary
protected  ObjectconvertNumber(Number number, Class valueClass)
    
protected  ObjectconvertStringValue(String text, Class valueClass)
    
public  JRXmlDataSourcedataSource(String selectExpr)
     Creates a sub data source using as root document the document used by "this" data source.
public  JRXmlDataSourcedataSource()
     Creates a sub data source using as root document the document used by "this" data source.
protected  LocaleConvertUtilsBeangetConvertBean()
    
public  StringgetDatePattern()
    
public  ObjectgetFieldValue(JRField jrField)
    
public  LocalegetLocale()
    
public  StringgetNumberPattern()
    
public  StringgetText(Node node)
     Return the text that a node contains.
public  TimeZonegetTimeZone()
    
public static  voidmain(String[] args)
    
public  voidmoveFirst()
    
public  booleannext()
    
public  voidsetDatePattern(String datePattern)
    
public  voidsetLocale(Locale locale)
    
public  voidsetNumberPattern(String numberPattern)
    
public  voidsetTimeZone(TimeZone timeZone)
    
public  JRXmlDataSourcesubDataSource(String selectExpr)
     Creates a sub data source using the current node (record) as the root of the document.
public  JRXmlDataSourcesubDataSource()
     Creates a sub data source using the current node (record) as the root of the document.
public  DocumentsubDocument()
     Creates a document using the current node as root.


Constructor Detail
JRXmlDataSource
public JRXmlDataSource(Document document) throws JRException(Code)
Creates the data source by parsing the xml document from the given file. The data source will contain exactly one record consisting of the document node itself.
Parameters:
  document - the document
throws:
  JRException - if the data source cannot be created



JRXmlDataSource
public JRXmlDataSource(Document document, String selectExpression) throws JRException(Code)
Creates the data source by parsing the xml document from the given file. An additional XPath expression specifies the select criteria that produces the nodes (records) for the data source.
Parameters:
  document - the document
Parameters:
  selectExpression - the XPath select expression
throws:
  JRException - if the data source cannot be created



JRXmlDataSource
public JRXmlDataSource(InputStream in) throws JRException(Code)
Creates the data source by parsing the xml document from the given input stream.
Parameters:
  in - the input stream
See Also:   JRXmlDataSource.JRXmlDataSource(Document)
See Also:   



JRXmlDataSource
public JRXmlDataSource(InputStream in, String selectExpression) throws JRException(Code)
Creates the data source by parsing the xml document from the given input stream.
See Also:   JRXmlDataSource.JRXmlDataSource(InputStream)
See Also:   
See Also:   JRXmlDataSource.JRXmlDataSource(DocumentString)
See Also:   



JRXmlDataSource
public JRXmlDataSource(String uri) throws JRException(Code)
Creates the data source by parsing the xml document from the given system identifier (URI).

If the system identifier is a URL, it must be full resolved.


Parameters:
  uri - the system identifier
See Also:   JRXmlDataSource.JRXmlDataSource(Document)
See Also:   



JRXmlDataSource
public JRXmlDataSource(String uri, String selectExpression) throws JRException(Code)
Creates the data source by parsing the xml document from the given system identifier (URI).
See Also:   JRXmlDataSource.JRXmlDataSource(String)
See Also:   
See Also:   JRXmlDataSource.JRXmlDataSource(DocumentString)
See Also:   



JRXmlDataSource
public JRXmlDataSource(File file) throws JRException(Code)
Creates the data source by parsing the xml document from the given file.
Parameters:
  file - the file
See Also:   JRXmlDataSource.JRXmlDataSource(Document)
See Also:   



JRXmlDataSource
public JRXmlDataSource(File file, String selectExpression) throws JRException(Code)
Creates the data source by parsing the xml document from the given file.
See Also:   JRXmlDataSource.JRXmlDataSource(File)
See Also:   
See Also:   JRXmlDataSource.JRXmlDataSource(DocumentString)
See Also:   




Method Detail
convertNumber
protected Object convertNumber(Number number, Class valueClass) throws JRException(Code)



convertStringValue
protected Object convertStringValue(String text, Class valueClass)(Code)



dataSource
public JRXmlDataSource dataSource(String selectExpr) throws JRException(Code)
Creates a sub data source using as root document the document used by "this" data source. An additional XPath expression specifies the select criteria applied to this document and that produces the nodes (records) for the data source.
Parameters:
  selectExpr - the XPath select expression the xml sub data source
throws:
  JRException - if the sub data source couldn't be created
See Also:   JRXmlDataSource.JRXmlDataSource(DocumentString)



dataSource
public JRXmlDataSource dataSource() throws JRException(Code)
Creates a sub data source using as root document the document used by "this" data source. The data source will contain exactly one record consisting of the document node itself. the xml sub data source
throws:
  JRException - if the data source cannot be created
See Also:   JRXmlDataSource.dataSource(String)
See Also:   JRXmlDataSource.JRXmlDataSource(Document)



getConvertBean
protected LocaleConvertUtilsBean getConvertBean()(Code)



getDatePattern
public String getDatePattern()(Code)



getFieldValue
public Object getFieldValue(JRField jrField) throws JRException(Code)



getLocale
public Locale getLocale()(Code)



getNumberPattern
public String getNumberPattern()(Code)



getText
public String getText(Node node)(Code)
Return the text that a node contains. This routine:
  • Ignores comments and processing instructions.
  • Concatenates TEXT nodes, CDATA nodes, and the results of recursively processing EntityRef nodes.
  • Ignores any element nodes in the sublist. (Other possible options are to recurse into element sublists or throw an exception.)

Parameters:
  node - a DOM node a String representing node contents or null



getTimeZone
public TimeZone getTimeZone()(Code)



main
public static void main(String[] args) throws Exception(Code)



moveFirst
public void moveFirst() throws JRException(Code)



next
public boolean next()(Code)



setDatePattern
public void setDatePattern(String datePattern)(Code)



setLocale
public void setLocale(Locale locale)(Code)



setNumberPattern
public void setNumberPattern(String numberPattern)(Code)



setTimeZone
public void setTimeZone(TimeZone timeZone)(Code)



subDataSource
public JRXmlDataSource subDataSource(String selectExpr) throws JRException(Code)
Creates a sub data source using the current node (record) as the root of the document. An additional XPath expression specifies the select criteria applied to this new document and that produces the nodes (records) for the data source.
Parameters:
  selectExpr - the XPath select expression the xml sub data source
throws:
  JRException - if the sub data source couldn't be created
See Also:   JRXmlDataSource.JRXmlDataSource(DocumentString)



subDataSource
public JRXmlDataSource subDataSource() throws JRException(Code)
Creates a sub data source using the current node (record) as the root of the document. The data source will contain exactly one record consisting of the document node itself. the xml sub data source
throws:
  JRException - if the data source cannot be created
See Also:   JRXmlDataSource.subDataSource(String)
See Also:   JRXmlDataSource.JRXmlDataSource(Document)



subDocument
public Document subDocument() throws JRException(Code)
Creates a document using the current node as root. a document having the current node as root
throws:
  JRException -



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.