Ejemplo n.º 1
0
  @Override
  public CommandOutput exec(ShellOutputWriter out, ApplicationInstance instance, CommandInput in) {
    TreeNode node = null;
    if (in.getInputData() != null) {
      if (in.getInputData() instanceof TreeNode) {
        super.checkInputObjectArgumentConflict(out, in, "$0");
        node = (TreeNode) in.getInputData();
      } else {
        super.printUnusableInputWarning(out);
        return CommandOutput.error();
      }
    }

    if (node == null) {
      node = in.getTreeNode();
    }

    out.println(
        "Childnodes of \""
            + node.getText()
            + "\":\n\n"
            + "Index\tCreation date\tModification date\tNode name\n"
            + "-----\t-------------\t-----------------\t---------");

    int i = 0;
    for (TreeNode n : node.getChildNodes()) {
      String creationDate =
          Utilities.getTimeFromEpochMilli(
              n.getAttribute(
                  de.akubix.keyminder.core.ApplicationInstance.NODE_ATTRIBUTE_CREATION_DATE),
              true,
              "-\t");
      String modificationDate =
          Utilities.getTimeFromEpochMilli(
              n.getAttribute(
                  de.akubix.keyminder.core.ApplicationInstance.NODE_ATTRIBUTE_MODIFICATION_DATE),
              true,
              "-\t");

      out.println(i++ + "\t" + creationDate + "\t" + modificationDate + "\t\t" + n.getText());
    }
    return CommandOutput.success();
  }