|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpnuts.lang.Package
public class Package
This class represents a Pnuts' package (not Java's).
Field Summary | |
---|---|
protected pnuts.lang.SymbolTable |
autoloadTable
|
protected pnuts.lang.SymbolTable |
exportedSymbols
|
protected boolean |
exports
|
static Package |
globalPackage
The package with name "". |
protected boolean |
initialized
|
protected java.lang.String |
name
The name of the package. |
protected java.util.Hashtable |
packages
All packages with a non-null name |
protected Package |
parent
|
protected java.util.Vector |
providedModuleNames
|
protected java.util.Vector |
requiredModuleNames
|
protected Package |
root
|
protected boolean |
usedAsModule
|
Constructor Summary | |
---|---|
|
Package()
Creates a package that is not visible from other packages. |
|
Package(java.lang.String name)
Creates a package and register it in a static hashtable. |
|
Package(java.lang.String name,
Package parent)
Creates a package and register it in a static hashtable. |
protected |
Package(java.lang.String name,
Package parent,
Package root)
Creates a package and register it in a static hashtable. |
Method Summary | |
---|---|
protected void |
addPackage(Package pkg,
Context context)
|
java.util.Map |
asMap()
Returns a Map object that wraps this package |
void |
autoload(java.lang.String name,
AutoloadHook hook)
Registers an AutoloadHook for the name. |
void |
autoload(java.lang.String name,
java.lang.String file,
Context context)
Registers an autoload script for the name. |
java.util.Enumeration |
bindings()
Returns an enumeration of the NamedValues in the symbol table. |
void |
clear()
Deletes all name-value bindings. |
void |
clear(java.lang.String symbol,
Context context)
Deletes a symbol from the package. |
java.lang.Object |
clone()
Returns a clone package. |
boolean |
defined(java.lang.String name,
Context context)
Checks if the specified name is already defined in this package. |
java.util.Enumeration |
elements()
Deprecated. |
void |
export(java.lang.String name)
Exports a symbol of the module |
static Package |
find(java.lang.String pkg)
Deprecated. replaced by find(String, Context) |
static Package |
find(java.lang.String pkg,
Context context)
Find a named package. |
java.lang.Object |
get(java.lang.String interned)
Gets the value of a variable. |
java.lang.Object |
get(java.lang.String symbol,
Context context)
Get the value of a symbol in the package. |
static Package |
getGlobalPackage()
|
java.lang.String |
getName()
|
static Package |
getPackage(java.lang.String pkg)
If package "pkg" exists returns the package, otherwise creates and returns it. |
static Package |
getPackage(java.lang.String pkg,
Context context)
If package "pkg" exists returns the package, otherwise creates and returns it. |
Package |
getParent()
Returns the parent package. |
protected void |
init(Context context)
This method is called when the package become the current package with package() function. |
protected void |
initializeModule()
Starts using this package as a module. |
java.util.Enumeration |
keys()
Returns an enumeration of the keys in the symbol table. |
NamedValue |
lookup(java.lang.String interned)
Looks for a name-value binding in the symbol table chain. |
NamedValue |
lookup(java.lang.String symbol,
Context context)
Looks up a symbol in this package. |
protected NamedValue |
lookupRecursively(java.lang.String symbol,
Context context)
Lookup the symbol in the package. |
Package |
newInstance(java.lang.String name)
Creates an uninitialized instance of a Package subclass When a sub-package is created, this method is called. |
static void |
remove(java.lang.String name)
Deprecated. replaced by remove(String, Context) |
static void |
remove(java.lang.String name,
Context context)
Removes the specified package. |
protected void |
removePackage(Package pkg,
Context context)
|
void |
set(java.lang.String interned,
java.lang.Object value)
Defines a name-value binding in the symbol table. |
void |
set(java.lang.String symbol,
java.lang.Object obj,
Context context)
Set a value of a symbol in the package. |
void |
setConstant(java.lang.String interned,
java.lang.Object value)
Defines a constant in the symbol table. |
int |
size()
|
java.lang.String |
toString()
|
java.util.Enumeration |
values()
Returns an enumeration of the values in the symbol table. |
static Package |
wrap(java.util.Map map)
Returns a Package object that wrap the specified Map |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected transient java.util.Hashtable packages
public static final Package globalPackage
protected transient Package parent
protected transient Package root
protected pnuts.lang.SymbolTable autoloadTable
protected pnuts.lang.SymbolTable exportedSymbols
protected java.util.Vector requiredModuleNames
protected java.util.Vector providedModuleNames
protected boolean exports
protected boolean usedAsModule
protected boolean initialized
protected java.lang.String name
Constructor Detail |
---|
public Package()
public Package(java.lang.String name)
name
- the name of the packagepublic Package(java.lang.String name, Package parent)
name
- the name of the packageparent
- the parent package.protected Package(java.lang.String name, Package parent, Package root)
name
- the name of the packageparent
- the parent package.root
- the root package.Method Detail |
---|
public static Package getGlobalPackage()
public static Package wrap(java.util.Map map)
public java.util.Map asMap()
public Package newInstance(java.lang.String name)
name
- the package name
protected void addPackage(Package pkg, Context context)
protected void removePackage(Package pkg, Context context)
public static Package getPackage(java.lang.String pkg)
public static Package getPackage(java.lang.String pkg, Context context)
public boolean defined(java.lang.String name, Context context)
public java.lang.Object get(java.lang.String symbol, Context context)
get
in interface Property
symbol
- an interned name in the packagecontext
- the context in which the symbol is referenced. null means "not
specified".
public void set(java.lang.String symbol, java.lang.Object obj, Context context)
set
in interface Property
symbol
- an interned name of variableobj
- the value of the variablecontext
- the context in which the expression is evaluated.public void export(java.lang.String name)
name
- the symbol
java.lang.IllegalStateException
- when the package is not used as a module.public void clear(java.lang.String symbol, Context context)
symbol
- a name of variable to be deletedpublic static void remove(java.lang.String name)
public static void remove(java.lang.String name, Context context)
public static Package find(java.lang.String pkg)
pkg
- a name of package to look.
public static Package find(java.lang.String pkg, Context context)
pkg
- a name of package to look.
protected void init(Context context)
public java.lang.String getName()
public Package getParent()
public NamedValue lookup(java.lang.String symbol, Context context)
symbol
- an interned Stringcontext
- the context
protected NamedValue lookupRecursively(java.lang.String symbol, Context context)
symbol
- intern'ed stringprotected void initializeModule()
public java.util.Enumeration elements()
public java.lang.Object clone()
public void autoload(java.lang.String name, java.lang.String file, Context context)
name
- variable namefile
- the filecontext
- the contextpublic void autoload(java.lang.String name, AutoloadHook hook)
name
- variable namehook
- the AutoloadHookpublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object get(java.lang.String interned)
interned
- the name of the variable, which must be intern'd
public NamedValue lookup(java.lang.String interned)
interned
- the name of the variable, which must be intern'd
public void set(java.lang.String interned, java.lang.Object value)
interned
- the name of the variable, which must be intern'dvalue
- the new value
java.lang.IllegalStateException
- thrown when the specified symbol has been defined as a
constant.public void setConstant(java.lang.String interned, java.lang.Object value)
interned
- the name of the variable, which must be intern'dvalue
- the constant value
java.lang.IllegalStateException
- thrown when the specified symbol has been defined as a
constantpublic void clear()
public int size()
public java.util.Enumeration bindings()
NamedValue
public java.util.Enumeration keys()
public java.util.Enumeration values()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |