/** * Helper function to file away new categories. It adds one entry in the map * for each sub-category in the passed category. * * @param category - the <code>Categorized</code> files. */ private void addCategory(Categorized category) { Iterator<String> names = category.getCategoryNames(); while (names.hasNext()) { categories.put(names.next(), category); } }
/** * Get the names of all the items in one of the categories. * * @param categoryName - the <code>String</code> name of the category * whose item names are required. * @return an <code>Enumeration</code> of <code>String</code> names. * This value will not be <code>null</code>, but it may be empty. */ public Iterator<String> getItemNames(String categoryName) { // Get the category with the given name. Categorized category = categories.get(categoryName); // Return an empty Enumeration if we couldn't find the category. if (null == category) { return new ArrayList<String>().iterator(); } // Is this a subcategory? if (this != category) { // Yup. Pass the request on. return category.getItemNames(categoryName); } // Return the names of this directory's items. return items.keySet().iterator(); }
return category.getItem(categoryName, itemName);