/**
  * Converts a Category object into a CategoryListItem.
  *
  * @param category the category to extract the name and sub-categories from
  * @param parentItem the parent category or null if this is a root category
  */
 public CategoryListItem(Category category, CategoryListItem parentItem) {
   name = category.getName();
   fullName = parentItem == null ? name : parentItem.fullName + " / " + name;
   key = category.getKey();
   List<Category> subCategories = category.getSubCategories();
   int cntSubCategories = subCategories == null ? 0 : subCategories.size();
   if (cntSubCategories == 0) {
     subItems = new CategoryListItem[0];
   } else {
     subItems = new CategoryListItem[cntSubCategories];
     for (int i = 0; i < cntSubCategories; i++) {
       subItems[i] = new CategoryListItem(subCategories.get(i), this);
     }
     // add a clickable item for the expandable root category
     subItems[cntSubCategories - 1] = new CategoryListItem(name, fullName, key, null);
   }
 }