1
/*
2
 * $Id$
3
 *
4
 * Copyright (C) 2003-2009 JNode.org
5
 *
6
 * This library is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU Lesser General Public License as published
8
 * by the Free Software Foundation; either version 2.1 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful, but 
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
14
 * License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public License
17
 * along with this library; If not, write to the Free Software Foundation, Inc., 
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
 */
20
 
21
package org.jnode.vm;
22
23
import java.io.InputStream;
24
import java.io.PrintStream;
25
import java.util.Map;
26
import java.util.Properties;
27
28
/**
29
 * This interface provides the hooks for implementing special semantics for 
30
 * System.in, System.out and System.err.  Specifically, it is used to implement 
31
 * 'proclet' mode where the stream objects are proxies for context specific 
32
 * streams.  It also supports 'proclet' mode contextualization of the System 
33
 * properties ({@link System#getProperties()}) and environment ({@link System#getenv()}).
34
 *
35
 * @author Levente S\u00e1ntha
36
 * @author crawley@jnode.org
37
 */
38
public interface IOContext {
39
    
40
    // FIXME ... the name of this interface is misleading.
41
42
    /**
43
     * This hook is used when "setting" System.in; i.e. via System.setIn(in).
44
     *
45
     * @param in the application supplied value for System.in
46
     */
47
    void setSystemIn(InputStream in);
48
49
    /**
50
     * This hook is used when "setting" System.out; i.e. via System.setOut(out).
51
     *
52
     * @param out the application supplied value for System.out
53
     */
54
    void setSystemOut(PrintStream out);
55
56
    /**
57
     * This hook is used when "setting" System.err; i.e. via System.setErr(err).
58
     *
59
     * @param err the application supplied value for System.err
60
     */
61
    void setSystemErr(PrintStream err);
62
63
    /**
64
     * This hook is used to get the 'real' stream underlying System.in in the current context.
65
     */
66
    InputStream getRealSystemIn();
67
68
    /**
69
     * This hook is used to get the 'real' stream underlying System.out in the current context.
70
     */
71
    PrintStream getRealSystemOut();
72
73
    /**
74
     * This hook is used to get the 'real' stream underlying System.err in the current context.
75
     */
76
    PrintStream getRealSystemErr();
77
    
78
    /**
79
     * The hook is used to get the current context's 'system properties'
80
     */
81
    Properties getProperties();
82
    
83
    /**
84
     * The hook is used to set the current context's 'system properties'
85
     */
86
    void setProperties(Properties props);
87
    
88
    /**
89
     * The hook is used to get the current context's environment; e.g. containing exported
90
     * shell variables.
91
     */
92
    Map<String, String> getEnv();
93
    
94
    /**
95
     * The hook is used to get the current context's environment.
96
     */
97
    void setEnv(Map<String, String> env);
98
99
    void enterContext();
100
101
    void exitContext();
102
    
103
    
104
}