Facing problem in XMLReportEmitter java class in the package:org.eclipse.birt.report.engine.emitter.xml with undefined methods namely:<br />
1)isPropertyRequired(XMLTags.rPropList
, rp)<br />
2)getReportPropValue(i,report)<br />
3)replaceTag( rp, "??"+XMLTags.rPropList, propValue )<br />
<br />
We need to know the definition of each of these methods.<br />
<br />
These are the contents of the XMLReportEmitter java class:<br />
<br />
package org.eclipse.birt.report.engine.emitter.xml;<br />
<br />
import java.io.BufferedOutputStream;<br />
import java.io.File;<br />
import java.io.FileNotFoundException;<br />
import java.io.FileOutputStream;<br />
import java.io.IOException;<br />
import java.io.OutputStream;<br />
import java.util.logging.Level;<br />
import java.util.logging.Logger;<br />
<br />
import org.eclipse.birt.core.exception.BirtException;<br />
import org.eclipse.birt.report.engine.api.RenderOptionBase;<br />
import org.eclipse.birt.report.engine.content.IReportContent;<br />
import org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter;<br />
import org.eclipse.birt.report.engine.emitter.IEmitterServices;<br />
import org.eclipse.birt.report.engine.presentation.ContentEmitterVisitor;<br />
<br />
<br />
@SuppressWarnings("deprecation")<br />
<br />
public class XMLReportEmitter extends ContentEmitterAdapter{<br />
<br />
public ContentEmitterVisitor contentVisitor = null;<br />
public LoadExportSchema exportSchema = null;<br />
public OutputStream out = null;<br />
public IEmitterServices services = null;<br />
public IReportContent report = null;;<br />
public XMLFileWriter writer = null;<br />
public Logger logger = Logger.getLogger(XMLReportEmitter.class.getName());<br />
<br />
public XMLReportEmitter(){<br />
contentVisitor = new ContentEmitterVisitor(this);<br />
}<br />
<br />
public void initialize(IEmitterServices services ){<br />
this.services = services;<br />
Object fd = services.getOption(RenderOptionBase.OUTPUT_FILE_NAME );<br />
File file = null;<br />
<br />
try{<br />
if ( fd != null ){<br />
file = new File( fd.toString());<br />
File parent = file.getParentFile();<br />
if ( parent != null && !parent.exists()){<br />
parent.mkdirs();<br />
}<br />
out = new BufferedOutputStream(new FileOutputStream(file));<br />
}<br />
} catch ( FileNotFoundException e) {<br />
logger.log(Level.WARNING, e.getMessage(), e );<br />
}<br />
if ( out == null ){<br />
Object value = services.getOption(RenderOptionBase.OUTPUT_STREAM);<br />
<br />
if ( value != null && value instanceof OutputStream ){<br />
out = (OutputStream) value;<br />
} else {<br />
try{<br />
file = new File("XMLDataExtraction_Demo.xml");<br />
out = new BufferedOutputStream<br />
( new FileOutputStream(file) );<br />
}catch(FileNotFoundException e){<br />
logger.log(Level.SEVERE, e.getMessage( ), e );<br />
System.out.println("Exception :"+e.getMessage());<br />
}<br />
}<br />
writer = new XMLFileWriter();<br />
}<br />
}<br />
<br />
public void start(IReportContent report){<br />
<br />
logger.log(Level.FINE,"[XMLReportEmitter] Start emitter.");<br />
String fileName = report.getDesign().getReportDesign().getFileName();<br />
int pos = fileName.indexOf("/");<br />
String fn = fileName.substring(pos+1,fileName.length());<br />
fileName = fn;<br />
if (fileName.length() > 0) {<br />
pos = fileName.lastIndexOf(".");<br />
if (pos > 0)<br />
fileName = fileName.substring(0, pos);<br />
fileName = fileName + ".xmlemitter";<br />
pos = fileName.lastIndexOf("/");<br />
String propFileName = fileName.substring( pos+1 , fileName.length() );<br />
String resourceFolder = report.getDesign().getReportDesign().getResourceFolder( );<br />
if (fileExists(resourceFolder + "/" + propFileName))<br />
exportSchema = new LoadExportSchema(resourceFolder + "/" + propFileName );<br />
else<br />
if (fileExists(fileName))<br />
exportSchema = new LoadExportSchema( fileName );<br />
else <br />
exportSchema = new LoadExportSchema("");<br />
}<br />
<br />
this.report = report;<br />
writer.open(out, "UTF-8");<br />
writer.startWriter();<br />
writer.closeTag(exportSchema.getExportStartTag());<br />
writer.closeTag(XMLTags.TAG_CR );<br />
String rp = exportSchema.getExportReportTag();<br />
for (int i = 0;i < XMLTags.rPropList.length;i++) {<br />
if (exportSchema.isPropertyRequired(XMLTags.rPropList, rp)) {<br />
String propValue = getReportPropValue(i,report);<br />
rp = replaceTag( rp, "??"+XMLTags.rPropList, propValue );<br />
}<br />
}<br />
writer.writeCode(rp);<br />
writer.closeTag( XMLTags.TAG_CR );<br />
}<br />
<br />
public String getReportValue(int index, IReportContent report){<br />
<br />
return "";<br />
}<br />
public void end(IReportContent report) {<br />
logger.log( Level.FINE,"[CSVReportEmitter] End report." );<br />
writer.endWriter( );<br />
writer.close( );<br />
if(out != null){<br />
try {<br />
out.close();<br />
}catch (IOException e){<br />
//logger.log( Level.WARNING, e.getMessage( ), e );<br />
System.out.println("Exception :"+e.getMessage());<br />
}<br />
}<br />
}<br />
<br />
public boolean fileExists(String filePath){<br />
<br />
File file = new File(filePath);<br />
return file.exists()?true:false;<br />
}<br />
}