/**
   * Creates and binds a new context. Creates a new context with the given name and binds it in the
   * target context (that named by all but terminal atomic component of the name). All intermediate
   * contexts and the target context must already exist.
   *
   * @param name the name of the context to create; may not be empty
   * @return the newly created context
   * @exception NameAlreadyBoundException if name is already bound
   * @exception javax.naming.directory.InvalidAttributesException if creation of the sub-context
   *     requires specification of mandatory attributes
   * @exception NamingException if a naming exception is encountered
   */
  @Override
  public Context createSubcontext(Name name) throws NamingException {
    if (!checkWritable()) {
      return null;
    }

    NamingContext newContext = new NamingContext(env, this.name);
    bind(name, newContext);

    newContext.setExceptionOnFailedWrite(getExceptionOnFailedWrite());

    return newContext;
  }
 /**
  * Binds a name to an object, overwriting any existing binding. All intermediate contexts and the
  * target context (that named by all but terminal atomic component of the name) must already
  * exist.
  *
  * <p>If the object is a DirContext, any existing attributes associated with the name are replaced
  * with those of the object. Otherwise, any existing attributes associated with the name remain
  * unchanged.
  *
  * @param name the name to bind; may not be empty
  * @param obj the object to bind; possibly null
  * @exception javax.naming.directory.InvalidAttributesException if object did not supply all
  *     mandatory attributes
  * @exception NamingException if a naming exception is encountered
  */
 @Override
 public void rebind(Name name, Object obj) throws NamingException {
   bind(name, obj, true);
 }
 /**
  * Binds a new name to the object bound to an old name, and unbinds the old name. Both names are
  * relative to this context. Any attributes associated with the old name become associated with
  * the new name. Intermediate contexts of the old name are not changed.
  *
  * @param oldName the name of the existing binding; may not be empty
  * @param newName the name of the new binding; may not be empty
  * @exception NameAlreadyBoundException if newName is already bound
  * @exception NamingException if a naming exception is encountered
  */
 @Override
 public void rename(Name oldName, Name newName) throws NamingException {
   Object value = lookup(oldName);
   bind(newName, value);
   unbind(oldName);
 }
 /**
  * Binds a name to an object.
  *
  * @param name the name to bind; may not be empty
  * @param obj the object to bind; possibly null
  * @exception NameAlreadyBoundException if name is already bound
  * @exception javax.naming.directory.InvalidAttributesException if object did not supply all
  *     mandatory attributes
  * @exception NamingException if a naming exception is encountered
  */
 @Override
 public void bind(String name, Object obj) throws NamingException {
   bind(new CompositeName(name), obj);
 }