Package megamek.common.util.fileUtils
Class AbstractDirectory
java.lang.Object
megamek.common.util.fileUtils.AbstractDirectory
- Direct Known Subclasses:
DirectoryItems
AbstractDirectory is a class that is used to define a directory.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDirectory(File file, String rootName, String rootPath, ItemFileFactory itemFileFactory) -
Method Summary
Modifier and TypeMethodDescriptiongetCategory(String categoryPath) Get the indicated item from the correct category.getItemNames(String categoryName) Get the names of all the items in one of the categories.getItems()voidmerge(AbstractDirectory other) Adds the given AbstractDirectory's contents to this one's.voidsetRootName(String rootName) voidsetRootPath(String rootPath)
-
Constructor Details
-
AbstractDirectory
protected AbstractDirectory(File file, @Nullable String rootName, @Nullable String rootPath, ItemFileFactory itemFileFactory) throws NullPointerException - Parameters:
file- the directory file, included to ensure that is it not nullrootName- the root directory nameitemFileFactory- this is included to ensure that it is not null, as that is required for the files to be processed- Throws:
NullPointerException
-
-
Method Details
-
getRootName
-
setRootName
-
getRootPath
-
setRootPath
-
getCategories
-
getCategory
-
getNonEmptyCategoryPaths
-
getItems
-
getItemNames
Get the names of all the items in one of the categories.- Parameters:
categoryName- theStringname of the category whose item names are required.- Returns:
- an
IteratorofStringnames. This value will not benull, but it may be empty.
-
getItem
Get the indicated item from the correct category.- Parameters:
categoryName- theStringname of the category whose item names are requireditemName- theStringname of the indicated item- Returns:
- the
Objectin the given category with the given name - Throws:
Exception- if there's any error getting the item
-
merge
Adds the given AbstractDirectory's contents to this one's. Note: equally named categories are integrated into one another, but for items in the exact same category (file path) and with the same name the item of other will replace the item in this AbstractDirectory.- Parameters:
other- The AbstractDirectory to merge into this one
-