]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/reporting/SCLReportingHandler.java
a5359564632fe1b7edabc3d6f3055fde8fc8eb4a
[simantics/platform.git] / bundles / org.simantics.scl.runtime / src / org / simantics / scl / runtime / reporting / SCLReportingHandler.java
1 package org.simantics.scl.runtime.reporting;
2
3 /**
4  * <p>An interface that is used to handle printing commands from SCL 
5  * such as Prelude.print. This interface is typically stored to 
6  * SCLContext with name {@link SCLReportingHandler#REPORTING_HANDLER}.
7  * 
8  * <p>A convenient way to call the methods of this interface in 
9  * arbitrary evaluation context is to use class {@link SCLReporting}
10  * 
11  * @author Hannu Niemist&ouml;
12  */
13 public interface SCLReportingHandler {
14     public static final String REPORTING_HANDLER = "reportingHandler";
15     
16     public void print(String text);
17     public void printError(String error);
18     public void printCommand(String command);
19     public void didWork(double amount);
20
21     public static final SCLReportingHandler DEFAULT = new AbstractSCLReportingHandler() {
22         @Override
23         public void print(String text) {
24             System.out.println(text);
25         }
26
27         @Override
28         public void printError(String error) {
29             System.err.println(error);
30         }
31     };
32     
33     public static final SCLReportingHandler DEFAULT_WITHOUT_ECHO = new AbstractSCLReportingHandler() {
34         @Override
35         public void print(String text) {
36             System.out.println(text);
37         }
38
39         @Override
40         public void printError(String error) {
41             System.err.println(error);
42         }
43
44         @Override
45         public void printCommand(String command) {
46         }
47     };
48 }