Package de.peacei.gae.foodsupplier.out

Source Code of de.peacei.gae.foodsupplier.out.RenderingService

package de.peacei.gae.foodsupplier.out;

import java.io.OutputStream;
import java.util.List;

import com.google.inject.Singleton;

import de.peacei.gae.foodsupplier.Finals;
import de.peacei.gae.foodsupplier.data.Comment;
import de.peacei.gae.foodsupplier.data.Weekplan;
import de.peacei.gae.foodsupplier.out.json.JSONRenderer;
import de.peacei.gae.foodsupplier.out.xml.XMLRenderer;


@Singleton
public class RenderingService {
 
  public void renderWeekplan(Weekplan weekplan, OutputStream os, String format) {
   
    this.renderWeekplan(weekplan, os, format, null);
  }
 
  public void renderWeekplan(Weekplan weekplan, OutputStream os, String format, String callback) {
   
   
    Renderer renderer = null;
    renderer = getRenderer(format);
   
    if (renderer != null) {
      if(callback != null) {
        renderer.setCallback(callback);
      }
     
      renderer.renderWeekplan(weekplan, os);
    }
  }
 
  public void renderComments(List<Comment> comments, OutputStream os, String format) {
   
   
  }
 
  public void renderComments(List<Comment> comments, OutputStream os, String format, String callback) {
   
    Renderer renderer = null;
    renderer = getRenderer(format);
   
    if (renderer != null) {
      if(callback != null) {
        renderer.setCallback(callback);
      }
     
      renderer.renderComments(comments, os);
    }
  }
 
  private Renderer getRenderer(String format) {
    if (format.equals(Finals.FORMAT_JSON)) {
      return new JSONRenderer();
    }
    if (format.equals(Finals.FORMAT_XML)) {
      return new XMLRenderer();
    }
    return null;
  }
}
TOP

Related Classes of de.peacei.gae.foodsupplier.out.RenderingService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.