Package net.sf.jasperreports.jaxen.data
Class JaxenXmlDataSource
- java.lang.Object
-
- net.sf.jasperreports.engine.data.JRAbstractTextDataSource
-
- net.sf.jasperreports.engine.data.AbstractXmlDataSource<JaxenXmlDataSource>
-
- net.sf.jasperreports.jaxen.data.JaxenXmlDataSource
-
- All Implemented Interfaces:
HierarchicalDataSource<JaxenXmlDataSource>
,RandomAccessDataSource
,JRDataSource
,JRRewindableDataSource
public class JaxenXmlDataSource extends AbstractXmlDataSource<JaxenXmlDataSource>
- 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 JaxenXmlDataSource(File file)
Creates the data source by parsing the xml document from the given file.JaxenXmlDataSource(File file, String selectExpression)
Creates the data source by parsing the xml document from the given file.JaxenXmlDataSource(InputStream in)
Creates the data source by parsing the xml document from the given input stream.JaxenXmlDataSource(InputStream in, String selectExpression)
Creates the data source by parsing the xml document from the given input stream.JaxenXmlDataSource(String uri)
Creates the data source by parsing the xml document from the given system identifier (URI).JaxenXmlDataSource(String uri, String selectExpression)
Creates the data source by parsing the xml document from the given system identifier (URI).JaxenXmlDataSource(Document document)
Creates the data source by parsing the xml document from the given file.JaxenXmlDataSource(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()
JaxenXmlDataSource
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)
JaxenXmlDataSource
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
-
JaxenXmlDataSource
public JaxenXmlDataSource(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
-
JaxenXmlDataSource
public JaxenXmlDataSource(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
-
JaxenXmlDataSource
public JaxenXmlDataSource(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)
-
JaxenXmlDataSource
public JaxenXmlDataSource(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)
-
JaxenXmlDataSource
public JaxenXmlDataSource(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)
-
JaxenXmlDataSource
public JaxenXmlDataSource(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)
-
JaxenXmlDataSource
public JaxenXmlDataSource(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)
-
JaxenXmlDataSource
public JaxenXmlDataSource(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<JaxenXmlDataSource>
- 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 NoRecordAtIndexException
- Throws:
NoRecordAtIndexException
-
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<JaxenXmlDataSource>
- 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<JaxenXmlDataSource>
-
getSelectObject
public Object getSelectObject(Node currentNode, String expression) throws JRException
- Specified by:
getSelectObject
in classAbstractXmlDataSource<JaxenXmlDataSource>
- Throws:
JRException
-
subDataSource
public JaxenXmlDataSource 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<JaxenXmlDataSource>
- Specified by:
subDataSource
in classAbstractXmlDataSource<JaxenXmlDataSource>
- 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 JaxenXmlDataSource 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<JaxenXmlDataSource>
- 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)
-
-