pnuts.ext
Class ProtectedPackage
java.lang.Object
|
+--pnuts.lang.Package
|
+--pnuts.ext.ProtectedPackage
- All Implemented Interfaces:
- java.lang.Cloneable, Property, java.io.Serializable
- public class ProtectedPackage
- extends Package
This class is a variation of pnuts.lang.Package class.
Only exported symbols are visible from other package.
e.g.
import("pnuts.ext.ProtectedPackage")
package(ProtectedPackage("foo"))
x = 100
y = 100
export("x")
package("")
foo::x ==> 100
foo::y ==> not found
- See Also:
- User's Guide, Serialized Form
Field Summary |
protected java.util.Hashtable |
exports
|
Method Summary |
void |
clear(java.lang.String symbol,
Context context)
Delete a symbol from the package |
void |
export(java.lang.String symbol,
Context context)
|
protected void |
init()
This method is called by the constructors. |
protected void |
init(Context context)
This method is called when this package become the current package. |
protected Value |
lookup(java.lang.String symbol,
Context context)
Lookup the symbol in the package. |
void |
set(java.lang.String symbol,
java.lang.Object val,
Context context)
Set a value of a symbol in the package |
static void |
setDefault()
make this class the default class of packages |
Methods inherited from class pnuts.lang.Package |
clone, defined, elements, find, get, get, getGlobalPackage, getName, getPackage, getParent, keys, remove, save, setPackageFactory, size, toString |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
exports
protected java.util.Hashtable exports
ProtectedPackage
protected ProtectedPackage()
ProtectedPackage
public ProtectedPackage(java.lang.String name)
ProtectedPackage
public ProtectedPackage(java.lang.String name,
Package parent)
setDefault
public static void setDefault()
- make this class the default class of packages
export
public void export(java.lang.String symbol,
Context context)
init
protected void init()
- This method is called by the constructors.
- Overrides:
init
in class Package
init
protected void init(Context context)
- This method is called when this package become the current package.
Function export(symbol) is defined for convenience.
- Overrides:
init
in class Package
lookup
protected Value lookup(java.lang.String symbol,
Context context)
- Description copied from class:
Package
- Lookup the symbol in the package. When the symbol is not defined in the package and this.parent
is not null, lookup the symbol in the parent package.
- Overrides:
lookup
in class Package
- Following copied from class:
pnuts.lang.Package
- Parameters:
symbol
- intern'ed string
set
public void set(java.lang.String symbol,
java.lang.Object val,
Context context)
- Set a value of a symbol in the package
- Overrides:
set
in class Package
- Parameters:
symbol
- a name of variableval
- the value of the variablecontext
- the context- Since:
- Pnuts 1.0beta3
clear
public void clear(java.lang.String symbol,
Context context)
- Delete a symbol from the package
- Overrides:
clear
in class Package
- Parameters:
symbol
- a name of variable to be deletedcontext
- the context