@Override public List<ProcessTask> handle(EntityManager manager) throws Exception { if (!file.exists()) { return todo; } try (ZipFile zip = new ZipFile(file)) { for (ZipArchiveEntry entry : new IteratorIterable<>(new EnumerationIterator<>(zip.getEntries()))) { try { handleSingleZipEntry(zip, entry, manager); } catch (IOException ex) { System.out.println(ex.getLocalizedMessage()); } } } return todo; }
@Override public Object transform(Object input) { fireTreeStructureChanged(); if (input instanceof TreeObject) { TreeObject treeObject = (TreeObject) input; if (treeObject.isFile()) { return treeObject; } else { return new EnumerationIterator<TreeObject>( treeObject.children()); } } Class<?> clazz = null; if (input != null) { clazz = input.getClass(); } throw new ClassCastException("Can only handle TreeObjects but was " + clazz); }
/** * Gets an iterator that provides an iterator view of the given enumeration * that will remove elements from the specified collection. * * @param <E> the element type * @param enumeration the enumeration to use, may not be null * @param removeCollection the collection to remove elements from, may not be null * @return a new iterator * @throws NullPointerException if enumeration or removeCollection is null */ public static <E> Iterator<E> asIterator(final Enumeration<? extends E> enumeration, final Collection<? super E> removeCollection) { if (enumeration == null) { throw new NullPointerException("Enumeration must not be null"); } if (removeCollection == null) { throw new NullPointerException("Collection must not be null"); } return new EnumerationIterator<E>(enumeration, removeCollection); }
/** * Gets an iterator that provides an iterator view of the given enumeration. * * @param <E> the element type * @param enumeration the enumeration to use, may not be null * @return a new iterator * @throws NullPointerException if enumeration is null */ public static <E> Iterator<E> asIterator(final Enumeration<? extends E> enumeration) { if (enumeration == null) { throw new NullPointerException("Enumeration must not be null"); } return new EnumerationIterator<E>(enumeration); }
/** * Creates a list based on an enumeration. * * <p>As the enumeration is traversed, an ArrayList of its values is * created. The new list is returned.</p> * * @param <E> the element type * @param enumeration the enumeration to traverse, which should not be <code>null</code>. * @return a list containing all elements of the given enumeration * @throws NullPointerException if the enumeration parameter is <code>null</code>. */ public static <E> List<E> toList(final Enumeration<? extends E> enumeration) { return IteratorUtils.toList(new EnumerationIterator<E>(enumeration)); }
/** * 判断<code>enumeration</code>枚举里面,是否有指定的元素<code>value</code>. * * <h3>示例:</h3> * * <blockquote> * * <pre class="code"> * EnumerationUtil.contains(null, "a") = false * * EnumerationUtil.contains(toEnumeration(toList("4", "5")), "a") = false * EnumerationUtil.contains(toEnumeration(toList("4", "5")), "4") = true * EnumerationUtil.contains(toEnumeration(toList("4", "5", "")), "") = true * EnumerationUtil.contains(toEnumeration(toList("4", "5", "", null)), null) = true * </pre> * * </blockquote> * * @param <O> * the generic type * @param enumeration * the enumeration * @param value * 指定的元素 * @return 如果 <code>enumeration</code> 是null或者empty,返回 false<br> * 否则如果 contains 返回true,<br> * 其他返回false * @see "org.springframework.util.CollectionUtils#contains(Enumeration, Object)" * @see org.apache.commons.collections4.iterators.EnumerationIterator * @see org.apache.commons.collections4.IteratorUtils#contains(java.util.Iterator, Object) */ public static <O> boolean contains(Enumeration<O> enumeration,O value){ return isNullOrEmpty(enumeration) ? false : IteratorUtils.contains(new EnumerationIterator<O>(enumeration), value); }
/** * Access the parameter names. * * @return An Iterator of parameter names (String). */ public Iterator<String> getNames() { return new EnumerationIterator(m_req.getParameterNames()); }