001package org.javasimon.console.action;
002
003import org.javasimon.Simon;
004import org.javasimon.console.ActionContext;
005import org.javasimon.console.SimonConsolePlugin;
006import org.javasimon.console.json.ObjectJS;
007import org.javasimon.console.text.StringifierFactory;
008
009import java.io.IOException;
010
011/**
012 * Base class for Detail plugins.
013 *
014 * @author gquintana
015 */
016public abstract class DetailPlugin extends SimonConsolePlugin {
017
018        protected DetailPlugin(String id, String label) {
019                super(id, label);
020        }
021
022        /**
023         * Indicates this plugin applies to this kind of Simon.
024         *
025         * @param simon Simon
026         * @return {@code true} if plugin can be executed
027         */
028        public boolean supports(Simon simon) {
029                return true;
030        }
031
032        /**
033         * Callback for flat HTML rendering.
034         *
035         * @param context Context (Request, parameters...)
036         * @param htmlBuilder HTML Builder (Response generation helper)
037         * @param simon Simon to render.
038         */
039        public DetailHtmlBuilder executeHtml(ActionContext context, DetailHtmlBuilder htmlBuilder, StringifierFactory htmlStringifierFactory, Simon simon) throws IOException {
040                return htmlBuilder;
041        }
042
043        /**
044         * Callback for flat JSON rendering.
045         *
046         * @param context Context (Request, parameters...)
047         * @param simon Simon to render
048         */
049        public ObjectJS executeJson(ActionContext context, StringifierFactory jsonStringifierFactory, Simon simon) {
050                return null;
051        }
052}