Esempio n. 1
0
  /** var_dump() implementation */
  public void varDumpImpl(
      Env env, Value obj, WriteStream out, int depth, IdentityHashMap<Value, String> valueSet)
      throws IOException {
    String name = "SimpleXMLElement";

    if (obj != null) name = obj.getClassName();

    // php/1x33
    if (_text != null && _children == null && _attributes == null) {
      if (depth > 0) {
        _text.varDump(env, out, depth, valueSet);
        return;
      }

      out.println("object(" + name + ") (1) {");
      printDepth(out, 2 * (depth + 1));
      out.println("[0]=>");

      printDepth(out, 2 * (depth + 1));
      _text.varDump(env, out, depth, valueSet);
      out.println();

      printDepth(out, 2 * depth);
      out.print("}");

      return;
    }

    Set<Map.Entry<Value, Value>> entrySet = entrySet();
    out.println("object(" + name + ") (" + entrySet.size() + ") {");

    for (Map.Entry<Value, Value> entry : entrySet) {
      printDepth(out, 2 * (depth + 1));
      out.print("[");

      if (entry.getKey().isString()) out.print("\"" + entry.getKey() + "\"");
      else out.print(entry.getKey());

      out.println("]=>");

      printDepth(out, 2 * (depth + 1));
      entry.getValue().varDump(env, out, depth + 1, valueSet);
      out.println();
    }

    printDepth(out, 2 * depth);
    out.print('}');
  }