alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 *
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 *
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.tasklist.suggestions;

import java.util.Map;
import java.util.Iterator;
import java.util.Collection;

/**
 * Registry of all suggestion types. This is singleton and it also keeps
 * the settings whether the suggestion types which are not active are 
 * drawn on the background, whther the combining of suggestions is
 * turned on or off etc. These settings are shared by all views.
 *
 * Based on AnnotationTypes.java in the editor package.
 * 

* * @author Tor Norbye, David Konecny */ final public class SuggestionTypes { /** Static map containing all suggestion types: suggestion_name <-> suggestion_type */ private Map allTypes = null; /** Flag whether the suggestion types were initialized or not */ private boolean initializedTypes = false; /** Single instance of this class */ private static SuggestionTypes suggestionTypes = null; private SuggestionTypes() { } /** Returns instance of SuggestionTypes singleton. */ public static SuggestionTypes getDefault() { if (suggestionTypes == null) { suggestionTypes = new SuggestionTypes(); } return suggestionTypes; } /** Initialize the map of all suggestion types * @param map map containing all suggestion types */ final void setTypes(Map map) { allTypes = map; initializedTypes = map != null; } public final int getCount() { loadTypes(); if (allTypes == null) { return 0; } else { return allTypes.size(); } } /** Returns SuggestionType instance for the given name of the type * @param name suggestion type name * @return instance describing suggestion type */ public final SuggestionType getType(String name) { loadTypes(); if (allTypes == null) return null; return (SuggestionType)allTypes.get(name); } /** Returns a collection containing all the registered SuggestionTypes. * @return collection containing all registered types */ public final Collection getAllTypes() { loadTypes(); if (allTypes == null) return null; return allTypes.values(); } /** Check if the types were loaded and load them if not */ private void loadTypes() { if (initializedTypes) return; SuggestionTypesFolder.getSuggestionTypesFolder(); initializedTypes = true; } }

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.