Exemplo n.º 1
0
  public NodeWrapper getChild(String name) {
    ArrayList<NodeWrapper> children = getChildren();

    for (NodeWrapper child : children) {
      if (child.getName().equals(name)) return child;
    }
    return null;
  }
Exemplo n.º 2
0
  public boolean hasChild(NodeWrapper node) {
    long id = node.getId();

    for (NodeWrapper child : getChildren()) {
      if (child.getId() == id) return true;
    }

    return false;
  }
Exemplo n.º 3
0
  public NodeWrapper getSibling(String name) {
    if (getParent() == null) return null;

    ArrayList<NodeWrapper> children = getParent().getChildren();

    for (NodeWrapper child : children) {
      if (child.getName().equals(name)) return child;
    }
    return null;
  }
Exemplo n.º 4
0
  public ArrayList<String> getSiblings() {
    ArrayList<String> result = new ArrayList<String>();

    if (cursor == null) return result;

    NodeWrapper parent = getParent();

    if (parent != null) result = parent.getChildrenStringArray();
    else result = db.cursorToArrayList(db.getFileCursor());

    return result;
  }
Exemplo n.º 5
0
  public String constructOlpId() {
    if (cursor == null) return "";

    StringBuilder result = new StringBuilder();
    result.insert(0, getName());

    long parentId = getParentId();

    while (parentId > 0) {
      NodeWrapper node = new NodeWrapper(db.getNode(parentId), db);
      parentId = node.getParentId();

      if (parentId > 0) result.insert(0, node.getOlpName() + "/");
      else { // Get file nodes real name
        String filename = db.getFilenameFromNodeId(node.getId());
        result.insert(0, filename + ":");
      }
    }

    result.insert(0, "olp:");
    return result.toString();
  }
Exemplo n.º 6
0
  public ArrayList<String> getChildrenStringArray() {
    ArrayList<String> result = new ArrayList<String>();
    for (NodeWrapper wrapper : getChildren()) result.add(wrapper.getName());

    return result;
  }
Exemplo n.º 7
0
  public void setParent(NodeWrapper newParent) {
    if (cursor == null) return;

    setParent(newParent.getId());
    setFileId(newParent.getFileId());
  }