Class ResourceFilePool

  • All Implemented Interfaces:
    FilePool

    public class ResourceFilePool
    extends java.lang.Object
    implements FilePool
    This is a set of ResourceFile instances. They can be enumerated or retrieved by name. They can also be accessed by means of resource file visitors.
    • Constructor Summary

      Constructors 
      Constructor Description
      ResourceFilePool()
      Creates a new empty ResourceFilePool.
      ResourceFilePool​(java.lang.Iterable<? extends ResourceFile> resourceFiles)
      Creates a new ResourceFilePool with the given resource files.
      ResourceFilePool​(ResourceFile... resourceFiles)
      Creates a new ResourceFilePool with the given resource files.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addResourceFile​(java.lang.String fileName, ResourceFile resourceFile)
      Adds the given ResourceFile with the given name to this pool.
      void addResourceFile​(ResourceFile resourceFile)
      Adds the given ResourceFile to this pool.
      void clear()
      Clears the pool.
      ResourceFile getResourceFile​(java.lang.String fileName)
      Returns a ResourceFile from this pool, based on its name.
      ResourceFilePool refreshedCopy()
      Returns a ResourceFilePool with the same resource files, but with the keys that correspond to the names of the resource file instances.
      void removeResourceFile​(java.lang.String fileName)
      Removes the specified ResourceFile from this pool.
      java.util.Set<java.lang.String> resourceFileNames()
      Returns a Set of all resource file names in this resource file pool.
      void resourceFilesAccept​(java.lang.String fileNameFilter, ResourceFileVisitor resourceFileVisitor)
      Applies the given ResourceFileVisitor to all resource files in this pool matching the given file name filter.
      void resourceFilesAccept​(java.util.List<java.lang.String> fileNameFilter, ResourceFileVisitor resourceFileVisitor)
      Applies the given ResourceFileVisitor to all resource files in this pool matching the given file name filters.
      void resourceFilesAccept​(ResourceFileVisitor resourceFileVisitor)
      Applies the given ResourceFileVisitor to all instances in this pool.
      void resourceFilesAccept​(StringMatcher fileNameFilter, ResourceFileVisitor resourceFileVisitor)
      Applies the given ResourceFileVisitor to all resource files in this pool matching the given file name filter.
      int size()
      Returns the number of resource files in this pool.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • resourceFileMap

        protected final java.util.Map<java.lang.String,​ResourceFile> resourceFileMap
    • Constructor Detail

      • ResourceFilePool

        public ResourceFilePool()
        Creates a new empty ResourceFilePool.
      • ResourceFilePool

        public ResourceFilePool​(ResourceFile... resourceFiles)
        Creates a new ResourceFilePool with the given resource files.
        Parameters:
        resourceFiles - the resource files to be added.
      • ResourceFilePool

        public ResourceFilePool​(java.lang.Iterable<? extends ResourceFile> resourceFiles)
        Creates a new ResourceFilePool with the given resource files.
        Parameters:
        resourceFiles - the resource files to be added.
    • Method Detail

      • clear

        public void clear()
        Clears the pool.
      • addResourceFile

        public void addResourceFile​(ResourceFile resourceFile)
        Adds the given ResourceFile to this pool.
      • addResourceFile

        public void addResourceFile​(java.lang.String fileName,
                                    ResourceFile resourceFile)
        Adds the given ResourceFile with the given name to this pool.
      • removeResourceFile

        public void removeResourceFile​(java.lang.String fileName)
        Removes the specified ResourceFile from this pool.
      • getResourceFile

        public ResourceFile getResourceFile​(java.lang.String fileName)
        Returns a ResourceFile from this pool, based on its name. Returns null if the instance with the given name is not in the pool.
        Specified by:
        getResourceFile in interface FilePool
      • size

        public int size()
        Returns the number of resource files in this pool.
      • refreshedCopy

        public ResourceFilePool refreshedCopy()
        Returns a ResourceFilePool with the same resource files, but with the keys that correspond to the names of the resource file instances. This can be useful to create a resource file pool with obfuscated names.
      • resourceFileNames

        public java.util.Set<java.lang.String> resourceFileNames()
        Returns a Set of all resource file names in this resource file pool.
        Specified by:
        resourceFileNames in interface FilePool
      • resourceFilesAccept

        public void resourceFilesAccept​(java.lang.String fileNameFilter,
                                        ResourceFileVisitor resourceFileVisitor)
        Applies the given ResourceFileVisitor to all resource files in this pool matching the given file name filter.
        Specified by:
        resourceFilesAccept in interface FilePool
      • resourceFilesAccept

        public void resourceFilesAccept​(java.util.List<java.lang.String> fileNameFilter,
                                        ResourceFileVisitor resourceFileVisitor)
        Applies the given ResourceFileVisitor to all resource files in this pool matching the given file name filters.
        Specified by:
        resourceFilesAccept in interface FilePool
      • resourceFilesAccept

        public void resourceFilesAccept​(StringMatcher fileNameFilter,
                                        ResourceFileVisitor resourceFileVisitor)
        Applies the given ResourceFileVisitor to all resource files in this pool matching the given file name filter.
        Specified by:
        resourceFilesAccept in interface FilePool
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object