jxl.binding
Class BindingContext

java.lang.Object
  extended by jxl.binding.BindingContext
All Implemented Interfaces:
java.io.Serializable

public final class BindingContext
extends java.lang.Object
implements java.io.Serializable

Binds Serializale objects with String name key. Supports creation and remove of subcontexts.

Author:
Alex Lynch
See Also:
Serialized Form

Field Summary
static java.lang.String BINDING_DIR_KEY
          This is the java property key to specify a directory to save bound data.
 
Method Summary
 void bind(java.lang.String name, java.io.Serializable o)
          Bind name to o
 void checkPermission()
           
 void destroySubcontext(java.lang.String name)
          Recursively destroys all bindings and subcontexts beneath the subcontext denoted by name.
 boolean equals(java.lang.Object o)
          An equality evaluation based on hashCode()
static BindingContext getContext(javax.naming.Name n, java.security.Permission check)
          Get a BindingContext
 BindingContext getSubcontext(java.lang.String name)
          Returns the named subcontext
 int hashCode()
          Every BindingContext creatd with name A will here return A.hashCode().
 boolean isBound(java.lang.String name)
          Check if name is bound to an object.
 java.util.Set<java.lang.String> listBindings()
          List the names of object bindings in this context
 java.util.Set<java.lang.String> listSubcontexts()
          List the names of subcontext of this context
 java.io.Serializable lookup(java.lang.String name)
          Get object bound to name or null if it is not bound.
 java.lang.String nextUniqueSubcontext()
          Get a name for new subcontext
 java.lang.String toString()
           
 void unbind(java.lang.String name)
          Removes the binding to name.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BINDING_DIR_KEY

public static final java.lang.String BINDING_DIR_KEY
This is the java property key to specify a directory to save bound data. If this is not set, the directory returned from Installer is used instead.

See Also:
Constant Field Values
Method Detail

getContext

public static BindingContext getContext(javax.naming.Name n,
                                        java.security.Permission check)
                                 throws BindingException
Get a BindingContext

Parameters:
n - Name of the context to return
Returns:
returned context
Throws:
BindingException - If an error occurs in io

checkPermission

public void checkPermission()
                     throws java.lang.SecurityException
Throws:
java.lang.SecurityException

nextUniqueSubcontext

public java.lang.String nextUniqueSubcontext()
                                      throws BindingException
Get a name for new subcontext

Returns:
The next unbound subcontext name
Throws:
BindingException - if an io error occurs

bind

public void bind(java.lang.String name,
                 java.io.Serializable o)
          throws BindingException
Bind name to o

Parameters:
name -
o -
Throws:
BindingException

listBindings

public java.util.Set<java.lang.String> listBindings()
                                             throws BindingException
List the names of object bindings in this context

Throws:
BindingException

listSubcontexts

public java.util.Set<java.lang.String> listSubcontexts()
                                                throws BindingException
List the names of subcontext of this context

Throws:
BindingException

isBound

public boolean isBound(java.lang.String name)
Check if name is bound to an object. Does not check subcontexts.

Parameters:
name -
Returns:
true if name is bound to an object, false otherwise

lookup

public java.io.Serializable lookup(java.lang.String name)
                            throws BindingException
Get object bound to name or null if it is not bound.

Parameters:
name -
Throws:
BindingException

unbind

public void unbind(java.lang.String name)
            throws BindingException
Removes the binding to name.

Parameters:
name -
Throws:
BindingException

getSubcontext

public BindingContext getSubcontext(java.lang.String name)
                             throws BindingException
Returns the named subcontext

Parameters:
name -
Returns:
the subcontext
Throws:
BindingException

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws BindingException
Recursively destroys all bindings and subcontexts beneath the subcontext denoted by name. So if this BindingContext contained a subcontext foo, every binding and subcontext below foo would be destroyed.

Parameters:
name -
Throws:
BindingException

hashCode

public int hashCode()
Every BindingContext creatd with name A will here return A.hashCode(). Thus hashCode() is consistent across sessions. This is to facilitate serialization.

Overrides:
hashCode in class java.lang.Object
Returns:
hashCode() based on the name of this BindingContext.

equals

public boolean equals(java.lang.Object o)
An equality evaluation based on hashCode()

Overrides:
equals in class java.lang.Object
Parameters:
o -

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object