September 2, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Developing an Eclipse BIRT XML Report Rendering Extension

  • March 6, 2008
  • By Jason Weathersby, Iana Chatalbasheva, and Tom Bondur
  • Send Email »
  • More Articles »

Understanding the other XMLReportEmitter methods

The XMLReportEmitter class defines the following additional methods, called at different phases of the report generation process, that provide access to the report container, pages, tables, rows, cells text, labels, data, images, hyperlinks, and other contents. The following examples show the processing for a label.

  • startLabel( ) performs the following operations:
    • Calls LoadExportSchema.getExportLabelTag( ) to get the pattern for the <label> tag specified in the <report_name>.xmlemitter property file. If the property file does not exist, the plug-in uses the following default pattern specified in the LoadExportSchema class:
    • <label>??value</label>
    • Iterates through the following label properties list defined in XMLTags to determine the properties required by the report:
    • static String[ ] lPropList =
      {"Bookmark","Height","Hyperlink","InlineStyle",
         "Name","TOC","Width","X","Y"
      };
      
    • Calls getLabelPropValue( ) to obtain each required property value and substitute the value in the <label> tag expression.
    • Calls startText( ) and XMLFileWriter.closeTag( ) to write the <label> tag to the output file.

    Listing 2 shows the startLabel( ) method code.

    Listing 2: The startLabel( ) method

    public void startLabel( ILabelContent label )
    {
       String lbl = exportSchema.getExportLabelTag();
       int len =  XMLTags.lPropList.length;
       for (int i = 0;i < XMLTags.lPropList.length;i++)
       {
          if (exportSchema.isPropertyRequired(
             XMLTags.lPropList[i], lbl))
          {
             String propValue = getLabelPropValue(i,label);
             lbl = replaceTag( lbl, "??"+XMLTags.lPropList[i],
                propValue );
          }
       }
       startText( label, lbl );
       writer.closeTag( XMLTags.TAG_CR );
    }
    
  • startText( ) performs the following operations:
    • Sets the start text logging level and writes to the log file
    • Uses ITextContent. getText( ) to get the label text value
    • Writes the <label> tag to the output file

    Listing 3 shows the startText( ) method code.

    Listing 3: The startText( ) method

    public void startText( ITextContent text,
                           String exportTag )
    {
       logger.log( Level.FINE,
          "[XMLReportEmitter] Start text" );
       String textValue = text.getText( );
       writer.writeCode( replaceTag( exportTag,
          XMLTags.valueTag, textValue ) );
    }
    
  • getLabelPropValue( ) performs the following operations:
    • Calls the appropriate IContent accessor method to obtain the property value
    • Returns the value to startLabel( ) for substitution in the <label> tag and writing the tag to the XML output file

    Listing 4 shows the getLabelPropValue( ) method code.

    Listing 4: The getLabelPropValue( ) method

    private String getLabelPropValue( int property,
       ILabelContent label)
    {
       String propValue;
    
       switch (property) {
          case 0: // "Bookmark":
             propValue = label.getBookmark( );
             break;
          case 1: // "Height":
             if ( label.getHeight( ) != null )
                propValue
             else
                propValue = "";
             break;
          case 2: //"Hyperlink":
             if ( label.getHyperlinkAction( ) != null )
                propValue =
                   label.getHyperlinkAction( ).getHyperlink( );
             else propValue = "";
             break;
          ...
             case 8: //"Y":
                if ( label.getY( ) != null )
                   propValue = label.getY( ).toString( );
                else
                   propValue = "";
                break;
          default: propValue = "";
             break;
       }
       if ( propValue == null )
          propValue = "";
             return propValue;
    }
    




Page 3 of 6



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel