Class JRApiWriter

java.lang.Object
net.sf.jasperreports.engine.util.JRApiWriter

public class JRApiWriter extends Object
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 Details

    • EXCEPTION_MESSAGE_KEY_OUTPUT_STREAM_WRITE_ERROR

      public static final String EXCEPTION_MESSAGE_KEY_OUTPUT_STREAM_WRITE_ERROR
      See Also:
    • EXCEPTION_MESSAGE_KEY_FILE_WRITE_ERROR

      public static final String EXCEPTION_MESSAGE_KEY_FILE_WRITE_ERROR
      See Also:
  • Constructor Details

  • Method Details

    • write

      public String write(JRReport report)
    • getIndent

      public String getIndent()
    • write

      public void write(JRReport report, String destFileName) throws JRException
      Throws:
      JRException
    • write

      public void write(JRReport report, OutputStream outputStream) throws JRException
      Throws:
      JRException
    • writeReport

      public static String writeReport(JRReport report)
      See Also:
    • writeReport

      public static void writeReport(JRReport report, String destFileName) throws JRException
      Throws:
      JRException
      See Also:
    • writeReport

      public static void writeReport(JRReport report, OutputStream outputStream) throws JRException
      Throws:
      JRException
      See Also:
    • writeReport

      protected void writeReport(JRReport report, Writer aWriter)
    • writeTemplates

      protected void writeTemplates(JRReport report, String indent)
    • writeTemplate

      protected void writeTemplate(JRReportTemplate template, String templateName)
    • writeSection

      protected void writeSection(JRSection section, String sectionName, String sectionBandListGetterName)
    • writeChildElements

      public void writeChildElements(JRElementGroup elementContainer, String parentName)
      Writes the contents (child elements) of an element container.
      Parameters:
      elementContainer - the element container
    • writeElementGroup

      public void writeElementGroup(JRElementGroup elementGroup, String groupName)
    • writeBreak

      public void writeBreak(JRBreak breakElement, String breakName)
    • writeLine

      public void writeLine(JRLine line, String lineName)
    • writeReportElement

      public void writeReportElement(JRElement element, String elementName)
    • 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

      public void writeRectangle(JRRectangle rectangle, String rectangleName)
    • writeEllipse

      public void writeEllipse(JREllipse ellipse, String ellipseName)
    • writeImage

      public void writeImage(JRImage image, String imageName)
    • writeStaticText

      public void writeStaticText(JRStaticText staticText, String staticTextName)
    • writeFont

      public void writeFont(JRFont font, String fontHolderName)
    • writeTextField

      public void writeTextField(JRTextField textField, String textFieldName)
    • writeSubreport

      public void writeSubreport(JRSubreport subreport, String subreportName)
    • writeElementDataset

      public void writeElementDataset(JRElementDataset dataset, String datasetName)
      Writes the JRXML representation of an element dataset.

      The method produces a <dataset> XML element.

      Parameters:
      dataset - the element dataset
    • writeElementDataset

      public void writeElementDataset(JRElementDataset dataset, boolean skipIfEmpty, String datasetName)
      Writes the JRXML representation of an element dataset.

      The method produces a <dataset> XML element.

      Parameters:
      dataset - the element dataset
      skipIfEmpty - if set, no output will be produced if the element dataset only has default attribute values
    • writeCrosstab

      public void writeCrosstab(JRCrosstab crosstab, String crosstabName)
    • writeCrosstabTitleCell

      protected void writeCrosstabTitleCell(JRCrosstab crosstab, String crosstabName)
    • writeCrosstabRowGroup

      protected void writeCrosstabRowGroup(JRCrosstabRowGroup group, String groupName)
    • writeCrosstabColumnGroup

      protected void writeCrosstabColumnGroup(JRCrosstabColumnGroup group, String groupName)
    • writeBucket

      protected void writeBucket(JRCrosstabBucket bucket, String parentName)
    • writeCrosstabMeasure

      protected void writeCrosstabMeasure(JRCrosstabMeasure measure, String measureName)
    • writeCrosstabCell

      protected void writeCrosstabCell(JRCrosstabCell cell, String cellName)
    • writeCellContents

      protected void writeCellContents(JRCellContents contents, String cellName)
    • writeCrosstabParameter

      protected void writeCrosstabParameter(JRCrosstabParameter parameter, String parameterName)
    • writeDataset

      public void writeDataset(JRDataset dataset, String datasetName)
    • writeDatasetContents

      protected void writeDatasetContents(JRDataset dataset, String datasetName)
    • writeDatasetRun

      public void writeDatasetRun(JRDatasetRun datasetRun, String parentName)
      Outputs the XML representation of a subdataset run object.
      Parameters:
      datasetRun - the subdataset run
    • writeFrame

      public void writeFrame(JRFrame frame, String frameName)
    • writeHyperlinkParameters

      public void writeHyperlinkParameters(JRHyperlinkParameter[] parameters, String parentName)
    • writeHyperlinkParameter

      protected void writeHyperlinkParameter(JRHyperlinkParameter parameter, String parameterName)
    • writeHyperlink

      public void writeHyperlink(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(); } } /**
    • toWriteConditionalStyles

      protected boolean toWriteConditionalStyles()
    • writeConditionalStyle

      protected void writeConditionalStyle(JRConditionalStyle style, String styleName)
      Writes a conditional style.
      Parameters:
      style - the conditional style
    • writeComponentElement

      public void writeComponentElement(JRComponentElement componentElement, String componentName)
    • writeGenericElement

      public void writeGenericElement(JRGenericElement element, String elementName)
      protected XmlNamespace getNamespace() { return JASPERREPORTS_NAMESPACE; } /**
    • writeStyleReferenceAttr

      protected void writeStyleReferenceAttr(JRStyleContainer styleContainer, String styleName)
    • writeBox

      public void writeBox(JRLineBox box, String boxHolder)
    • writeParagraph

      protected void writeParagraph(JRParagraph paragraph, String paragraphHolder)
    • writeExpression

      public void writeExpression(JRExpression expression, String parentName, String expressionSuffix)
    • writeExpression

      public void writeExpression(JRExpression expression, String parentName, String expressionSuffix, String defaultClassName)
    • write

      public void write(String text)
    • write

      public void write(String pattern, Object value)
    • write

      public void write(String pattern, Object value, Object defaultValue)
    • write

      public void write(String pattern, Enum<?> value)
    • write

      public void write(String pattern, Enum<?> value, Enum<?> defaultValue)
    • write

      public void write(String pattern, int value)
    • write

      public void write(String pattern, int value, int defaultValue)
    • write

      public void write(String pattern, Float value)
    • write

      public void write(String pattern, Float value, Float defaultValue)
    • write

      public void write(String pattern, Double value)
    • write

      public void write(String pattern, Double value, Double defaultValue)
    • write

      public void write(String pattern, boolean value, boolean defaultValue)
    • write

      public void write(String pattern, byte value, byte defaultValue)
    • write

      public void write(String pattern, Color value)
    • write

      public void write(String pattern, Color value, Color defaultValue)
    • writePattern

      protected void writePattern(String pattern, Object... arguments)
    • getBooleanText

      public String getBooleanText(Boolean key)
    • close

      protected void close()
    • flush

      public void flush()
    • main

      public static void main(String[] args)