Class FilenameExtensionIterator

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.String>

    public class FilenameExtensionIterator
    extends java.lang.Object
    implements java.util.Iterator<java.lang.String>
    Iterates through the possible extensions of a filename, from the most specific to the most general.

    For example for the filename example.foo.bar, this iterator would return the following in order:

    1. foo.bar
    2. bar
    Author:
    Garret Wilson
    See Also:
    Filenames.EXTENSION_SEPARATOR
    • Constructor Summary

      Constructors 
      Constructor Description
      FilenameExtensionIterator​(java.lang.CharSequence filename)
      Filename constructor using the normal filename extension delimiter.
      FilenameExtensionIterator​(java.lang.CharSequence filename, char extensionDelimiter)
      Filename and delimiter constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected int findNextDelimiterIndex()
      Determines the next delimiter index based on the current "next" delimiter index.
      boolean hasNext()  
      java.lang.String next()  
      • Methods inherited from class java.lang.Object

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

        forEachRemaining, remove
    • Constructor Detail

      • FilenameExtensionIterator

        public FilenameExtensionIterator​(@Nonnull
                                         java.lang.CharSequence filename)
        Filename constructor using the normal filename extension delimiter.
        Parameters:
        filename - The filename over which extensions should be iterated.
        See Also:
        Filenames.EXTENSION_SEPARATOR
      • FilenameExtensionIterator

        public FilenameExtensionIterator​(@Nonnull
                                         java.lang.CharSequence filename,
                                         char extensionDelimiter)
        Filename and delimiter constructor.
        Parameters:
        filename - The filename over which extensions should be iterated.
        extensionDelimiter - The filename extension delimiter.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.String>
      • next

        public java.lang.String next()
        Specified by:
        next in interface java.util.Iterator<java.lang.String>
      • findNextDelimiterIndex

        protected int findNextDelimiterIndex()
        Determines the next delimiter index based on the current "next" delimiter index.
        Returns:
        The index of the new "next" delimiter index, based on the current "next" delimiter index.