Package gamedata

Class ClassMap

  • All Implemented Interfaces:
    java.lang.Iterable<ClassMap.Entry>

    public class ClassMap
    extends java.lang.Object
    implements java.lang.Iterable<ClassMap.Entry>
    Represents the entries listed in the New Editor dialog and maps those entries to their respective component classes (or scripts). Primarily, this class is used by extensions to register new kinds of game components from a class map file. This class can also be used to examine class map file entries programmatically.
    Since:
    3.0
    Author:
    Chris Jennings
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ClassMap.Entry
      An entry in a class map file.
      static class  ClassMap.EntryType
      An enumeration of the types of entries that may appear in a class map file.
      static class  ClassMap.Parser
      A parser for class map files.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassMap​(java.lang.String... resources)
      Creates a new class map that contains entries parsed from the specified class map resources.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void add​(java.lang.String resource)
      Adds the specified class map resource to the list of such files that is used to generate the contents of the New Editor dialog.
      java.util.Set<ClassMap.Entry> getCategories()
      Returns an immutable set of the categories contained in this class map.
      java.util.Set<ClassMap.Entry> getCategoryEntries​(ClassMap.Entry category)
      Returns an immutable set of the entries associated with a particular category.
      static java.lang.String[] getClassMapFiles()
      Returns an array of the resource files that are used to build the list of categories and editors in the New Component dialog.
      java.util.Set<ClassMap.Entry> getEntries()
      Returns all non-category entries as a set.
      java.util.Iterator<ClassMap.Entry> iterator()
      Returns an iterator that iterates over the categories contained in this class map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • ENTRY_EVERYTHING_CATEGORY

        public static final ClassMap.Entry ENTRY_EVERYTHING_CATEGORY
        The special "Everything" pseudocategory. The NewEditorDialog generates the contents of this category automatically. It is not a member of the set returned by getCategories().
    • Constructor Detail

      • ClassMap

        public ClassMap​(java.lang.String... resources)
                 throws java.io.IOException
        Creates a new class map that contains entries parsed from the specified class map resources.
        Parameters:
        resources - the class map resources to parse; if no resources are specified, the default class map files are used
        Throws:
        ResourceParserException - if any of the class map files cannot be parsed
        java.io.IOException
    • Method Detail

      • iterator

        public java.util.Iterator<ClassMap.Entry> iterator()
        Returns an iterator that iterates over the categories contained in this class map.
        Specified by:
        iterator in interface java.lang.Iterable<ClassMap.Entry>
        Returns:
        an iterator over the available categories
      • getCategories

        public java.util.Set<ClassMap.Entry> getCategories()
        Returns an immutable set of the categories contained in this class map.
        Returns:
        an unmodifiable category set
      • getCategoryEntries

        public java.util.Set<ClassMap.Entry> getCategoryEntries​(ClassMap.Entry category)
        Returns an immutable set of the entries associated with a particular category.
        Parameters:
        category - the category to obtain a set of entries for
        Returns:
        the entries in the requested category, or an empty set
      • getEntries

        public java.util.Set<ClassMap.Entry> getEntries()
        Returns all non-category entries as a set.
        Returns:
        a set of all class map entries, excluding category entries
      • add

        public static void add​(java.lang.String resource)
        Adds the specified class map resource to the list of such files that is used to generate the contents of the New Editor dialog. The sample class map (/resources/projects/new-classmap.txt) describes the format of these files.
        Parameters:
        resource - a relative URL within resources/ that points to the file to add
        See Also:
        getClassMapFiles()
      • getClassMapFiles

        public static java.lang.String[] getClassMapFiles()
        Returns an array of the resource files that are used to build the list of categories and editors in the New Component dialog.
        Returns:
        an array of the resource URLs of all currently registered class maps