|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--pnuts.lang.Context
Context represents an internal state in Pnuts runtime environment. A Context object contains the following information.
Field Summary | |
protected pnuts.lang.SymbolTable |
autoloadTable
|
protected int |
beginLine
|
static java.io.PrintWriter |
defaultErrorStream
|
static java.io.PrintWriter |
defaultOutputStream
|
static java.io.PrintWriter |
defaultTerminalStream
|
protected int |
depth
|
protected int |
endLine
|
protected pnuts.lang.SymbolTable |
environment
|
protected pnuts.lang.SymbolTable |
importedFunctions
|
protected pnuts.lang.ImportEnv |
importEnv
|
protected pnuts.lang.Stack |
loadingResource
|
protected pnuts.lang.SymbolTable |
provideTable
|
protected java.util.Hashtable |
unitTable
|
protected java.util.Hashtable |
usedPackage
|
Constructor Summary | |
Context()
Create a new context |
|
Context(Context context)
Creates a context from a template |
|
Context(Package pkg)
Creates a context. |
|
Context(java.lang.String pkg)
Creates a context. |
Method Summary | |
void |
autoload(java.lang.String name,
AutoloadHook hook)
|
void |
autoload(java.lang.String name,
java.lang.String file)
|
java.lang.Object |
clone()
Make a clone of the context |
java.lang.Object |
clone(boolean clear)
Make a clone of the context |
protected void |
close()
|
boolean |
defined(java.lang.String name)
|
java.lang.Object |
get(java.lang.String key)
Get an environemnt variable associated with this context |
java.lang.ClassLoader |
getClassLoader()
|
Package |
getCurrentPackage()
get the current package |
java.io.PrintWriter |
getErrorStream()
Get an OutputStream or a Writer to which error() write message |
java.lang.Object |
getId(java.lang.String interned)
Gets the value of a symbol |
java.lang.String |
getName()
Gets the name of the context |
java.io.PrintWriter |
getOutputStream()
get output stream of the context |
PnutsImpl |
getPnutsImpl()
Gets the PnutsImpl object associated with this context |
protected java.lang.Object |
getScriptSource()
Get the source of the script. |
java.io.PrintWriter |
getTerminalStream()
get terminal-output-stream of the context |
java.util.Enumeration |
keys()
Returns an enumeration of the keys in the environment of this context. |
protected void |
onError(java.lang.Throwable t)
This method is called when an exception is thrown. |
protected void |
onExit(java.lang.Object arg)
This method is called when the excecution is terminated normally. |
protected void |
open(java.lang.String[] locals)
|
void |
registerQuantityFactory(java.lang.String unit,
QuantityFactory fac)
Defines a unit. |
void |
set(java.lang.String key,
java.lang.Object value)
Define an environemnt variable associated with this context |
void |
setClassLoader(java.lang.ClassLoader loader)
|
void |
setCurrentPackage(Package pkg)
set the current package |
void |
setErrorStream(java.lang.Object errorStream)
set an OutputStream or a Writer to which error() write message If errorStream is null, exception is thrown out of eval loop. |
void |
setErrorStream(java.lang.Object errorStream,
boolean autoFlush)
Set an OutputStream or a Writer to which error() write message If errorStream is null, exception is thrown out of eval loop. |
void |
setName(java.lang.String name)
Sets the name of the context |
void |
setOutputStream(java.lang.Object outputStream)
|
void |
setOutputStream(java.lang.Object out,
boolean autoFlush)
set output stream of the context |
void |
setPnutsImpl(PnutsImpl impl)
Changes the PnutsImpl object associated with this context |
void |
setTerminalStream(java.lang.Object stream)
|
void |
setTerminalStream(java.lang.Object str,
boolean autoFlush)
set terminal-output-stream of the context |
protected void |
setValue(java.lang.String symbol,
java.lang.Object obj)
|
protected java.lang.Object |
undefinedHook(java.lang.String symbol)
|
protected void |
updateLine(SimpleNode node)
|
protected void |
updateLine(SimpleNode node,
int beginLine,
int endLine)
|
java.lang.String[] |
usedPackages()
Returns the list of use()'d packages |
void |
usePackage(java.lang.String name)
Add a package to the use()'d package list. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.io.PrintWriter defaultOutputStream
public static final java.io.PrintWriter defaultTerminalStream
public static final java.io.PrintWriter defaultErrorStream
protected int depth
protected pnuts.lang.Stack loadingResource
protected int beginLine
protected int endLine
protected pnuts.lang.ImportEnv importEnv
protected java.util.Hashtable usedPackage
protected pnuts.lang.SymbolTable autoloadTable
protected pnuts.lang.SymbolTable importedFunctions
protected pnuts.lang.SymbolTable provideTable
protected java.util.Hashtable unitTable
protected pnuts.lang.SymbolTable environment
Constructor Detail |
public Context()
public Context(java.lang.String pkg)
pkg
- the name of the package.public Context(Package pkg)
pkg
- the initial package of the context.public Context(Context context)
context
- The templateMethod Detail |
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.Object clone(boolean clear)
clear
- If true, import() state and current package are reset
to the default values.public void setName(java.lang.String name)
name
- The name of the context.public java.lang.String getName()
public void setPnutsImpl(PnutsImpl impl)
impl
- The PnutsImpl object, which defines the implementation
of the interpreter. eval(), load(), and loadFile() of pnuts.lang.Pnuts
select an implementation (pure interpreter, on-the-fly compiler, etc.),
according to the context passed to the methods.public PnutsImpl getPnutsImpl()
public java.lang.Object get(java.lang.String key)
key
- the name of the variablepublic void set(java.lang.String key, java.lang.Object value)
The key name which starts with "pnuts." is reserved.
key
- the name of the variablevalue
- the value of the variablepublic java.util.Enumeration keys()
public void setOutputStream(java.lang.Object out, boolean autoFlush)
public void setOutputStream(java.lang.Object outputStream)
public java.io.PrintWriter getOutputStream()
public void setTerminalStream(java.lang.Object str, boolean autoFlush)
public void setTerminalStream(java.lang.Object stream)
public java.io.PrintWriter getTerminalStream()
public void setErrorStream(java.lang.Object errorStream, boolean autoFlush)
public void setErrorStream(java.lang.Object errorStream)
public java.io.PrintWriter getErrorStream()
public Package getCurrentPackage()
public void setCurrentPackage(Package pkg)
public void setClassLoader(java.lang.ClassLoader loader)
public java.lang.ClassLoader getClassLoader()
public java.lang.String[] usedPackages()
public void usePackage(java.lang.String name)
name
- the package nameprotected java.lang.Object getScriptSource()
java.net.URL object, when the script is not precompiled pnuts.lang.Runtime object, when the script is precompiled
protected void updateLine(SimpleNode node)
protected void updateLine(SimpleNode node, int beginLine, int endLine)
protected void onExit(java.lang.Object arg)
protected void onError(java.lang.Throwable t)
public java.lang.Object getId(java.lang.String interned)
interned
- a symbol (interned string)public void autoload(java.lang.String name, java.lang.String file)
public void autoload(java.lang.String name, AutoloadHook hook)
protected java.lang.Object undefinedHook(java.lang.String symbol)
public boolean defined(java.lang.String name)
public void registerQuantityFactory(java.lang.String unit, QuantityFactory fac)
unit
- The unit symbolfac
- A QuantityFactory object which defines what kind of object is created
when a decimal number with this unit symbol is evaluated.protected void open(java.lang.String[] locals)
protected void close()
protected void setValue(java.lang.String symbol, java.lang.Object obj)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |