depends.org.apache.http.message

类 BasicTokenIterator

    • 方法概要

      方法 
      限定符和类型 方法和说明
      protected java.lang.String createToken(java.lang.String value, int start, int end)
      Creates a new token to be returned.
      protected int findNext(int pos)
      Determines the next token.
      protected int findTokenEnd(int from)
      Determines the ending position of the current token.
      protected int findTokenSeparator(int pos)
      Determines the position of the next token separator.
      protected int findTokenStart(int pos)
      Determines the starting position of the next token.
      boolean hasNext()
      Indicates whether there is another token in this iteration.
      protected boolean isHttpSeparator(char ch)
      Checks whether a character is an HTTP separator.
      protected boolean isTokenChar(char ch)
      Checks whether a character is a valid token character.
      protected boolean isTokenSeparator(char ch)
      Checks whether a character is a token separator.
      protected boolean isWhitespace(char ch)
      Checks whether a character is a whitespace character.
      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.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • HTTP_SEPARATORS

        public static final java.lang.String HTTP_SEPARATORS
        The HTTP separator characters. Defined in RFC 2616, section 2.2.
        另请参阅:
        常量字段值
      • headerIt

        protected final HeaderIterator headerIt
        The iterator from which to obtain the next header.
      • currentHeader

        protected java.lang.String currentHeader
        The value of the current header. This is the header value that includes currentToken. Undefined if the iteration is over.
      • currentToken

        protected java.lang.String currentToken
        The token to be returned by the next call to nextToken(). null if the iteration is over.
    • 构造器详细资料

      • BasicTokenIterator

        public BasicTokenIterator(HeaderIterator headerIterator)
        Creates a new instance of BasicTokenIterator.
        参数:
        headerIterator - the iterator for the headers to tokenize
    • 方法详细资料

      • hasNext

        public boolean hasNext()
        从接口复制的说明: TokenIterator
        Indicates whether there is another token in this iteration.
        指定者:
        hasNext 在接口中 TokenIterator
        指定者:
        hasNext 在接口中 java.util.Iterator<java.lang.Object>
        返回:
        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.
        指定者:
        nextToken 在接口中 TokenIterator
        返回:
        the next token in this iteration
        抛出:
        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 category.
        指定者:
        next 在接口中 java.util.Iterator<java.lang.Object>
        返回:
        the next token in this iteration
        抛出:
        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.
        指定者:
        remove 在接口中 java.util.Iterator<java.lang.Object>
        抛出:
        java.lang.UnsupportedOperationException - always
      • findNext

        protected int findNext(int pos)
                        throws ParseException
        Determines the next token. If found, the token is stored in currentToken. The return value indicates the position after the token in currentHeader. If necessary, the next header will be obtained from headerIt. If not found, currentToken is set to null.
        参数:
        pos - the position in the current header at which to start the search, -1 to search in the first header
        返回:
        the position after the found token in the current header, or negative if there was no next token
        抛出:
        ParseException - if an invalid header value is encountered
      • createToken

        protected java.lang.String createToken(java.lang.String value,
                                   int start,
                                   int end)
        Creates a new token to be returned. Called from findNext after the token is identified. The default implementation simply calls String.substring.
        If header values are significantly longer than tokens, and some tokens are permanently referenced by the application, there can be problems with garbage collection. A substring will hold a reference to the full characters of the original string and therefore occupies more memory than might be expected. To avoid this, override this method and create a new string instead of a substring.
        参数:
        value - the full header value from which to create a token
        start - the index of the first token character
        end - the index after the last token character
        返回:
        a string representing the token identified by the arguments
      • findTokenStart

        protected int findTokenStart(int pos)
        Determines the starting position of the next token. This method will iterate over headers if necessary.
        参数:
        pos - the position in the current header at which to start the search
        返回:
        the position of the token start in the current header, negative if no token start could be found
      • findTokenSeparator

        protected int findTokenSeparator(int pos)
        Determines the position of the next token separator. Because of multi-header joining rules, the end of a header value is a token separator. This method does therefore not need to iterate over headers.
        参数:
        pos - the position in the current header at which to start the search
        返回:
        the position of a token separator in the current header, or at the end
        抛出:
        ParseException - if a new token is found before a token separator. RFC 2616, section 2.1 explicitly requires a comma between tokens for #.
      • findTokenEnd

        protected int findTokenEnd(int from)
        Determines the ending position of the current token. This method will not leave the current header value, since the end of the header value is a token boundary.
        参数:
        from - the position of the first character of the token
        返回:
        the position after the last character of the token. The behavior is undefined if from does not point to a token character in the current header value.
      • isTokenSeparator

        protected boolean isTokenSeparator(char ch)
        Checks whether a character is a token separator. RFC 2616, section 2.1 defines comma as the separator for #token sequences. The end of a header value will also separate tokens, but that is not a character check.
        参数:
        ch - the character to check
        返回:
        true if the character is a token separator, false otherwise
      • isWhitespace

        protected boolean isWhitespace(char ch)
        Checks whether a character is a whitespace character. RFC 2616, section 2.2 defines space and horizontal tab as whitespace. The optional preceeding line break is irrelevant, since header continuation is handled transparently when parsing messages.
        参数:
        ch - the character to check
        返回:
        true if the character is whitespace, false otherwise
      • isTokenChar

        protected boolean isTokenChar(char ch)
        Checks whether a character is a valid token character. Whitespace, control characters, and HTTP separators are not valid token characters. The HTTP specification (RFC 2616, section 2.2) defines tokens only for the US-ASCII character set, this method extends the definition to extension character sets.
        参数:
        ch - the character to check
        返回:
        true if the character is a valid token start, false otherwise
      • isHttpSeparator

        protected boolean isHttpSeparator(char ch)
        Checks whether a character is an HTTP separator. The implementation in this class checks only for the HTTP separators defined in RFC 2616, section 2.2. If you need to detect extension separators beyond the US-ASCII character set, override this method.
        参数:
        ch - the character to check
        返回:
        true if the character is an HTTP separator