/** * Returns an iterator over this group of headers. * * @return iterator over this group of headers. * * @since 4.0 */ public HeaderIterator iterator() { return new BasicListHeaderIterator(this.headers, null); }
/** * Determines the index of the next header. * * @param from one less than the index to consider first, * -1 to search for the first header * * @return the index of the next header that matches the filter name, * or negative if there are no more headers */ protected int findNext(int from) { if (from < -1) return -1; final int to = this.allHeaders.size()-1; boolean found = false; while (!found && (from < to)) { from++; found = filterHeader(from); } return found ? from : -1; }
/** * Creates a new header iterator. * * @param headers a list of headers over which to iterate * @param name the name of the headers over which to iterate, or * <code>null</code> for any */ public BasicListHeaderIterator(List headers, String name) { if (headers == null) { throw new IllegalArgumentException ("Header list must not be null."); } this.allHeaders = headers; this.headerName = name; this.currentIndex = findNext(-1); this.lastIndex = -1; }
/** * Returns the next header. * Same as {@link #nextHeader nextHeader}, but not type-safe. * * @return the next header in this iteration * * @throws NoSuchElementException if there are no more headers */ public final Object next() throws NoSuchElementException { return nextHeader(); }
/** * Returns the next header. * Same as {@link #nextHeader nextHeader}, but not type-safe. * * @return the next header in this iteration * * @throws NoSuchElementException if there are no more headers */ public final Object next() throws NoSuchElementException { return nextHeader(); }
/** * Returns an iterator over the headers with a given name in this group. * * @param name the name of the headers over which to iterate, or * <code>null</code> for all headers * * @return iterator over some headers in this group. * * @since 4.0 */ public HeaderIterator iterator(final String name) { return new BasicListHeaderIterator(this.headers, name); }
/** * Obtains the next header from this iteration. * * @return the next header in this iteration * * @throws NoSuchElementException if there are no more headers */ public Header nextHeader() throws NoSuchElementException { final int current = this.currentIndex; if (current < 0) { throw new NoSuchElementException("Iteration already finished."); } this.lastIndex = current; this.currentIndex = findNext(current); return (Header) this.allHeaders.get(current); }
/** * Returns the next header. * Same as {@link #nextHeader nextHeader}, but not type-safe. * * @return the next header in this iteration * * @throws NoSuchElementException if there are no more headers */ public final Object next() throws NoSuchElementException { return nextHeader(); }
/** * Determines the index of the next header. * * @param from one less than the index to consider first, * -1 to search for the first header * * @return the index of the next header that matches the filter name, * or negative if there are no more headers */ protected int findNext(int from) { if (from < -1) return -1; final int to = this.allHeaders.size()-1; boolean found = false; while (!found && (from < to)) { from++; found = filterHeader(from); } return found ? from : -1; }
/** * Returns an iterator over this group of headers. * * @return iterator over this group of headers. * * @since 4.0 */ public HeaderIterator iterator() { return new BasicListHeaderIterator(this.headers, null); }
/** * Creates a new header iterator. * * @param headers a list of headers over which to iterate * @param name the name of the headers over which to iterate, or * <code>null</code> for any */ public BasicListHeaderIterator(List headers, String name) { if (headers == null) { throw new IllegalArgumentException ("Header list must not be null."); } this.allHeaders = headers; this.headerName = name; this.currentIndex = findNext(-1); this.lastIndex = -1; }
/** * Returns the next header. * Same as {@link #nextHeader nextHeader}, but not type-safe. * * @return the next header in this iteration * * @throws NoSuchElementException if there are no more headers */ @Override public final Object next() throws NoSuchElementException { return nextHeader(); }
/** * Determines the index of the next header. * * @param pos one less than the index to consider first, * -1 to search for the first header * * @return the index of the next header that matches the filter name, * or negative if there are no more headers */ protected int findNext(final int pos) { int from = pos; if (from < -1) { return -1; } final int to = this.allHeaders.size()-1; boolean found = false; while (!found && (from < to)) { from++; found = filterHeader(from); } return found ? from : -1; }
/** * Returns an iterator over this group of headers. * * @return iterator over this group of headers. * * @since 4.0 */ public HeaderIterator iterator() { return new BasicListHeaderIterator(this.headers, null); }
/** * Creates a new header iterator. * * @param headers a list of headers over which to iterate * @param name the name of the headers over which to iterate, or * <code>null</code> for any */ public BasicListHeaderIterator(List headers, String name) { if (headers == null) { throw new IllegalArgumentException ("Header list must not be null."); } this.allHeaders = headers; this.headerName = name; this.currentIndex = findNext(-1); this.lastIndex = -1; }
/** * Returns the next header. * Same as {@link #nextHeader nextHeader}, but not type-safe. * * @return the next header in this iteration * * @throws NoSuchElementException if there are no more headers */ public final Object next() throws NoSuchElementException { return nextHeader(); }
/** * Determines the index of the next header. * * @param from one less than the index to consider first, * -1 to search for the first header * * @return the index of the next header that matches the filter name, * or negative if there are no more headers */ protected int findNext(int from) { if (from < -1) return -1; final int to = this.allHeaders.size()-1; boolean found = false; while (!found && (from < to)) { from++; found = filterHeader(from); } return found ? from : -1; }
/** * Returns an iterator over this group of headers. * * @return iterator over this group of headers. * * @since 4.0 */ public HeaderIterator iterator() { return new BasicListHeaderIterator(this.headers, null); }
/** * Creates a new header iterator. * * @param headers a list of headers over which to iterate * @param name the name of the headers over which to iterate, or * <code>null</code> for any */ public BasicListHeaderIterator(List headers, String name) { if (headers == null) { throw new IllegalArgumentException ("Header list must not be null."); } this.allHeaders = headers; this.headerName = name; this.currentIndex = findNext(-1); this.lastIndex = -1; }
/** * Returns the next header. * Same as {@link #nextHeader nextHeader}, but not type-safe. * * @return the next header in this iteration * * @throws NoSuchElementException if there are no more headers */ public final Object next() throws NoSuchElementException { return nextHeader(); }