Class PackageMapNode


  • public class PackageMapNode
    extends java.lang.Object
    A data structure modeling all classes in a jar or directory, or on a classpath. It's a recursive mapping of Strings to either Maps or ClassFiles (which are lazily created and may be null). At each level of the nested map, the string key is a package name iff its corresponding value is a Map. Examine that Map's contents to explore the contents of that package. If the corresponding value is a ClassFile, then the string key's value is the name of that class. Finally, if the corresponding value is null, then the string key's value is the name of a class, but its contents have not yet been loaded for use by the code completion library (ClassFiles are lazily loaded to conserve memory).
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.SortedMap<java.lang.String,​ClassFile> classFiles
      A mapping of class file names to class files in this package.
      private java.util.SortedMap<java.lang.String,​PackageMapNode> subpackages
      A mapping of sub-package name to the sub-packages and classes under it.
    • Constructor Summary

      Constructors 
      Constructor Description
      PackageMapNode()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.String className)
      Adds entries for a fully-qualified class name, of the form "org/fife/util/DynamicIntArray.class".
      void addCompletions​(LibraryInfo info, org.fife.ui.autocomplete.CompletionProvider provider, java.lang.String[] pkgNames, java.util.Set<org.fife.ui.autocomplete.Completion> addTo)
      Gets the completions in this package map that match a given string.
      int clearClassFiles()
      Removes the cache of all ClassFiles from this package map.
      private int clearClassFilesImpl​(PackageMapNode pmn)  
      boolean containsClass​(java.lang.String className)
      Returns whether this package map node contains a class.
      boolean containsPackage​(java.lang.String pkgName)
      Returns whether this package map node contains a package.
      ClassFile getClassEntry​(LibraryInfo info, java.lang.String[] items)
      Returns a class entry.
      void getClassesInPackage​(LibraryInfo info, java.util.List<ClassFile> addTo, java.lang.String[] pkgs, boolean inPkg)
      Returns the classes in a package.
      (package private) void getClassesWithNamesStartingWith​(LibraryInfo info, java.lang.String prefix, java.lang.String currentPkg, java.util.List<ClassFile> addTo)
      Method used to recursively scan our package map for classes whose names start with a given prefix, ignoring case.
      private static void possiblyAddTo​(java.util.Collection<ClassFile> addTo, ClassFile cf, boolean inPkg)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • subpackages

        private java.util.SortedMap<java.lang.String,​PackageMapNode> subpackages
        A mapping of sub-package name to the sub-packages and classes under it.
      • classFiles

        private java.util.SortedMap<java.lang.String,​ClassFile> classFiles
        A mapping of class file names to class files in this package. The actual ClassFile values are lazily instantiated, so any map entry with a value of null simply has not been created yet.
    • Constructor Detail

      • PackageMapNode

        public PackageMapNode()
    • Method Detail

      • add

        public void add​(java.lang.String className)
        Adds entries for a fully-qualified class name, of the form "org/fife/util/DynamicIntArray.class". This method should only be called on the "root" node of a package map.
        Parameters:
        className - A fully-qualified class name of the form described above.
      • addCompletions

        public void addCompletions​(LibraryInfo info,
                                   org.fife.ui.autocomplete.CompletionProvider provider,
                                   java.lang.String[] pkgNames,
                                   java.util.Set<org.fife.ui.autocomplete.Completion> addTo)
        Gets the completions in this package map that match a given string.
        Parameters:
        info - The library info.
        provider - The parent completion provider.
        pkgNames - The text to match, split into tokens around the '.' character. This should be (the start of) a fully-qualified class, interface, or enum name.
        addTo - The list to add completion choices to.
      • clearClassFiles

        public int clearClassFiles()
        Removes the cache of all ClassFiles from this package map.
        Returns:
        The number of class file entries removed.
      • clearClassFilesImpl

        private int clearClassFilesImpl​(PackageMapNode pmn)
      • containsClass

        public boolean containsClass​(java.lang.String className)
        Returns whether this package map node contains a class.
        Parameters:
        className - The class name to check.
        Returns:
        Whether it is contained.
      • containsPackage

        public boolean containsPackage​(java.lang.String pkgName)
        Returns whether this package map node contains a package.
        Parameters:
        pkgName - The package to check.
        Returns:
        Whether it is contained.
      • getClassEntry

        public ClassFile getClassEntry​(LibraryInfo info,
                                       java.lang.String[] items)
        Returns a class entry.
        Parameters:
        info - The library info.
        items - The set of items (?).
        Returns:
        The class file entry.
      • getClassesInPackage

        public void getClassesInPackage​(LibraryInfo info,
                                        java.util.List<ClassFile> addTo,
                                        java.lang.String[] pkgs,
                                        boolean inPkg)
        Returns the classes in a package.
        Parameters:
        info - The library info.
        addTo - The collection to add to.
        pkgs - The current set of packages.
        inPkg - Whether to be in the package (?).
      • getClassesWithNamesStartingWith

        void getClassesWithNamesStartingWith​(LibraryInfo info,
                                             java.lang.String prefix,
                                             java.lang.String currentPkg,
                                             java.util.List<ClassFile> addTo)
        Method used to recursively scan our package map for classes whose names start with a given prefix, ignoring case.
        Parameters:
        prefix - The prefix that the unqualified class names must match (ignoring case).
        currentPkg - The package that map belongs to (i.e. all levels of packages scanned before this one), separated by '/'.
        addTo - The list to add any matching ClassFiles to.
      • possiblyAddTo

        private static void possiblyAddTo​(java.util.Collection<ClassFile> addTo,
                                          ClassFile cf,
                                          boolean inPkg)