/** * Gets a list iterator over an object or primitive array. * <p> * This method will handle primitive arrays as well as object arrays. * The primitives will be wrapped in the appropriate wrapper class. * * @param <E> the element type * @param array the array over which to iterate * @return a list iterator over the array * @throws IllegalArgumentException if the array is not an array * @throws NullPointerException if array is null */ public static <E> ResettableListIterator<E> arrayListIterator(final Object array) { return new ArrayListIterator<>(array); }
/** * Gets the next element from the array. * * @return the next element * @throws NoSuchElementException if there is no next element */ @Override @SuppressWarnings("unchecked") public E next() { if (hasNext() == false) { throw new NoSuchElementException(); } this.lastItemIndex = this.index; return (E) Array.get(this.array, this.index++); }
/** * Gets the previous element from the array. * * @return the previous element * @throws NoSuchElementException if there is no previous element */ @Override @SuppressWarnings("unchecked") public E previous() { if (hasPrevious() == false) { throw new NoSuchElementException(); } this.lastItemIndex = --this.index; return (E) Array.get(this.array, this.index); }
/** * Gets a list iterator over the end part of an object or primitive array. * <p> * This method will handle primitive arrays as well as object arrays. * The primitives will be wrapped in the appropriate wrapper class. * * @param <E> the element type * @param array the array over which to iterate * @param start the index to start iterating at * @return a list iterator over part of the array * @throws IllegalArgumentException if the array is not an array * @throws IndexOutOfBoundsException if start is less than zero * @throws NullPointerException if array is null */ public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start) { return new ArrayListIterator<>(array, start); }
/** * Gets a list iterator over part of an object or primitive array. * <p> * This method will handle primitive arrays as well as object arrays. * The primitives will be wrapped in the appropriate wrapper class. * * @param <E> the element type * @param array the array over which to iterate * @param start the index to start iterating at * @param end the index to finish iterating at * @return a list iterator over part of the array * @throws IllegalArgumentException if the array is not an array or end is before start * @throws IndexOutOfBoundsException if array bounds are invalid * @throws NullPointerException if array is null */ public static <E> ResettableListIterator<E> arrayListIterator(final Object array, final int start, final int end) { return new ArrayListIterator<>(array, start, end); }
/** * Convert an array of fully qualified class names into an array of Class objects * @param parameterClassNames * @return */ protected final Class[] getParameters(String[] parameterClassNames) { if(parameterClassNames == null) { return new Class[0]; } Vector<Class> classes = new Vector<Class>(); Iterator<String> classNames = new ArrayListIterator(parameterClassNames); while(classNames.hasNext()) { classes.add(getClass(classNames.next(), "parameter")); } return classes.toArray(new Class[classes.size()]); } /**