/** * Describe the complete path to ( and including) this directory, separated by the * RepositoryDirectory.DIRECTORY_SEPARATOR property (slash). * * @return The complete path to this directory. */ @Override public String getPath() { // Root! if ( getParent() == null ) { return DIRECTORY_SEPARATOR; } else { if ( getParent().getParent() == null ) { return DIRECTORY_SEPARATOR + getName(); } else { return getParent().getPath() + DIRECTORY_SEPARATOR + getName(); } } }
/** * Find the root of the directory tree starting from this directory. * * @return the root of the directory tree */ @Override public RepositoryDirectoryInterface findRoot() { if ( isRoot() ) { return this; } return getParent().findRoot(); }
/** * Describe the complete path to ( and including) this directory, as an array of strings. * * @return The complete path to this directory. */ @Override public String[] getPathArray() { // First determine the depth of the tree... int depth = 1; RepositoryDirectoryInterface follow = getParent(); if ( follow != null ) { depth++; follow = follow.getParent(); } // Then put something in it... String[] retval = new String[depth]; int level = depth - 1; retval[level] = getName(); follow = getParent(); if ( follow != null ) { level--; retval[level] = follow.getName(); follow = follow.getParent(); } return retval; }