Esempio n. 1
0
  /**
   * Resolves to penultimate context named by 'name'. Returns true if penultimate context has been
   * reached (i.e. name only has one atomic component left). Returns false otherwise, and sets
   * Continuation to parts of name not yet resolved.
   */
  protected boolean resolve_to_penultimate_context(Name name, Continuation cont)
      throws NamingException {
    String target = name.toString();

    if (debug > 0) System.out.println("RESOLVE TO PENULTIMATE" + target);

    StringHeadTail ht = c_parseComponent(target, cont);
    String tail = ht.getTail();
    String head = ht.getHead();
    if (head == null) {
      // something is wrong; no name at all
      InvalidNameException e = new InvalidNameException();
      throw cont.fillInException(e);
    }

    if (!isEmpty(tail)) {
      // more components; hence not at penultimate context yet
      try {
        Object headCtx = a_lookup(head, cont);
        if (headCtx != null) cont.setContinue(headCtx, head, this, tail);
        else if (cont.isContinue()) cont.appendRemainingComponent(tail);
      } catch (NamingException e) {
        e.appendRemainingComponent(tail);
        throw e;
      }
    } else {
      // already at penultimate context
      cont.setSuccess(); // clear
      return true;
    }
    return false;
  }
Esempio n. 2
0
  /**
   * Resolve to context named by 'name'. Returns true if at named context (i.e. 'name' is empty
   * name). Returns false otherwise, and sets Continuation on parts of 'name' not yet resolved.
   */
  protected boolean resolve_to_context(Name name, Continuation cont) throws NamingException {
    String target = name.toString();

    StringHeadTail ht = c_parseComponent(target, cont);
    String tail = ht.getTail();
    String head = ht.getHead();

    if (debug > 0)
      System.out.println("RESOLVE TO CONTEXT(" + target + ") = {" + head + ", " + tail + "}");

    if (head == null) {
      // something is wrong; no name at all
      InvalidNameException e = new InvalidNameException();
      throw cont.fillInException(e);
    }
    if (!isEmpty(head)) {
      // if there is head is a non-empty name
      // this means more resolution to be done
      try {
        Object headCtx = a_lookup(head, cont);
        //              System.out.println("answer " + headCtx);
        if (headCtx != null) cont.setContinue(headCtx, head, this, (tail == null ? "" : tail));
        else if (cont.isContinue()) cont.appendRemainingComponent(tail);
      } catch (NamingException e) {
        e.appendRemainingComponent(tail);
        throw e;
      }
    } else {
      cont.setSuccess(); // clear
      return true;
    }
    return false;
  }