Class BasicTokenIterator

  • All Implemented Interfaces:
    java.util.Iterator<java.lang.Object>, TokenIterator

    public class BasicTokenIterator
    extends java.lang.Object
    implements TokenIterator
    Basic implementation of a TokenIterator. This implementation parses #token sequences as defined by RFC 2616, section 2. It extends that definition somewhat beyond US-ASCII.
    Since:
    4.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String HTTP_SEPARATORS
      The HTTP separator characters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()
      Indicates whether there is another token in this iteration.
      java.lang.Object next()
      Returns the next token.
      java.lang.String nextToken()
      Obtains the next token from this iteration.
      void remove()
      Removing tokens is not supported.
      • Methods inherited from class java.lang.Object

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

        forEachRemaining
    • Field Detail

      • HTTP_SEPARATORS

        public static final java.lang.String HTTP_SEPARATORS
        The HTTP separator characters. Defined in RFC 2616, section 2.2.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BasicTokenIterator

        public BasicTokenIterator​(HeaderIterator headerIterator)
        Creates a new instance of BasicTokenIterator.
        Parameters:
        headerIterator - the iterator for the headers to tokenize
    • Method Detail

      • hasNext

        public boolean hasNext()
        Description copied from interface: TokenIterator
        Indicates whether there is another token in this iteration.
        Specified by:
        hasNext in interface java.util.Iterator<java.lang.Object>
        Specified by:
        hasNext in interface TokenIterator
        Returns:
        true if there is another token, false otherwise
      • nextToken

        public java.lang.String nextToken()
                                   throws java.util.NoSuchElementException,
                                          ParseException
        Obtains the next token from this iteration.
        Specified by:
        nextToken in interface TokenIterator
        Returns:
        the next token in this iteration
        Throws:
        java.util.NoSuchElementException - if the iteration is already over
        ParseException - if an invalid header value is encountered
      • next

        public final java.lang.Object next()
                                    throws java.util.NoSuchElementException,
                                           ParseException
        Returns the next token. Same as nextToken(), but with generic return type.
        Specified by:
        next in interface java.util.Iterator<java.lang.Object>
        Returns:
        the next token in this iteration
        Throws:
        java.util.NoSuchElementException - if there are no more tokens
        ParseException - if an invalid header value is encountered
      • remove

        public final void remove()
                          throws java.lang.UnsupportedOperationException
        Removing tokens is not supported.
        Specified by:
        remove in interface java.util.Iterator<java.lang.Object>
        Throws:
        java.lang.UnsupportedOperationException - always