コード例 #1
0
  public static Filter getFilter(Env env, Value filterIdV) {
    int filterId;

    int defaultFilterId = FILTER_UNSAFE_RAW;

    if (filterIdV.isDefault()) {
      // XXX: lookup in ini
      filterId = defaultFilterId;
    } else if (filterIdV.isArray()) {
      Value value = filterIdV.get(env.createString("filter"));

      if (value.isNull()) {
        filterId = defaultFilterId;
      } else {
        filterId = value.toInt();
      }
    } else {
      filterId = filterIdV.toInt();
    }

    Filter filter = _filterMap.get(filterId);

    if (filter == null) {
      throw new UnimplementedException(
          L.l("filter not implemented: {0} ({1})", filterIdV, filterId));
    }

    return filter;
  }
コード例 #2
0
ファイル: SimpleXMLElement.java プロジェクト: dlitz/resin
  /** Implementation for getting the indices of this class. i.e. <code>$a->foo[0]</code> */
  public Value __get(Env env, Value indexV) {
    if (indexV.isString()) {
      String name = indexV.toString();

      SimpleXMLElement attr = getAttribute(name);

      if (attr == null) return NullValue.NULL;
      else return wrapJava(env, _cls, attr);
    } else if (indexV.isLongConvertible()) {
      int i = indexV.toInt();

      if (i == 0) return wrapJava(env, _cls, getOwner());
      else if (_parent == null) return NullValue.NULL;

      ArrayList<SimpleXMLElement> children = _parent._children;

      if (children != null) {
        int size = children.size();

        for (int j = 0; j < size; j++) {
          SimpleXMLElement child = children.get(j);

          if (child.getName().equals(getName()) && i-- == 0) return wrapJava(env, _cls, child);
        }
      }

      return NullValue.NULL;
    } else return NullValue.NULL;
  }
コード例 #3
0
  /** Implementation for getting the indices of this class. i.e. <code>$a->foo[0]</code> */
  public Value __get(Env env, Value indexV) {
    if (indexV.isString()) {
      String name = indexV.toString();

      SimpleXMLElement attr = getAttribute(name);

      if (attr != null) return wrapJava(env, _cls, attr);
      else return NullValue.NULL;
    } else if (indexV.isLongConvertible()) {
      int i = indexV.toInt();

      if (i < _attributes.size()) return wrapJava(env, _cls, _attributes.get(i));

      return NullValue.NULL;
    } else return NullValue.NULL;
  }