public class DirectoryNavigator extends Object
Modifier and Type | Field and Description |
---|---|
private ArrayList<DirectoryItem> |
currentItems |
private ArrayList<String> |
path |
private String |
TAG |
private String |
XMLinfo |
Constructor and Description |
---|
DirectoryNavigator(String fileXML)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addToPath(String directory)
Function used for testing.
|
DirectoryItem |
getDirectoryItem(int position)
Searches for a node in the current directory with the given position
|
(package private) DirectoryItem |
getDirectoryItem(String name)
Searches for a node in the current directory with the given name
|
long |
getFileCode(String name)
Identifies the node with name @a name and gets its file code in case the node is a file.
|
String |
getFileName(String name) |
private List<DirectoryItem> |
getItems(Node node)
Obtain all the items of the specific directory.
|
String |
getPath() |
ArrayList<DirectoryItem> |
goToCurrentDirectory() |
private Node |
goToDirectory()
Go to the directory of the path.
|
ArrayList<DirectoryItem> |
goToParentDirectory()
Travel to the parent directory.
|
ArrayList<DirectoryItem> |
goToRoot()
Go to the root directory.
|
ArrayList<DirectoryItem> |
goToSubDirectory(int directoryPosition)
Travel inside a subdirectory.
|
ArrayList<DirectoryItem> |
goToSubDirectory(String subDirectory)
Travel inside a subdirectory.
|
ArrayList<DirectoryItem> |
refresh(String fileXML)
Refresh the XML file and refresh the directory data.
|
private String TAG
private String XMLinfo
private ArrayList<DirectoryItem> currentItems
public DirectoryNavigator(String fileXML)
fileXML
- File where we obtain all the information.public ArrayList<DirectoryItem> goToSubDirectory(String subDirectory) throws InvalidPath
subDirectory
- The subdirectory where we will travel.InvalidPath
- When the directory don't exist.public ArrayList<DirectoryItem> goToCurrentDirectory()
public ArrayList<DirectoryItem> goToSubDirectory(int directoryPosition) throws InvalidPath
directoryPosition
- The position of the subdirectory where we will travel.InvalidPath
- When the directory don't exist.public ArrayList<DirectoryItem> goToParentDirectory() throws InvalidPath
InvalidPath
- When the directory does not exist.public ArrayList<DirectoryItem> refresh(String fileXML) throws InvalidPath
InvalidPath
- When the directory don't exist.public ArrayList<DirectoryItem> goToRoot() throws InvalidPath
InvalidPath
- When the directory don't exist.private List<DirectoryItem> getItems(Node node)
node
- Node that represents the current directory.private Node goToDirectory() throws InvalidPath
InvalidPath
- When the directory don't exist.public String getPath()
public void addToPath(String directory)
directory
- Directory to add to the current path.DirectoryItem getDirectoryItem(String name)
name
- Name of the node located on the current directory.public DirectoryItem getDirectoryItem(int position)
position
- position where the node is locatedpublic long getFileCode(String name)
name
- Name of the node located on the current directory.