Developing an Eclipse BIRT XML Report Rendering Extension, Page 3
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>
static String[ ] lPropList =
{"Bookmark","Height","Hyperlink","InlineStyle",
"Name","TOC","Width","X","Y"
};
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 );
}
- 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 ) );
}
- 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;
}
0 Comments (click to add your comment)
Networking Solutions
