Convenience method to format a map of categories in a nice 2 column list, for example
for display of debugging output.<p>

@param categories the map to format
@return the formatted category map
340275
public static final String formatCategoryMap(Map<String, Integer> categories) {

        StringBuffer result = new StringBuffer(256);
        result.append("Total categories: ");
        result.append(categories.size());
        result.append('\n');
        Iterator<Map.Entry<String, Integer>> i = categories.entrySet().iterator();
        while (i.hasNext()) {
            Map.Entry<String, Integer> entry = i.next();
            result.append(CmsStringUtil.padRight(entry.getKey(), 30));
            result.append(entry.getValue().intValue());
            result.append('\n');
        }
        return result.toString();
    }
666835
public Map<String, CmsCategory> getReadCategory() {

        if (null == m_categories) {
            m_categories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {

                public Object transform(Object categoryPath) {

                    try {
                        CmsCategoryService catService = CmsCategoryService.getInstance();
                        return catService.localizeCategory(
                            m_cms,
                            catService.readCategory(m_cms, (String)categoryPath, getRequestContext().getUri()),
                            m_cms.getRequestContext().getLocale());
                    } catch (CmsException e) {
                        LOG.warn(e.getLocalizedMessage(), e);
                        return null;
                    }
                }

            });
        }
        return m_categories;
    }
761970
public static Map<Integer, List<TagWrapper>> getCategoryMappingFromTagList(final Collection<TagWrapper> tags) {
        final HashMap<Integer, List<TagWrapper>> mapping = new HashMap<Integer, List<TagWrapper>>();
        for (final TagWrapper tag : tags) {
            final List<CategoryInTagWrapper> catList = tag.getCategories().getItems();
            if (catList != null) {
                for (final CategoryInTagWrapper cat : catList) {
                    if (!mapping.containsKey(cat.getId())) {
                        mapping.put(cat.getId(), new ArrayList<TagWrapper>());
                    }
                    mapping.get(cat.getId()).add(tag);
                }
            }
        }
        return mapping;
    }
509822
function(category) {
			var settingsMap = this.settingsMap;
			var pids = typeof category === 'string' ? this.categories[category] : Object.keys(settingsMap); //$NON-NLS-0$
			if (!pids) {
				return [];
			}
			return pids.map(function(pid) {
				return settingsMap[pid];
			});
		}
1049006
public static List<Group> categoriesToGroups(List<Category> categories) {
    return categories.stream()
        .map(Category::getGroups)     // get groups from categories
        .filter(Objects::nonNull)     // remove all null
        .flatMap(Collection::stream)
        .collect(Collectors.toList());
  }
202517
public static List<String> getLabels(boolean categories){
        List<String> rawLabels = new Cifar10DataSetIterator(1).getLabels();
        if(categories){
            return rawLabels;
        }

        //Otherwise, convert to human-readable format, using 'words.txt' file
        File baseDir = DL4JResources.getDirectory(ResourceType.DATASET, Cifar10Fetcher.LOCAL_CACHE_NAME);
        File labelFile = new File(baseDir, Cifar10Fetcher.LABELS_FILENAME);
        List<String> lines;
        try {
            lines = FileUtils.readLines(labelFile, StandardCharsets.UTF_8);
        } catch (IOException e){
            throw new RuntimeException("Error reading label file", e);
        }

        Map<String,String> map = new HashMap<>();
        for(String line : lines){
            String[] split = line.split("\t");
            map.put(split[0], split[1]);
        }

        List<String> outLabels = new ArrayList<>(rawLabels.size());
        for(String s : rawLabels){
            String s2 = map.get(s);
            Preconditions.checkState(s2 != null, "Label \"%s\" not found in labels.txt file");
            outLabels.add(s2);
        }
        return outLabels;
    }
620626
public Graph categories(String... names) {
        if (names == null || names.length == 0) {
            return this;
        }
        for (String name : names) {
            this.categories().add(new Category(name));
        }
        return this;
    }
1042831
public static List<Setting> categoriesToSettings(List<Category> categories) {
    return categories.stream()
        .map(Category::getGroups)     // get groups from categories
        .filter(Objects::nonNull)     // remove all null
        .flatMap(Collection::stream)  // recursively flatten all categories
        .map(Group::getSettings)      // get settings from groups
        .filter(Objects::nonNull)     // remove all null
        .flatMap(Collection::stream)  // recursively flatten all settings
        .collect(Collectors.toList());
  }
