Package net.sf.jasperreports.engine.xml
Class JRXmlWriter
java.lang.Object
net.sf.jasperreports.engine.xml.JRXmlBaseWriter
net.sf.jasperreports.engine.xml.JRXmlWriter
A writer that produces the JRXML representation of an in-memory report.
Sometimes report designs are generated automatically using the JasperReports API. Report design objects obtained this way can be serialized for disk storage or transferred over the network, but they also can be stored in JRXML format.
The JRXML representation of a given report design object can be obtained by using one
of the public static writeReport() methods exposed by this class.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net), Minor enhancements by Barry Klawans (bklawans@users.sourceforge.net)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final XmlNamespacestatic final Stringstatic final StringFields inherited from class net.sf.jasperreports.engine.xml.JRXmlBaseWriter
PROPERTY_REPORT_VERSION, version, versionComparator, writer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected XmlNamespaceReturns the underlying stream to which this writer outputs to.Returns the XML write helper used by this report writer.booleanprotected booleanisPropertyToWrite(JRPropertiesHolder propertiesHolder, String propertyName) voidsetExcludeUuids(boolean excludeUuids) protected booleanDecides whether conditional styles are to be written.voidwrite(JRReport report, OutputStream outputStream, String encoding) voidvoidwriteAreaChart(JRChart chart) voidwriteAxisFormat(String axisFormatElementName, JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Color axisLineColor) Writes out the axis format block for a chart axis.voidwriteAxisFormat(JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Color axisLineColor) Writes out the axis format block for a chart axis.voidwriteBar3DChart(JRChart chart) voidwriteBar3DPlot(JRBar3DPlot plot) voidwriteBarChart(JRChart chart) voidwriteBreak(JRBreak breakElement) voidwriteBubbleChart(JRChart chart) protected voidwriteBucket(JRCrosstabBucket bucket) voidwriteCandlestickChart(JRChart chart) voidwriteCategoryAxisFormat(JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Double labelRotation, Color axisLineColor) Writes out the category axis format block.protected voidwriteCellContents(JRCellContents contents) voidwriteChartTag(JRChart chart) voidwriteChildElements(JRElementGroup elementContainer) Writes the contents (child elements) of an element container.voidwriteComponentElement(JRComponentElement componentElement) voidwriteCrosstab(JRCrosstab crosstab) protected voidprotected voidprotected voidwriteCrosstabMeasure(JRCrosstabMeasure measure) protected voidwriteCrosstabParameter(JRCrosstabParameter parameter) protected voidprotected voidwriteDataLevelBucket(DataLevelBucket bucket) voidwriteDataRange(JRDataRange dataRange) Writes a data range block to the output stream.voidwriteDataset(JRDataset dataset) protected voidwriteDatasetContents(JRDataset dataset) voidwriteDatasetRun(JRDatasetRun datasetRun) Outputs the XML representation of a subdataset run object.voidwriteElementDataset(JRElementDataset dataset) Writes the JRXML representation of anelement dataset.voidwriteElementDataset(JRElementDataset dataset, boolean skipIfEmpty) Writes the JRXML representation of anelement dataset.voidwriteElementDataset(JRElementDataset dataset, DatasetResetTypeEnum defaultResetType, boolean skipIfEmpty) Writes the JRXML representation of anelement dataset.voidwriteElementGroup(JRElementGroup elementGroup) voidwriteEllipse(JREllipse ellipse) protected voidwriteExpression(String name, JRExpression expression, boolean writeClass, String defaultClassName) protected voidwriteExpression(String name, XmlNamespace namespace, JRExpression expression, boolean writeClass) voidvoidwriteFrame(JRFrame frame) voidwriteGanttChart(JRChart chart) voidwriteGenericElement(JRGenericElement element) voidwriteHighLowChart(JRChart chart) voidwriteHighLowDataset(JRHighLowDataset dataset) voidwriteHyperlink(String tagName, JRHyperlink hyperlink) voidwriteHyperlink(String tagName, XmlNamespace namespace, JRHyperlink hyperlink) protected voidwriteHyperlinkParameter(JRHyperlinkParameter parameter) protected voidwriteHyperlinkParameters(JRHyperlinkParameter[] parameters) voidwriteImage(JRImage image) voidwriteItemLabel(JRItemLabel itemLabel) Writes the description of how to display item labels in a category plot.voidvoidwriteLineChart(JRChart chart) voidwriteMeterChart(JRChart chart) Writes the definition of a meter chart to the output stream.voidwriteMultiAxisChart(JRChart chart) Writes the definition of a multiple axis chart to the output stream.voidvoidwritePie3DChart(JRChart chart) voidwritePieChart(JRChart chart) voidwritePieDataset(JRPieDataset dataset) voidwriteProperties(JRPropertiesHolder propertiesHolder) protected voidwritePropertyExpression(DatasetPropertyExpression propertyExpression) protected voidwritePropertyExpression(JRPropertyExpression propertyExpression) voidwritePropertyExpressions(DatasetPropertyExpression[] propertyExpressions) voidwritePropertyExpressions(JRPropertyExpression[] propertyExpressions) voidwriteRectangle(JRRectangle rectangle) static voidwriteReport(JRReport report, OutputStream outputStream, String encoding) static StringwriteReport(JRReport report, String encoding) protected voidwriteReport(JRReport report, String encoding, Writer out) static voidwriteReport(JRReport report, String destFileName, String encoding) protected voidwriteReturnValue(ExpressionReturnValue returnValue) protected voidwriteReturnValue(VariableReturnValue returnValue) voidwriteScatterChart(JRChart chart) protected voidwriteSection(JRSection section) voidwriteStackedAreaChart(JRChart chart) voidwriteStackedBar3DChart(JRChart chart) voidwriteStackedBarChart(JRChart chart) voidwriteStaticText(JRStaticText staticText) voidwriteSubreport(JRSubreport subreport) voidwriteSubreportParameter(JRSubreportParameter subreportParameter, XmlNamespace namespace) voidwriteSubreportReturnValue(JRSubreportReturnValue returnValue, XmlNamespace namespace) protected voidwriteTemplate(JRReportTemplate template) protected voidwriteTemplates(JRReport report) voidwriteTextField(JRTextField textField) voidwriteThermometerChart(JRChart chart) Writes the description of a thermometer chart to the output stream.voidwriteTimeSeriesChart(JRChart chart) voidwriteValueDataset(JRValueDataset dataset) Writes the description of a value dataset to the output stream.voidwriteValueDisplay(JRValueDisplay valueDisplay) Writes the description of how to display a value in a valueDataset.voidwriteXyAreaChart(JRChart chart) voidwriteXyBarChart(JRChart chart) voidwriteXyLineChart(JRChart chart) Methods inherited from class net.sf.jasperreports.engine.xml.JRXmlBaseWriter
isNewerVersionOrEqual, isOlderVersionThan, useWriter, writeBox, writeBox, writeConditionalStyle, writeExpression, writeParagraph, writeParagraph, writePen, writeStyle, writeStyleReferenceAttr, writeTabStop
-
Field Details
-
JASPERREPORTS_NAMESPACE
-
EXCEPTION_MESSAGE_KEY_FILE_WRITE_ERROR
- See Also:
-
EXCEPTION_MESSAGE_KEY_OUTPUT_STREAM_WRITE_ERROR
- See Also:
-
EXCEPTION_MESSAGE_KEY_REPORT_DESIGN_WRITE_ERROR
- See Also:
-
EXCEPTION_MESSAGE_KEY_UNSUPPORTED_CHART_TYPE
- See Also:
-
PREFIX_EXCLUDE_PROPERTIES
- See Also:
-
PROPERTY_EXCLUDE_UUIDS
- See Also:
-
-
Constructor Details
-
JRXmlWriter
-
-
Method Details
-
getReport
-
isExcludeUuids
public boolean isExcludeUuids() -
setExcludeUuids
public void setExcludeUuids(boolean excludeUuids) -
write
-
write
- Throws:
JRException
-
write
- Throws:
JRException
-
writeReport
- See Also:
-
writeReport
public static void writeReport(JRReport report, String destFileName, String encoding) throws JRException - Throws:
JRException- See Also:
-
writeReport
public static void writeReport(JRReport report, OutputStream outputStream, String encoding) throws JRException - Throws:
JRException- See Also:
-
writeReport
- Throws:
IOException
-
writeProperties
- Throws:
IOException
-
isPropertyToWrite
-
writeTemplates
- Throws:
IOException
-
writeTemplate
- Parameters:
template-- Throws:
IOException
-
writeSection
- Throws:
IOException
-
writeChildElements
Writes the contents (child elements) of an element container.- Parameters:
elementContainer- the element container
-
writeElementGroup
- Throws:
IOException
-
writeBreak
- Throws:
IOException
-
writeLine
- Throws:
IOException
-
writePropertyExpressions
- Throws:
IOException
-
writePropertyExpressions
public void writePropertyExpressions(DatasetPropertyExpression[] propertyExpressions) throws IOException - Throws:
IOException
-
writePropertyExpression
- Throws:
IOException
-
writePropertyExpression
protected void writePropertyExpression(DatasetPropertyExpression propertyExpression) throws IOException - Throws:
IOException
-
writeRectangle
- Throws:
IOException
-
writeEllipse
- Throws:
IOException
-
writeImage
- Throws:
IOException
-
writeStaticText
- Throws:
IOException
-
writeFont
- Throws:
IOException
-
writeTextField
- Throws:
IOException
-
writeSubreport
- Throws:
IOException
-
writeSubreportParameter
public void writeSubreportParameter(JRSubreportParameter subreportParameter, XmlNamespace namespace) throws IOException - Throws:
IOException
-
writeElementDataset
Writes the JRXML representation of anelement dataset.The method produces a
<dataset>XML element.- Parameters:
dataset- the element dataset- Throws:
IOException- any I/O exception that occurred while writing the XML output
-
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- Throws:
IOException- any I/O exception that occurred while writing the XML output
-
writeElementDataset
public void writeElementDataset(JRElementDataset dataset, DatasetResetTypeEnum defaultResetType, boolean skipIfEmpty) throws IOException Writes the JRXML representation of anelement dataset.The method produces a
<dataset>XML element.- Parameters:
dataset- the element datasetdefaultResetType- the default dataset reset typeskipIfEmpty- if set, no output will be produced if the element dataset only has default attribute values- Throws:
IOException- any I/O exception that occurred while writing the XML output
-
writePieDataset
- Throws:
IOException
-
writeValueDataset
Writes the description of a value dataset to the output stream.- Parameters:
dataset- the value dataset to persist- Throws:
IOException
-
writeValueDisplay
Writes the description of how to display a value in a valueDataset.- Parameters:
valueDisplay- the description to save- Throws:
IOException
-
writeItemLabel
Writes the description of how to display item labels in a category plot.- Parameters:
itemLabel- the description to save- Throws:
IOException
-
writeDataRange
Writes a data range block to the output stream.- Parameters:
dataRange- the range to write- Throws:
IOException
-
writePieChart
- Throws:
IOException
-
writePie3DChart
- Throws:
IOException
-
writeCategoryAxisFormat
public void writeCategoryAxisFormat(JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Double labelRotation, Color axisLineColor) throws IOException 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- Throws:
IOException
-
writeAxisFormat
public void writeAxisFormat(String axisFormatElementName, JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Color axisLineColor) throws IOException Writes out the axis format block for a chart axis.- Parameters:
axisFormatElementName- the name of the axis format element being writtenaxisLabelFont- 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- Throws:
IOException
-
writeAxisFormat
public void writeAxisFormat(JRFont axisLabelFont, Color axisLabelColor, JRFont axisTickLabelFont, Color axisTickLabelColor, String axisTickLabelMask, Boolean axisVerticalTickLabels, Color axisLineColor) throws IOException 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- Throws:
IOException
-
writeBar3DPlot
- Throws:
IOException
-
writeBarChart
- Throws:
IOException
-
writeBar3DChart
- Throws:
IOException
-
writeBubbleChart
- Throws:
IOException
-
writeStackedBarChart
- Throws:
IOException
-
writeStackedBar3DChart
- Throws:
IOException
-
writeLineChart
- Throws:
IOException
-
writeTimeSeriesChart
- Throws:
IOException
-
writeHighLowDataset
- Throws:
IOException
-
writeHighLowChart
- Throws:
IOException
-
writeGanttChart
- Throws:
IOException
-
writeCandlestickChart
- Throws:
IOException
-
writeAreaChart
- Throws:
IOException
-
writeScatterChart
- Throws:
IOException
-
writeXyAreaChart
- Throws:
IOException
-
writeXyBarChart
- Throws:
IOException
-
writeXyLineChart
- Throws:
IOException
-
writeMeterChart
Writes the definition of a meter chart to the output stream.- Parameters:
chart- the meter chart to write- Throws:
IOException
-
writeThermometerChart
Writes the description of a thermometer chart to the output stream.- Parameters:
chart- the thermometer chart to write- Throws:
IOException
-
writeMultiAxisChart
Writes the definition of a multiple axis chart to the output stream.- Parameters:
chart- the multiple axis chart to write- Throws:
IOException
-
writeStackedAreaChart
- Throws:
IOException
-
writeChartTag
- Throws:
IOException
-
writeSubreportReturnValue
public void writeSubreportReturnValue(JRSubreportReturnValue returnValue, XmlNamespace namespace) throws IOException - Throws:
IOException
-
writeReturnValue
- Throws:
IOException
-
writeReturnValue
- Throws:
IOException
-
writeCrosstab
- Throws:
IOException
-
writeCrosstabRowGroup
- Throws:
IOException
-
writeCrosstabColumnGroup
- Throws:
IOException
-
writeBucket
- Throws:
IOException
-
writeCrosstabMeasure
- Throws:
IOException
-
writeCrosstabCell
- Throws:
IOException
-
writeCellContents
- Throws:
IOException
-
writeCrosstabParameter
- Throws:
IOException
-
writeDataset
- Throws:
IOException
-
writeDatasetContents
- Throws:
IOException
-
writeDatasetRun
Outputs the XML representation of a subdataset run object.- Parameters:
datasetRun- the subdataset run- Throws:
IOException
-
writeFrame
- Throws:
IOException
-
writeHyperlinkParameters
- Throws:
IOException
-
writeHyperlinkParameter
- Throws:
IOException
-
writeHyperlink
- Throws:
IOException
-
writeHyperlink
public void writeHyperlink(String tagName, XmlNamespace namespace, JRHyperlink hyperlink) throws IOException - Throws:
IOException
-
toWriteConditionalStyles
protected boolean toWriteConditionalStyles()Description copied from class:JRXmlBaseWriterDecides whether conditional styles are to be written.- Specified by:
toWriteConditionalStylesin classJRXmlBaseWriter- Returns:
- whether conditional styles are to be written
-
getXmlWriteHelper
Returns the XML write helper used by this report writer. The helper can be used to output XML elements and attributes.- Returns:
- the XML write helper used by this report writer
-
getUnderlyingWriter
Returns the underlying stream to which this writer outputs to.- Returns:
- the underlying stream used by this writer
-
writeComponentElement
- Throws:
IOException
-
getNamespace
-
writeGenericElement
- Throws:
IOException
-
writeMultiAxisData
- Throws:
IOException
-
writeDataLevelBucket
- Throws:
IOException
-
writeExpression
protected void writeExpression(String name, JRExpression expression, boolean writeClass, String defaultClassName) throws IOException - Throws:
IOException
-
writeExpression
protected void writeExpression(String name, XmlNamespace namespace, JRExpression expression, boolean writeClass) throws IOException - Throws:
IOException
-