示例#1
0
  /** Lists the names for the context. */
  public NamingEnumeration list(Name name) throws NamingException {
    AbstractModel model = _model;

    if (name == null) {
      return new QNameClassEnumeration(create(model, _env), model.list());
    }

    for (int i = 0; i < name.size(); i++) {
      String first = name.get(i);

      Object value = model.lookup(first);

      if (value instanceof AbstractModel) {
        model = (AbstractModel) value;
        continue;
      }

      value = dereference(value, null, model);

      if (value instanceof Context) return ((Context) value).list(name.getSuffix(i + 1));
      else if (value != null)
        throw new NotContextException(
            L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value));
      else throw new NameNotFoundException(getFullPath(name));
    }

    return new QNameClassEnumeration(create(model, _env), model.list());
  }
示例#2
0
  /** List the bindings for a context. */
  public NamingEnumeration listBindings(String name) throws NamingException {
    String tail = name;
    AbstractModel model = _model;

    while (true) {
      String first = parseFirst(tail);
      String rest = parseRest(tail);

      if (first == null) {
        return new QBindingEnumeration(create(model, _env), model.list());
      }

      Object value = model.lookup(first);

      if (value instanceof AbstractModel) {
        model = (AbstractModel) value;
        tail = rest;
        continue;
      }

      value = dereference(value, null, model);

      if (value instanceof Context) return ((Context) value).listBindings(rest);
      else if (value != null)
        throw new NotContextException(
            L.l("{0}: expected intermediate context at `{1}'", getFullPath(name), value));
      else throw new NameNotFoundException(getFullPath(name));
    }
  }