354028
public Map<String, CmsJspCategoryAccessBean> getSubCategories() {

        if (m_subCategories == null) {
            m_subCategories = CmsCollectionsGenericWrapper.createLazyMap(new Transformer() {

                @SuppressWarnings("synthetic-access")
                public Object transform(Object pathPrefix) {

                    return new CmsJspCategoryAccessBean(m_cms, m_categories, (String)pathPrefix);
                }

            });
        }
        return m_subCategories;
    }
928623
public static void enableCategories(Category... categories) throws IOException {
        if (s_tracer == null) {
            start();
        }
        final VoltTrace tracer = s_tracer;
        assert tracer != null;

        final ImmutableSet.Builder<Category> builder = ImmutableSet.builder();
        builder.addAll(tracer.m_enabledCategories);
        builder.addAll(Arrays.asList(categories));
        tracer.m_enabledCategories = builder.build();
    }
1326080
public static List<CmsCategoryTreeEntry> buildCategoryTree(CmsObject cms, List<CmsCategory> categories) {

        List<CmsCategoryTreeEntry> result = new ArrayList<CmsCategoryTreeEntry>();
        for (CmsCategory category : categories) {
            CmsCategoryTreeEntry current = new CmsCategoryTreeEntry(category);
            current.setSitePath(cms.getRequestContext().removeSiteRoot(category.getRootPath()));
            String parentPath = CmsResource.getParentFolder(current.getPath());
            CmsCategoryTreeEntry parent = null;
            parent = findCategory(result, parentPath);
            if (parent != null) {
                parent.addChild(current);
            } else {
                result.add(current);
            }
        }
        return result;
    }
19925
public static List<String> categoriesFromString(String categoriesList) {
		List<String> result = new ArrayList<String>();
		try {
			if (categoriesList != null) {
				String[] categories = categoriesList.split(DescribeService.CATEGORY_SEPARATOR);
				if (categories != null && categories.length != 0) {
					for (String cat : categories) {
						result.add(cat);
					}
				}
			}
		} catch (Exception ignore) {
			logger.warn("DescribeService", ignore);
		}

		return result;
	}
1211815
public Map<CmsUUID, I_CmsFormatterBean> getAutoEnabledFormatters() {

        if (m_autoEnabledFormatters == null) {
            Map<CmsUUID, I_CmsFormatterBean> result = Maps.newHashMap();
            for (Map.Entry<CmsUUID, I_CmsFormatterBean> entry : m_formatters.entrySet()) {
                if (entry.getValue().isAutoEnabled()) {
                    result.put(entry.getKey(), entry.getValue());
                }
            }
            m_autoEnabledFormatters = result;
        }
        return Collections.unmodifiableMap(m_autoEnabledFormatters);
    }
156080
public final Set<String> getCategories()
	{
		final Set<String> categories = new TreeSet<String>();
		if (parentNode != null)
		{
			categories.addAll(parentNode.getCategories());
		}
		if (accessor instanceof CategoryAware)
		{
			final Set<String> categoriesFromAccessor = ((CategoryAware) accessor).getCategoriesFromAnnotation();
			if (categoriesFromAccessor != null)
			{
				categories.addAll(categoriesFromAccessor);
			}
		}
		categories.addAll(additionalCategories);

		return unmodifiableSet(categories);
	}
156028
public Graph categories(Category... values) {
        if (values == null || values.length == 0) {
            return this;
        }
        this.categories().addAll(Arrays.asList(values));
        return this;
    }
788446
private String getStringValue(Collection<CmsCategory> categories) {

        CmsObject cms = A_CmsUI.getCmsObject();
        String result = "";
        for (CmsCategory cat : categories) {
            result += cms.getRequestContext().removeSiteRoot(cat.getRootPath()) + ",";
        }
        if (result.length() > 0) {
            result = result.substring(0, result.length() - 1);
        }
        return result;
    }
570433
private List<Property> getPropertiesForCategory(List<Property> localProperties, String category) {
        List<Property> categoryProperties = new ArrayList<Property>();
        for (Property property : localProperties) {
            if (property.getCategory() != null && property.getCategory().equals(category)) {
                categoryProperties.add(property);
            }
        }
        return categoryProperties;
    }