Package net.sf.jasperreports.xalan.data
Class XalanXmlDataSource
- java.lang.Object
-
- net.sf.jasperreports.engine.data.JRAbstractTextDataSource
-
- net.sf.jasperreports.engine.data.AbstractXmlDataSource<XalanXmlDataSource>
-
- net.sf.jasperreports.xalan.data.XalanXmlDataSource
-
- All Implemented Interfaces:
HierarchicalDataSource<XalanXmlDataSource>
,RandomAccessDataSource
,JRDataSource
,JRRewindableDataSource
public class XalanXmlDataSource extends AbstractXmlDataSource<XalanXmlDataSource>
- Author:
- Narcis Marcu (narcism@users.sourceforge.net)
-
-
Field Summary
-
Fields inherited from class net.sf.jasperreports.engine.data.AbstractXmlDataSource
PROPERTY_FIELD_EXPRESSION
-
Fields inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSource
EXCEPTION_MESSAGE_KEY_CANNOT_CONVERT_FIELD_TYPE, EXCEPTION_MESSAGE_KEY_CANNOT_MODIFY_PROPERTIES_AFTER_START, EXCEPTION_MESSAGE_KEY_NODE_NOT_AVAILABLE, EXCEPTION_MESSAGE_KEY_NULL_DOCUMENT, EXCEPTION_MESSAGE_KEY_NULL_SELECT_EXPRESSION, EXCEPTION_MESSAGE_KEY_UNKNOWN_COLUMN_NAME, EXCEPTION_MESSAGE_KEY_UNKNOWN_NUMBER_TYPE
-
-
Constructor Summary
Constructors Constructor Description XalanXmlDataSource(File file)
Creates the data source by parsing the xml document from the given file.XalanXmlDataSource(File file, String selectExpression)
Creates the data source by parsing the xml document from the given file.XalanXmlDataSource(InputStream in)
Creates the data source by parsing the xml document from the given input stream.XalanXmlDataSource(InputStream in, String selectExpression)
Creates the data source by parsing the xml document from the given input stream.XalanXmlDataSource(String uri)
Creates the data source by parsing the xml document from the given system identifier (URI).XalanXmlDataSource(String uri, String selectExpression)
Creates the data source by parsing the xml document from the given system identifier (URI).XalanXmlDataSource(Document document)
Creates the data source by parsing the xml document from the given file.XalanXmlDataSource(Document document, String selectExpression)
Creates the data source by parsing the xml document from the given file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkMoveFirst()
int
currentIndex()
XalanXmlDataSource
dataSource(String selectExpr)
Creates a sub data source using as root document the document used by "this" data source.Node
getCurrentNode()
Document
getDocument()
Access the document that this data source is based on.Object
getSelectObject(Node currentNode, String expression)
void
moveFirst()
Moves back to the first element in the data source.void
moveToRecord(int index)
boolean
next()
Tries to position the cursor on the next element in the data source.int
recordCount()
void
setDetectXmlNamespaces(boolean detectXmlNamespaces)
void
setDocumentBuilderFactory(DocumentBuilderFactory documentBuilderFactory)
void
setXmlNamespaceMap(Map<String,String> xmlNamespaceMap)
XalanXmlDataSource
subDataSource(String selectExpr)
Creates a sub data source using the current node (record) as the root of the document.Document
subDocument()
Creates a document using the current node as root.-
Methods inherited from class net.sf.jasperreports.engine.data.AbstractXmlDataSource
dataSource, getFieldExpression, getFieldValue, getText, subDataSource
-
Methods inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSource
convertNumber, convertStringValue, getConvertBean, getDatePattern, getLocale, getNumberPattern, getTextAttributes, getTimeZone, setDatePattern, setLocale, setLocale, setNumberPattern, setTextAttributes, setTextAttributes, setTimeZone, setTimeZone
-
-
-
-
Constructor Detail
-
XalanXmlDataSource
public XalanXmlDataSource(Document document) throws JRException
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
-
XalanXmlDataSource
public XalanXmlDataSource(Document document, String selectExpression) throws JRException
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 documentselectExpression
- the XPath select expression- Throws:
JRException
- if the data source cannot be created
-
XalanXmlDataSource
public XalanXmlDataSource(InputStream in) throws JRException
Creates the data source by parsing the xml document from the given input stream.- Parameters:
in
- the input stream- Throws:
JRException
- See Also:
JRXmlDataSource(Document)
-
XalanXmlDataSource
public XalanXmlDataSource(InputStream in, String selectExpression) throws JRException
Creates the data source by parsing the xml document from the given input stream.- Throws:
JRException
- See Also:
JRXmlDataSource(InputStream)
,JRXmlDataSource(Document, String)
-
XalanXmlDataSource
public XalanXmlDataSource(String uri) throws JRException
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- Throws:
JRException
- See Also:
JRXmlDataSource(Document)
-
XalanXmlDataSource
public XalanXmlDataSource(String uri, String selectExpression) throws JRException
Creates the data source by parsing the xml document from the given system identifier (URI).- Throws:
JRException
- See Also:
JRXmlDataSource(String)
,JRXmlDataSource(Document, String)
-
XalanXmlDataSource
public XalanXmlDataSource(File file) throws JRException
Creates the data source by parsing the xml document from the given file.- Parameters:
file
- the file- Throws:
JRException
- See Also:
JRXmlDataSource(Document)
-
XalanXmlDataSource
public XalanXmlDataSource(File file, String selectExpression) throws JRException
Creates the data source by parsing the xml document from the given file.- Throws:
JRException
- See Also:
JRXmlDataSource(File)
,JRXmlDataSource(Document, String)
-
-
Method Detail
-
getDocument
public Document getDocument()
Description copied from class:AbstractXmlDataSource
Access the document that this data source is based on.- Overrides:
getDocument
in classAbstractXmlDataSource<XalanXmlDataSource>
- Returns:
- the document used by this data source
-
moveFirst
public void moveFirst() throws JRException
Description copied from interface:JRRewindableDataSource
Moves back to the first element in the data source.- Throws:
JRException
-
checkMoveFirst
protected void checkMoveFirst() throws JRException
- Throws:
JRException
-
next
public boolean next() throws JRException
Description copied from interface:JRDataSource
Tries to position the cursor on the next element in the data source.- Returns:
- true if there is a next record, false otherwise
- Throws:
JRException
- if any error occurs while trying to move to the next element
-
recordCount
public int recordCount() throws JRException
- Throws:
JRException
-
currentIndex
public int currentIndex()
-
moveToRecord
public void moveToRecord(int index) throws JRException
- Throws:
JRException
-
subDocument
public Document subDocument() throws JRException
Description copied from class:AbstractXmlDataSource
Creates a document using the current node as root.- Specified by:
subDocument
in classAbstractXmlDataSource<XalanXmlDataSource>
- Returns:
- a document having the current node as root
- Throws:
JRException
-
setXmlNamespaceMap
public void setXmlNamespaceMap(Map<String,String> xmlNamespaceMap) throws JRException
- Throws:
JRException
-
setDetectXmlNamespaces
public void setDetectXmlNamespaces(boolean detectXmlNamespaces)
-
setDocumentBuilderFactory
public void setDocumentBuilderFactory(DocumentBuilderFactory documentBuilderFactory)
-
getCurrentNode
public Node getCurrentNode()
- Specified by:
getCurrentNode
in classAbstractXmlDataSource<XalanXmlDataSource>
-
getSelectObject
public Object getSelectObject(Node currentNode, String expression) throws JRException
- Specified by:
getSelectObject
in classAbstractXmlDataSource<XalanXmlDataSource>
- Throws:
JRException
-
subDataSource
public XalanXmlDataSource subDataSource(String selectExpr) throws JRException
Description copied from class:AbstractXmlDataSource
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.- Specified by:
subDataSource
in interfaceHierarchicalDataSource<XalanXmlDataSource>
- Specified by:
subDataSource
in classAbstractXmlDataSource<XalanXmlDataSource>
- Parameters:
selectExpr
- the XPath select expression- Returns:
- the xml sub data source
- Throws:
JRException
- if the sub data source couldn't be created- See Also:
JRXmlDataSource(Document, String)
-
dataSource
public XalanXmlDataSource dataSource(String selectExpr) throws JRException
Description copied from class:AbstractXmlDataSource
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.- Specified by:
dataSource
in classAbstractXmlDataSource<XalanXmlDataSource>
- Parameters:
selectExpr
- the XPath select expression- Returns:
- the xml sub data source
- Throws:
JRException
- if the sub data source couldn't be created- See Also:
JRXmlDataSource(Document, String)
-
-