pnuts.security
Class SecurePackage

java.lang.Object
  extended by pnuts.lang.Package
      extended by pnuts.security.SecurePackage
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Property

public class SecurePackage
extends Package

Package that can control add/write/read operation in a security context.

 pnuts -J-Djava.security.manager "-J-Dpnuts.package.factory=pnuts.security.SecurePackage\$Factory" scripts
 

See Also:
Serialized Form

Field Summary
 
Fields inherited from class pnuts.lang.Package
autoloadTable, exportedSymbols, exports, globalPackage, initialized, name, packages, parent, providedModuleNames, requiredModuleNames, root, usedAsModule
 
Constructor Summary
SecurePackage(java.lang.String name, Package parent)
           
 
Method Summary
protected  void addPackage(Package pkg, Context context)
           
 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 get(java.lang.String interned)
          Gets the value of a variable.
 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.
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.util.Enumeration values()
          Returns an enumeration of the values in the symbol table.
 
Methods inherited from class pnuts.lang.Package
asMap, autoload, autoload, clone, defined, elements, export, find, find, get, getGlobalPackage, getName, getPackage, getPackage, getParent, init, initializeModule, lookup, lookupRecursively, newInstance, remove, remove, toString, wrap
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SecurePackage

public SecurePackage(java.lang.String name,
                     Package parent)
Method Detail

addPackage

protected void addPackage(Package pkg,
                          Context context)
Overrides:
addPackage in class Package

set

public void set(java.lang.String symbol,
                java.lang.Object obj,
                Context context)
Description copied from class: Package
Set a value of a symbol in the package. If this package is "used" in the specified context, and if the target object is either a Class object or a function whose name matches the symbol, then the symbol is imported to the context.

Specified by:
set in interface Property
Overrides:
set in class Package
Parameters:
symbol - an interned name of variable
obj - the value of the variable
context - the context in which the expression is evaluated.

clear

public void clear(java.lang.String symbol,
                  Context context)
Description copied from class: Package
Deletes a symbol from the package.

Overrides:
clear in class Package
Parameters:
symbol - a name of variable to be deleted

removePackage

protected void removePackage(Package pkg,
                             Context context)
Overrides:
removePackage in class Package

get

public java.lang.Object get(java.lang.String interned)
Gets the value of a variable.

Parameters:
interned - the name of the variable, which must be intern'd
Returns:
the value

lookup

public NamedValue lookup(java.lang.String interned)
Looks for a name-value binding in the symbol table chain.

Parameters:
interned - the name of the variable, which must be intern'd
Returns:
a NamedValue

set

public void set(java.lang.String interned,
                java.lang.Object value)
Defines a name-value binding in the symbol table.

Parameters:
interned - the name of the variable, which must be intern'd
value - the new value
Throws:
java.lang.IllegalStateException - thrown when the specified symbol has been defined as a constant.

setConstant

public void setConstant(java.lang.String interned,
                        java.lang.Object value)
Defines a constant in the symbol table.

Parameters:
interned - the name of the variable, which must be intern'd
value - the constant value
Throws:
java.lang.IllegalStateException - thrown when the specified symbol has been defined as a constant

clear

public void clear()
Deletes all name-value bindings.


size

public int size()

bindings

public java.util.Enumeration bindings()
Returns an enumeration of the NamedValues in the symbol table.

Returns:
an enumeration of the NamedValues
See Also:
NamedValue

keys

public java.util.Enumeration keys()
Returns an enumeration of the keys in the symbol table.

Returns:
an enumeration of the keys

values

public java.util.Enumeration values()
Returns an enumeration of the values in the symbol table.

Returns:
an enumeration of the values