class BrowseJasperReportTemplate
extends java.lang.Object
prepare(String)
function which loads
template into XML tree and performs preparation steps, and
generateReport(BrowseWidget)
function which transforms the XML tree into report
applicable to the specific browse and compiles the report.Modifier and Type | Field and Description |
---|---|
private XmlAst |
columnDataTemplate
Sub-tree representing template for a column data area.
|
private XmlAst |
columnHeaderTemplate
Sub-tree representing template for a column header.
|
private java.lang.String |
designTemplateFile
Name of the design template file.
|
private java.lang.Integer |
pageWidth
Page width specified in the report.
|
private XmlAst |
templateRoot
Root node of the prepared template.
|
Constructor and Description |
---|
BrowseJasperReportTemplate() |
Modifier and Type | Method and Description |
---|---|
private void |
cleanUUID(XmlAst root)
Remove all "uuid" attributes in the given tree.
|
private XmlAst |
findChild(XmlAst parent,
int nodeType,
java.lang.String nodeText,
boolean noError)
Find the single available child with the specified node type and text under the given parent
node.
|
private XmlAst |
findChild(XmlAst parent,
java.lang.String tag)
Find the single available child with the specified XML tag under the given parent node.
|
private XmlAst |
findChild(XmlAst parent,
java.lang.String tag,
boolean noError)
Find the single available child with the specified XML tag under the given parent node.
|
private XmlAst |
findChildPath(XmlAst parent,
java.lang.String path)
Find the single available path under the given parent node, and return the last node in this
path.
|
private java.util.List<XmlAst> |
findChildren(XmlAst parent,
int nodeType,
java.lang.String nodeText)
Find the child nodes with the specified node type and text under the given parent node.
|
private java.util.List<XmlAst> |
findChildren(XmlAst parent,
int nodeType,
java.lang.String nodeText,
boolean noError)
Find the child nodes with the specified node type and text under the given parent node.
|
private java.util.List<XmlAst> |
findChildren(XmlAst parent,
java.lang.String tag)
Find the child nodes with the specified XML tag under the given parent node.
|
(package private) net.sf.jasperreports.engine.JasperReport |
generateReport(BrowseWidget browse)
Transform the XML tree representing prepared template (
templateRoot field) into the
report applicable to the specific browse and compile it. |
private java.lang.String |
getAttribute(XmlAst node,
java.lang.String name)
Get value of the specified attribute of the specified node.
|
private int |
getAttributeInt(XmlAst node,
java.lang.String name,
int defaultValue)
Get value of the specified integer attribute of the specified node.
|
(package private) void |
prepare(java.lang.String designTemplateFile)
Load given design template into XML tree and perform preparation steps, which in the future
allow to quickly transform this tree into a report suitable for the specific browse.
|
private void |
removeAttribute(XmlAst node,
java.lang.String name)
Delete the specified attribute of the specified node.
|
private void |
setAttribute(XmlAst node,
java.lang.String name,
java.lang.String value)
Set the value of the specified attribute.
|
private void |
setPositionAndWidth(XmlAst parent,
int xPos,
int columnWidth)
Set position and width of the single
reportElement element under the given
parent node. |
private void |
setTextAlignment(XmlAst parent,
boolean right)
Set text alignment of the single
textElement element under the given
parent node. |
private XmlAst templateRoot
private XmlAst columnHeaderTemplate
private XmlAst columnDataTemplate
private java.lang.String designTemplateFile
private java.lang.Integer pageWidth
void prepare(java.lang.String designTemplateFile) throws JasperReportException
designTemplateFile
- Name of the design template file.JasperReportException
- if design template file could not be read or parsed or has invalid structure.net.sf.jasperreports.engine.JasperReport generateReport(BrowseWidget browse) throws JasperReportException
templateRoot
field) into the
report applicable to the specific browse and compile it.browse
- Browse for which the report is generated.JasperReportException
- if there was an error during creation of the browse report or the report could not
be compiled.private void setPositionAndWidth(XmlAst parent, int xPos, int columnWidth)
reportElement
element under the given
parent node.parent
- Parent node.xPos
- Element X position.columnWidth
- Element width.private void setTextAlignment(XmlAst parent, boolean right)
textElement
element under the given
parent node.parent
- Parent node.right
- true
for right alignment, false
for left alignment.private XmlAst findChildPath(XmlAst parent, java.lang.String path)
parent
- Parent node.path
- "/"-separated down path, e.g. "jasperReport/columnHeader/band". Elements of the path
are XML tags.null
if there is no
path or there are multiple matching paths.private XmlAst findChild(XmlAst parent, java.lang.String tag)
parent
- Parent node.tag
- XML tag.JasperReportXmlSearchException
- if there is no available node, or there are multiple matching nodes.private XmlAst findChild(XmlAst parent, java.lang.String tag, boolean noError)
parent
- Parent node.tag
- XML tag.noError
is
true
: returns null
if there is no available node, or
there are multiple matching nodes.JasperReportXmlSearchException
- if noError
is false
: there is no available node, or
there are multiple matching nodes.private XmlAst findChild(XmlAst parent, int nodeType, java.lang.String nodeText, boolean noError)
parent
- Parent node.nodeType
- Node type (see constants in XmlTokenTypes
).nodeText
- Node text (e.g. XML tag or attribute name).noError
is true
: returns null
if there are no
available node, or there are multiple matching nodes.JasperReportXmlSearchException
- if noError
is false
: there are no available node, or
there are multiple matching nodes.private java.util.List<XmlAst> findChildren(XmlAst parent, java.lang.String tag)
parent
- Parent node.tag
- XML tag.JasperReportXmlSearchException
- there are no available node.private java.util.List<XmlAst> findChildren(XmlAst parent, int nodeType, java.lang.String nodeText)
parent
- Parent node.nodeType
- Type of the target nodes (see constants in XmlTokenTypes
).nodeText
- Node text (e.g. XML tag or attribute name).JasperReportXmlSearchException
- there are no available node.private java.util.List<XmlAst> findChildren(XmlAst parent, int nodeType, java.lang.String nodeText, boolean noError)
parent
- Parent node.nodeType
- Type of the target nodes (see constants in XmlTokenTypes
).nodeText
- Node text (e.g. XML tag or attribute name).noError
is true
: returns null
if there are no
available nodes.JasperReportXmlSearchException
- if noError
is false
: there are no available nodes.private void cleanUUID(XmlAst root)
root
- Root of the tree.private int getAttributeInt(XmlAst node, java.lang.String name, int defaultValue)
node
- Parent node.name
- Attribute name.defaultValue
- Default value of the attribute.private java.lang.String getAttribute(XmlAst node, java.lang.String name)
node
- Parent node.name
- Attribute name.null
if there is no such attribute.private void removeAttribute(XmlAst node, java.lang.String name)
node
- Parent node.name
- Attribute name.private void setAttribute(XmlAst node, java.lang.String name, java.lang.String value)
node
- Parent node.name
- Attribute name.value
- Attribute value to set.