Package org.apache.commons.collections.iterators

Examples of org.apache.commons.collections.iterators.ArrayIterator


        {
            colIterator = ((Collection) collectionOrArray).iterator();
        }
        else if (collectionOrArray.getClass().isArray())
        {
            colIterator = new ArrayIterator(collectionOrArray);
        }
        else
        {
            throw new OJBRuntimeException( "Given object collection of type '"
                    + (collectionOrArray != null ? collectionOrArray.getClass().toString() : "null")
View Full Code Here


            return list.iterator();
        } else if ( value instanceof Map ) {
            Map map = (Map) value;
            return map.entrySet().iterator();
        } else if ( value.getClass().isArray() ) {
            return new ArrayIterator( value );
        } else if ( value instanceof Enumeration ) {
            return new EnumerationIterator((Enumeration ) value);
        } else if ( value instanceof Collection ) {
          Collection collection = (Collection) value;
          return collection.iterator();
        } else if ( value instanceof String ) {
           String[] array = StringUtils.split((String) value, "," );
           array = StringUtils.stripAll( array );
           return new ArrayIterator( array );
        } else {
            // XXX: should we return single iterator?
            return new SingletonIterator( value );
        }
    }
View Full Code Here

     * @return  an iterator over the array
     * @throws IllegalArgumentException if the array is not an array
     * @throws NullPointerException if array is null
     */
    public static ResettableIterator arrayIterator(Object array) {
        return new ArrayIterator(array);
    }
View Full Code Here

     * @throws IndexOutOfBoundsException if start is less than zero or greater
     *  than the length of the array
     * @throws NullPointerException if array is null
     */
    public static ResettableIterator arrayIterator(Object array, int start) {
        return new ArrayIterator(array, start);
    }
View Full Code Here

     * @throws IndexOutOfBoundsException if array bounds are invalid
     * @throws IllegalArgumentException if end is before start
     * @throws NullPointerException if array is null
     */
    public static ResettableIterator arrayIterator(Object array, int start, int end) {
        return new ArrayIterator(array, start, end);
    }
View Full Code Here

           
        } else if (obj instanceof Dictionary) {
            return new EnumerationIterator(((Dictionary) obj).elements());
           
        } else if (obj != null && obj.getClass().isArray()) {
            return new ArrayIterator(obj);
           
        } else {
            try {
                Method method = obj.getClass().getMethod("iterator", (Class[]) null);
                if (Iterator.class.isAssignableFrom(method.getReturnType())) {
View Full Code Here

            if (result instanceof Iterable) {
                itty = ((Iterable) result).iterator();
            } else if (result instanceof Iterator) {
                itty = (Iterator) result;
            } else if (result instanceof Object[]) {
                itty = new ArrayIterator((Object[]) result);
            } else if (result instanceof Map) {
                itty = ((Map) result).entrySet().iterator();
            } else if (result instanceof Throwable) {
                itty = new SingleIterator<Object>(((Throwable) result).getMessage());
            } else {
View Full Code Here

            }
        }
        assertEquals(count, 27);

        // check indexDelay section
        ArrayIterator iterator = new ArrayIterator(stat.split("\n"));
        while (iterator.hasNext() && !iterator.next().equals("indexDelay"));
        Set<String> stringSet = new HashSet<>();
        for (int i = 0; i < 6; ++i) {
            String s = (String) iterator.next();
            assertTrue(Long.parseLong(s.split(":")[1]) > 0);
            stringSet.add(s.split(":")[0]);
        }
        assertEquals(stringSet.size(), 6);
    }
View Full Code Here

  public void shouldMapSearchRequestToPage() {
    //Given
    SearchHit[] hits = {createCarHit("Ford", "Grat"), createCarHit("BMW", "Arrow")};
    SearchHits searchHits = mock(SearchHits.class);
    when(searchHits.totalHits()).thenReturn(2L);
    when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
    when(response.getHits()).thenReturn(searchHits);

    //When
    FacetedPage<Car> page = resultMapper.mapResults(response, Car.class, null);
View Full Code Here

  public void shouldMapPartialSearchRequestToObject() {
    //Given
    SearchHit[] hits = {createCarPartialHit("Ford", "Grat"), createCarPartialHit("BMW", "Arrow")};
    SearchHits searchHits = mock(SearchHits.class);
    when(searchHits.totalHits()).thenReturn(2L);
    when(searchHits.iterator()).thenReturn(new ArrayIterator(hits));
    when(response.getHits()).thenReturn(searchHits);

    //When
    FacetedPage<Car> page = resultMapper.mapResults(response, Car.class, null);
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.iterators.ArrayIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.