pnuts.ext
Class ProtectedPackage

java.lang.Object
  |
  +--pnuts.lang.Package
        |
        +--pnuts.ext.ProtectedPackage

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

Inner Class Summary
static class ProtectedPackage.Factory
           
 
Field Summary
protected  java.util.Hashtable exports
           
 
Fields inherited from class pnuts.lang.Package
autoloadTable, children, globalPackage, name, packages, parent, requireTable, table, unitTable
 
Constructor Summary
protected ProtectedPackage()
           
  ProtectedPackage(java.lang.String name)
           
 
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
clear, clone, defined, defined, elements, find, get, get, getGlobalPackage, getName, getPackage, keys, registerQuantityFactory, remove, reset, save, set, setPackageFactory, size, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

exports

protected java.util.Hashtable exports
Constructor Detail

ProtectedPackage

protected ProtectedPackage()

ProtectedPackage

public ProtectedPackage(java.lang.String name)
Method Detail

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
Overrides:
lookup in class Package
Tags copied from class: 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 variable
val - the value of the variable
context - 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 deleted
context - the context