예제 #1
0
파일: Post.java 프로젝트: hofmeister/Webi
  private static void put(ArrayValue array, Value key, Value value, boolean addSlashes) {
    if (addSlashes && value.isString()) {
      value = StringModule.addslashes(value.toStringValue());
    }

    if (key == null) array.put(value);
    else array.put(key, value);
  }
  /** 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;
  }