Class CookieParser.Sequence

  • All Implemented Interfaces:
    java.util.Iterator<Cookie>
    Enclosing class:
    CookieParser

    private class CookieParser.Sequence
    extends java.lang.Object
    implements java.util.Iterator<Cookie>
    This is used to represent an Iterator that will iterate over the available cookies within the provided source text. This allows the cookie parser to be used as an iterable with for each loops. Cookies can not be removed with this.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Sequence()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Determine whether or not there are any Cookies left in the String.
      Cookie next()
      Extracts the next Cookie object from the string given.
      void remove()
      This method is used to remove items from the iterator.
      • 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
    • Constructor Detail

      • Sequence

        private Sequence()
    • Method Detail

      • next

        public Cookie next()
        Extracts the next Cookie object from the string given. This will return null when there are no more cookies left in the String being parsed.

        To find out when there are no more cookies left use the hasNext method. This will only set the name, value, path, domain name version of the cookie because as of RFC 2109 these are the only attributes a Cookie may have, the path and domain are optional.

        Specified by:
        next in interface java.util.Iterator<Cookie>
        Returns:
        an initialized Cookie object
      • hasNext

        public boolean hasNext()
        Determine whether or not there are any Cookies left in the String. This will attempt to extract another Cookie from the String and cache the result so the next method will produce this Cookie. If another Cookie cannot be parsed from the remainder of the String then this will return false otherwise it will return true.
        Specified by:
        hasNext in interface java.util.Iterator<Cookie>
        Returns:
        true if there are more cookies false otherwise
      • remove

        public void remove()
        This method is used to remove items from the iterator. This however performs no action as the act of parsing should not modify the underlying source text value so that it can be reset with the reset method and used again.
        Specified by:
        remove in interface java.util.Iterator<Cookie>