Class 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 Detail

      • EXCEPTION_MESSAGE_KEY_OUTPUT_STREAM_WRITE_ERROR

        public static final String EXCEPTION_MESSAGE_KEY_OUTPUT_STREAM_WRITE_ERROR
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_FILE_WRITE_ERROR

        public static final String EXCEPTION_MESSAGE_KEY_FILE_WRITE_ERROR
        See Also:
        Constant Field Values
    • Method Detail

      • getIndent

        public String getIndent()
      • writeReport

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

        protected void writeTemplates​(JRReport report,
                                      String indent)
      • 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)
      • writePropertyExpression

        protected void writePropertyExpression​(JRPropertyExpression 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)
      • writeCellContents

        protected void writeCellContents​(JRCellContents contents,
                                         String cellName)
      • 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)
      • 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)
      • writeParagraph

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

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

        public void write​(String text)
      • write

        public void write​(String pattern,
                          Object value)
      • 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,
                          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)
      • close

        protected void close()
      • flush

        public void flush()
      • main

        public static void main​(String[] args)