public static class MidiLibrary.Folder extends Object implements MidiLibrary.MapNode
MidiLibrary. Backed by a TreeMap.| Constructor and Description |
|---|
Folder(String folderName,
String parentName,
String iconUri)
Constructs a new
Folder. |
| Modifier and Type | Method and Description |
|---|---|
void |
addChild(MidiLibrary.MapNode node)
Adds a
MidiLibrary.MapNode to this Folder. |
MidiLibrary.Folder |
clone()
Creates a new
Folder with the same properties as this Folder. |
int |
compareTo(MidiLibrary.MapNode node)
Compares this
Folder with another MidiLibrary.MapNode and determines which should be sorted first. |
boolean |
containsKey(String key)
Checks if a
String is the name of an item that is a direct child of this Folder. |
boolean |
containsValue(MidiLibrary.MapNode value)
Checks if a
MidiLibrary.MapNode is a direct child of this Folder. |
MidiLibrary.MidiFile |
createFile(Uri uri,
String fileName,
int duration,
String artist,
String album,
String path)
Creates a
MidiLibrary.MidiFile in this Folder. |
MidiLibrary.Folder |
createFolder(String folderName)
Creates a
Folder with the default icon. |
MidiLibrary.Folder |
createFolder(String folderName,
String iconUri)
Creates a
Folder with a specific icon. |
static MidiLibrary.Folder |
createFolderStructureWithFile(MidiLibrary.MidiFile midiFile,
String iconUri)
Creates a folder to house the provided
MidiLibrary.MidiFile. |
MidiLibrary.MapNode |
get(String key)
Gets a child of this
Folder. |
Set<MidiLibrary.MapNode> |
getChildren()
Gets all of the children of this
Folder. |
int |
getChildrenCount()
Gets the number children this
Folder has. |
Set<MidiLibrary.MapNode> |
getChildrenRecursive()
Recursively gets all the dead-end children of this
Folder. |
Set<MidiLibrary.Folder> |
getFoldersRecursive()
Gets all of the subfolders contained in this
Folder. |
String |
getIconUri()
Gets the URI of the icon this
Folder uses. |
Set<String> |
getKeys()
Gets the names of all direct children of this
Folder. |
Set<String> |
getKeysRecursive()
Recursively gets the names of all dead-end children children of this
Folder. |
MediaMetadataCompat |
getMetadata()
Gets the metadata of this
Folder. |
String |
getName()
Gets the name of this
Folder. |
String |
getNameGlobal()
Gets the fully-qualified name of this
Folder. |
String |
getParentName()
Gets the fully-qualified name of this
Folder's parent. |
boolean |
hasChildren()
Checks if this
Folder has any children. |
boolean |
isFile()
Always returns
false. |
MidiLibrary.MapNode |
remove(String key)
Removes a child of this
Folder. |
protected String |
validateFolderNames(String folderName,
String parentName)
Verifies the passed folder and parent names.
|
public Folder(String folderName, String parentName, String iconUri)
Folder.folderName - the name to use for this FolderparentName - the fully-qualified name of the parent MidiLibrary.Folder, use null if there is no parenticonUri - the URI String of the icon to use for this Folder@Nullable public static MidiLibrary.Folder createFolderStructureWithFile(MidiLibrary.MidiFile midiFile, String iconUri) throws InvalidPathException
MidiLibrary.MidiFile. The default folder icon is used for all new folders.midiFile - the file to create folders to containiconUri - the URI String of the icon to use for the folders; use null for default iconnull if no folders are in file pathInvalidPathException - if a segment of the path is blankprotected String validateFolderNames(String folderName, String parentName) throws InvalidPathException
folderName and creates subdirectories.folderName - the requested folder nameparentName - the fully-qualified name of the parent folderIllegalArgumentException - if folderName is nullInvalidPathException - if a segment of folderName already represents a non-Folder entryMidiLibrary.RootFolderpublic MidiLibrary.Folder createFolder(String folderName)
Folder with the default icon. If the requested Folder already
exists, that Folder is returned.folderName - the name or relative path of the folder to createFolderInvalidPathException - if folderName already is a non-Folder entrycreateFolder(String, String)public MidiLibrary.Folder createFolder(String folderName, String iconUri) throws InvalidPathException
Folder with a specific icon. If the requested Folder already
exists, that Folder is returned and the supplied icon is ignored.folderName - the name or relative path of the folder to createiconUri - the URI String of the icon to use for the folders; use null for default iconFolderInvalidPathException - if folderName already is a non-Folder entrypublic MidiLibrary.MidiFile createFile(Uri uri, String fileName, int duration, String artist, String album, String path) throws InvalidPathException
MidiLibrary.MidiFile in this Folder.uri - the Uri that can be used to open the filefileName - the file's nameduration - the duration (in milliseconds)artist - the file's artistalbum - the file's albumInvalidPathException - if fileName already existspublic void addChild(@Nullable MidiLibrary.MapNode node) throws InvalidPathException
MidiLibrary.MapNode to this Folder. If a MapNode with the same name as
node already exists and they are both Folders, they are combined; if they
are not both Folders, an InvalidPathException is raised.node - the MapNode to be addedInvalidPathException - if node already exists and both aren't Folderspublic MidiLibrary.MapNode get(String key)
Folder.key - the name or relative path of the requested itemnull if the item wasn't found, otherwise the requested item as a MapNodepublic MidiLibrary.MapNode remove(String key)
Folder.key - the name or relative path of the item to be removednull if the item wasn't found, otherwise the removed item as a MapNodepublic boolean containsKey(String key)
String is the name of an item that is a direct child of this Folder.key - the name of the itemtrue if key is the name of an item is in this Folder, otherwise falsepublic boolean containsValue(MidiLibrary.MapNode value)
MidiLibrary.MapNode is a direct child of this Folder.value - the item to check fortrue if value is an item is in this Folder, otherwise false@NonNull public MidiLibrary.Folder clone()
Folder with the same properties as this Folder.public Set<MidiLibrary.Folder> getFoldersRecursive()
Folder.Set containing all subfolderspublic String getIconUri()
Folder uses.Stringpublic boolean hasChildren()
Folder has any children.hasChildren in interface MidiLibrary.MapNodetrue if this Folder has children, otherwise falsepublic Set<MidiLibrary.MapNode> getChildren()
Folder.getChildren in interface MidiLibrary.MapNodeSet of all childrenpublic Set<MidiLibrary.MapNode> getChildrenRecursive()
Folder. In other words,
any MidiLibrary.MapNodes without children (e.g. an empty Folder or a MidiLibrary.MidiFile)
are found and returned.getChildrenRecursive in interface MidiLibrary.MapNodeSet of all children which have no childrengetChildrenRecursive()public int getChildrenCount()
Folder has.getChildrenCount in interface MidiLibrary.MapNodepublic Set<String> getKeys()
Folder.getKeys in interface MidiLibrary.MapNodeSet of all children namespublic Set<String> getKeysRecursive()
Folder. In other words,
the names of any MidiLibrary.MapNodes without children (e.g. an empty Folder or a MidiLibrary.MidiFile)
are found and returned.getKeysRecursive in interface MidiLibrary.MapNodeSet of all names of children which have no childrenpublic boolean isFile()
false.isFile in interface MidiLibrary.MapNodefalsepublic String getName()
Folder.getName in interface MidiLibrary.MapNodepublic String getNameGlobal()
Folder.getNameGlobal in interface MidiLibrary.MapNodepublic String getParentName()
Folder's parent.getParentName in interface MidiLibrary.MapNodepublic MediaMetadataCompat getMetadata()
Folder.getMetadata in interface MidiLibrary.MapNodepublic int compareTo(MidiLibrary.MapNode node)
Folder with another MidiLibrary.MapNode and determines which should be sorted first. Case is ignored.compareTo in interface Comparable<MidiLibrary.MapNode>node - the MapNode to compare againstFolder should be sorted first, 0 if the objects should be sorted equally, or
a positive integer if node should be sorted first