Package net.sf.jasperreports.engine.util
Class JRApiWriter
java.lang.Object
net.sf.jasperreports.engine.util.JRApiWriter
A writer that generates the Java code required to produce a given report template programmatically, using the JasperReports API.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclose()protected voidflush()static voidprotected booleanprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidprotected voidvoidwrite(JRReport report, OutputStream outputStream) voidvoidwriteAreaChart(JRChart chart, String chartName) voidwriteAxisFormat(String indent, JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Color axisLineColor, String parentName, String axisNameSuffix, boolean isToSet) Writes out the axis format block for a chart axis.voidwriteBar3DChart(JRChart chart, String chartName) voidwriteBar3DPlot(JRBar3DPlot plot, String chartName) voidwriteBarChart(JRChart chart, String chartName) protected voidvoidwriteBreak(JRBreak breakElement, String breakName) voidwriteBubbleChart(JRChart chart, String chartName) protected voidwriteBucket(JRCrosstabBucket bucket, String parentName) voidwriteCandlestickChart(JRChart chart, String chartName) voidwriteCategoryAxisFormat(String indent, JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Double labelRotation, Color axisLineColor, String parentName) Writes out the category axis format block.protected voidwriteCellContents(JRCellContents contents, String cellName) voidwriteChartTag(JRChart chart, String chartName) voidwriteChildElements(JRElementGroup elementContainer, String parentName) Writes the contents (child elements) of an element container.voidwriteComponentElement(JRComponentElement componentElement, String componentName) protected voidwriteConditionalStyle(JRConditionalStyle style, String styleName) Writes a conditional style.voidwriteCrosstab(JRCrosstab crosstab, String crosstabName) protected voidwriteCrosstabCell(JRCrosstabCell cell, String cellName) protected voidwriteCrosstabColumnGroup(JRCrosstabColumnGroup group, String groupName) protected voidwriteCrosstabMeasure(JRCrosstabMeasure measure, String measureName) protected voidwriteCrosstabParameter(JRCrosstabParameter parameter, String parameterName) protected voidwriteCrosstabRowGroup(JRCrosstabRowGroup group, String groupName) protected voidwriteCrosstabTitleCell(JRCrosstab crosstab, String crosstabName) voidwriteDataRange(JRDataRange dataRange, String parentName, String dataRangeSuffix) Writes a data range block to the output stream.voidwriteDataset(JRDataset dataset, String datasetName) protected voidwriteDatasetContents(JRDataset dataset, String datasetName) voidwriteDatasetRun(JRDatasetRun datasetRun, String parentName) Outputs the XML representation of a subdataset run object.voidwriteElementDataset(JRElementDataset dataset, boolean skipIfEmpty, String datasetName) Writes the JRXML representation of anelement dataset.voidwriteElementDataset(JRElementDataset dataset, String datasetName) Writes the JRXML representation of anelement dataset.voidwriteElementGroup(JRElementGroup elementGroup, String groupName) voidwriteEllipse(JREllipse ellipse, String ellipseName) voidwriteExpression(JRExpression expression, String parentName, String expressionSuffix) voidwriteExpression(JRExpression expression, String parentName, String expressionSuffix, String defaultClassName) voidwriteFrame(JRFrame frame, String frameName) voidwriteGanttChart(JRChart chart, String chartName) voidwriteGenericElement(JRGenericElement element, String elementName) protected XmlNamespace getNamespace() { return JASPERREPORTS_NAMESPACE; } /**voidwriteHighLowChart(JRChart chart, String chartName) voidwriteHighLowDataset(JRHighLowDataset dataset, String parentName, String datasetNameSuffix) voidwriteHyperlink(JRHyperlink hyperlink, String parentName, String hyperlinkSuffix) public void writeHyperlink( String tagName, JRHyperlink hyperlink, String hyperlinkName) { writeHyperlink( tagName, null, hyperlink, hyperlinkName); } /** public void writeHyperlink( String tagName, XmlNamespace namespace, JRHyperlink hyperlink, String hyperlinkName) { if (hyperlink != null) { writer.startElement(tagName, namespace); writer.addEncodedAttribute(JRApiConstants.ATTRIBUTE_hyperlinkType, hyperlink.getLinkType(), JRHyperlinkHelper.HYPERLINK_TYPE_NONE); writer.addEncodedAttribute(JRApiConstants.ATTRIBUTE_hyperlinkTarget, hyperlink.getLinkTarget(), JRHyperlinkHelper.HYPERLINK_TARGET_SELF); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkReferenceExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkReferenceExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkWhenExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkWhenExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkAnchorExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkAnchorExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkPageExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkPageExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkTooltipExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(hyperlink.getHyperlinkParameters()); flush(); } } /**protected voidwriteHyperlinkParameter(JRHyperlinkParameter parameter, String parameterName) protected voidwriteHyperlinkParameters(JRHyperlinkParameter[] parameters, String parentName) voidwriteImage(JRImage image, String imageName) voidwriteItemLabel(JRItemLabel itemLabel, String parentName, String itemLabelSuffix) Writes the description of how to display item labels in a category plot.voidvoidwriteLineChart(JRChart chart, String chartName) voidwriteMeterChart(JRChart chart, String chartName) Writes the definition of a meter chart to the output stream.voidwriteMultiAxisChart(JRChart chart, String chartName) Writes the definition of a multiple axis chart to the output stream.protected voidwriteParagraph(JRParagraph paragraph, String paragraphHolder) protected voidwritePattern(String pattern, Object... arguments) voidwritePie3DChart(JRChart chart, String chartName) voidwritePieChart(JRChart chart, String chartName) voidwritePieDataset(JRPieDataset dataset, String parentName, String datasetNameSuffix) protected voidwritePropertyExpression(DatasetPropertyExpression propertyExpression, String propertyExpressionName) protected voidwritePropertyExpression(JRPropertyExpression propertyExpression, String propertyExpressionName) protected voidwritePropertyExpressions(DatasetPropertyExpression[] propertyExpressions, String propertyHolderName) protected voidwritePropertyExpressions(JRPropertyExpression[] propertyExpressions, String propertyHolderName) voidwriteRectangle(JRRectangle rectangle, String rectangleName) static StringwriteReport(JRReport report) static voidwriteReport(JRReport report, OutputStream outputStream) protected voidwriteReport(JRReport report, Writer aWriter) static voidwriteReport(JRReport report, String destFileName) voidwriteScatterChart(JRChart chart, String chartName) protected voidwriteSection(JRSection section, String sectionName, String sectionBandListGetterName) voidwriteStackedAreaChart(JRChart chart, String chartName) voidwriteStackedBar3DChart(JRChart chart, String chartName) voidwriteStackedBarChart(JRChart chart, String chartName) voidwriteStaticText(JRStaticText staticText, String staticTextName) protected voidwriteStyleReferenceAttr(JRStyleContainer styleContainer, String styleName) voidwriteSubreport(JRSubreport subreport, String subreportName) protected voidwriteTemplate(JRReportTemplate template, String templateName) protected voidwriteTemplates(JRReport report, String indent) voidwriteTextField(JRTextField textField, String textFieldName) voidwriteThermometerChart(JRChart chart, String chartName) Writes the description of a thermometer chart to the output stream.voidwriteTimeSeriesChart(JRChart chart, String chartName) voidwriteValueDataset(JRValueDataset dataset, String parentName, String datasetNameSuffix) Writes the description of a value dataset to the output stream.voidwriteValueDisplay(JRValueDisplay valueDisplay, String parentName) Writes the description of how to display a value in a valueDataset.voidwriteXyAreaChart(JRChart chart, String chartName) voidwriteXyBarChart(JRChart chart, String chartName) voidwriteXyLineChart(JRChart chart, String chartName)
-
Field Details
-
EXCEPTION_MESSAGE_KEY_OUTPUT_STREAM_WRITE_ERROR
- See Also:
-
EXCEPTION_MESSAGE_KEY_FILE_WRITE_ERROR
- See Also:
-
-
Constructor Details
-
JRApiWriter
-
-
Method Details
-
write
-
write
- Throws:
JRException
-
write
- Throws:
JRException
-
writeReport
- See Also:
-
writeReport
- Throws:
JRException- See Also:
-
writeReport
- Throws:
JRException- See Also:
-
writeReport
-
writeTemplates
-
writeTemplate
-
writeSection
-
writeChildElements
Writes the contents (child elements) of an element container.- Parameters:
elementContainer- the element container
-
writeElementGroup
-
writeBreak
-
writeLine
-
writePropertyExpressions
protected void writePropertyExpressions(JRPropertyExpression[] propertyExpressions, String propertyHolderName) -
writePropertyExpressions
protected void writePropertyExpressions(DatasetPropertyExpression[] propertyExpressions, String propertyHolderName) -
writePropertyExpression
protected void writePropertyExpression(JRPropertyExpression propertyExpression, String propertyExpressionName) -
writePropertyExpression
protected void writePropertyExpression(DatasetPropertyExpression propertyExpression, String propertyExpressionName) -
writeRectangle
-
writeEllipse
-
writeImage
-
writeStaticText
-
writeTextField
-
writeSubreport
-
writeElementDataset
Writes the JRXML representation of anelement dataset.The method produces a
<dataset>XML element.- Parameters:
dataset- the element dataset
-
writeElementDataset
Writes the JRXML representation of anelement dataset.The method produces a
<dataset>XML element.- Parameters:
dataset- the element datasetskipIfEmpty- if set, no output will be produced if the element dataset only has default attribute values
-
writePieDataset
-
writeValueDataset
Writes the description of a value dataset to the output stream.- Parameters:
dataset- the value dataset to persist
-
writeValueDisplay
Writes the description of how to display a value in a valueDataset.- Parameters:
valueDisplay- the description to save
-
writeItemLabel
Writes the description of how to display item labels in a category plot.- Parameters:
itemLabel- the description to save
-
writeDataRange
Writes a data range block to the output stream.- Parameters:
dataRange- the range to write
-
writePieChart
-
writePie3DChart
-
writeCategoryAxisFormat
public void writeCategoryAxisFormat(String indent, JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Double labelRotation, Color axisLineColor, String parentName) Writes out the category axis format block.- Parameters:
axisLabelFont- font to use for the axis labelaxisLabelColor- color to use for the axis labelaxisTickLabelFont- font to use for the label of each tick markaxisTickLabelColor- color to use for the label of each tick markaxisTickLabelMask- formatting mask to use for the label of each tick markaxisVerticalTickLabels- flag to render tick labels at 90 degreeslabelRotation- label rotation angleaxisLineColor- the color to use for the axis line and any tick marks
-
writeAxisFormat
public void writeAxisFormat(String indent, JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Color axisLineColor, String parentName, String axisNameSuffix, boolean isToSet) Writes out the axis format block for a chart axis.- Parameters:
axisLabelFont- font to use for the axis labelaxisLabelColor- color to use for the axis labelaxisTickLabelFont- font to use for the label of each tick markaxisTickLabelColor- color to use for the label of each tick markaxisTickLabelMask- formatting mask to use for the label of each tick markaxisVerticalTickLabels- flag to render tick labels at 90 degreesaxisLineColor- the color to use for the axis line and any tick marks
-
writeBar3DPlot
-
writeBarChart
-
writeBar3DChart
-
writeBubbleChart
-
writeStackedBarChart
-
writeStackedBar3DChart
-
writeLineChart
-
writeTimeSeriesChart
-
writeHighLowDataset
public void writeHighLowDataset(JRHighLowDataset dataset, String parentName, String datasetNameSuffix) -
writeHighLowChart
-
writeGanttChart
-
writeCandlestickChart
-
writeAreaChart
-
writeScatterChart
-
writeXyAreaChart
-
writeXyBarChart
-
writeXyLineChart
-
writeMeterChart
Writes the definition of a meter chart to the output stream.- Parameters:
chart- the meter chart to write
-
writeThermometerChart
Writes the description of a thermometer chart to the output stream.- Parameters:
chart- the thermometer chart to write
-
writeMultiAxisChart
Writes the definition of a multiple axis chart to the output stream.- Parameters:
chart- the multiple axis chart to write
-
writeStackedAreaChart
-
writeChartTag
-
writeCrosstab
-
writeCrosstabTitleCell
-
writeCrosstabRowGroup
-
writeCrosstabColumnGroup
-
writeBucket
-
writeCrosstabMeasure
-
writeCrosstabCell
-
writeCellContents
-
writeCrosstabParameter
-
writeDataset
-
writeDatasetContents
-
writeDatasetRun
Outputs the XML representation of a subdataset run object.- Parameters:
datasetRun- the subdataset run
-
writeFrame
-
writeHyperlinkParameters
-
writeHyperlinkParameter
-
writeHyperlink
public void writeHyperlink( String tagName, JRHyperlink hyperlink, String hyperlinkName) { writeHyperlink( tagName, null, hyperlink, hyperlinkName); } /** public void writeHyperlink( String tagName, XmlNamespace namespace, JRHyperlink hyperlink, String hyperlinkName) { if (hyperlink != null) { writer.startElement(tagName, namespace); writer.addEncodedAttribute(JRApiConstants.ATTRIBUTE_hyperlinkType, hyperlink.getLinkType(), JRHyperlinkHelper.HYPERLINK_TYPE_NONE); writer.addEncodedAttribute(JRApiConstants.ATTRIBUTE_hyperlinkTarget, hyperlink.getLinkTarget(), JRHyperlinkHelper.HYPERLINK_TARGET_SELF); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkReferenceExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkReferenceExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkWhenExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkWhenExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkAnchorExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkAnchorExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkPageExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkPageExpression(), false); writer.writeExpression(JRApiConstants.ELEMENT_hyperlinkTooltipExpression, JASPERREPORTS_NAMESPACE, hyperlink.getHyperlinkTooltipExpression(), false); writeHyperlinkParameters(hyperlink.getHyperlinkParameters()); flush(); } } /** -
toWriteConditionalStyles
protected boolean toWriteConditionalStyles() -
writeConditionalStyle
Writes a conditional style.- Parameters:
style- the conditional style
-
writeComponentElement
-
writeGenericElement
protected XmlNamespace getNamespace() { return JASPERREPORTS_NAMESPACE; } /** -
writeStyleReferenceAttr
-
writeBox
-
writeParagraph
-
writeExpression
-
writeExpression
public void writeExpression(JRExpression expression, String parentName, String expressionSuffix, String defaultClassName) -
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
write
-
writePattern
-
close
protected void close() -
flush
protected void flush() -
main
-