package net.sf.jasperreports.engine.xml;

import java.io.IOException;
import net.sf.jasperreports.crosstabs.JRCrosstab;
import net.sf.jasperreports.engine.JRBreak;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRElementGroup;
import net.sf.jasperreports.engine.JREllipse;
import net.sf.jasperreports.engine.JRFrame;
import net.sf.jasperreports.engine.JRImage;
import net.sf.jasperreports.engine.JRLine;
import net.sf.jasperreports.engine.JRRectangle;
import net.sf.jasperreports.engine.JRRuntimeException;
import net.sf.jasperreports.engine.JRStaticText;
import net.sf.jasperreports.engine.JRSubreport;
import net.sf.jasperreports.engine.JRTextField;
import net.sf.jasperreports.engine.JRVisitor;

public class XmlWriterVisitor implements JRVisitor {
  private JRXmlWriter xmlWriter = null;
  
  public XmlWriterVisitor(JRXmlWriter xmlWriter) {
    this.xmlWriter = xmlWriter;
  }
  
  public void visitBreak(JRBreak breakElement) {
    try {
      this.xmlWriter.writeBreak(breakElement);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitChart(JRChart chart) {
    try {
      this.xmlWriter.writeChartTag(chart);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitCrosstab(JRCrosstab crosstab) {
    try {
      this.xmlWriter.writeCrosstab(crosstab);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitElementGroup(JRElementGroup elementGroup) {
    try {
      this.xmlWriter.writeElementGroup(elementGroup);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitEllipse(JREllipse ellipse) {
    try {
      this.xmlWriter.writeEllipse(ellipse);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitFrame(JRFrame frame) {
    try {
      this.xmlWriter.writeFrame(frame);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitImage(JRImage image) {
    try {
      this.xmlWriter.writeImage(image);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitLine(JRLine line) {
    try {
      this.xmlWriter.writeLine(line);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitRectangle(JRRectangle rectangle) {
    try {
      this.xmlWriter.writeRectangle(rectangle);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitStaticText(JRStaticText staticText) {
    try {
      this.xmlWriter.writeStaticText(staticText);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitSubreport(JRSubreport subreport) {
    try {
      this.xmlWriter.writeSubreport(subreport);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
  
  public void visitTextField(JRTextField textField) {
    try {
      this.xmlWriter.writeTextField(textField);
    } catch (IOException e) {
      throw new JRRuntimeException(e);
    } 
  }
}
