public class CollectionTool
extends org.apache.velocity.tools.generic.CollectionTool
Constructor and Description |
---|
CollectionTool() |
Modifier and Type | Method and Description |
---|---|
<E> Collection<E> |
disjunction(Collection<E> a,
Collection<E> b)
Returns a
Collection containing the exclusive disjunction (symmetric difference) of the given
Collection s. |
<E> List<E> |
getArrayList()
Create and return a new
ArrayList , an unbounded list with constant access time and good performance for
most additions at the end of the list, but which performs poorly when deleting items, when inserting a new item
in the list and when appending a new item requires resizing the allocated space. |
<E> BlockingQueue<E> |
getBlockingQueue()
Create and return a new
BlockingQueue , an unbounded queue that additionally supports operations that wait
for the queue to become non-empty when retrieving an element. |
<E> List<E> |
getLinkedList()
Create and return a new
LinkedList , optimized for insertion and deletion of items, and for sequential
iteration over the items, but not for quick access to random positions in the list. |
<K,V> Map<K,V> |
getMap()
Create and return a new
Map , providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the map. |
<K,V> Map<K,V> |
getOrderedMap()
Create and return a new
Map , which ensures that iterating the map will always return the entries in the
same order as they were added. |
<E> Set<E> |
getOrderedSet()
Create and return a new
Set , which ensures that iterating the set will always return the entries in the
same order as they were added. |
<E extends Comparable<E>> |
getPriorityQueue()
Create and return a new
Queue , which instead of the FIFO ordering uses the natural order of the items
added to the queue, so that the retrieved item is always the lowest one. |
<E> Queue<E> |
getQueue()
Create and return a new
Queue , an unbounded list where items are ordered in a FIFO (first-in-first-out)
manner. |
<E> Set<E> |
getSet()
Create and return a new
Set , providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the set. |
<K extends Comparable<K>,V> |
getSortedMap()
Create and return a new
SortedMap , which ensures that iterating the map will always return the entries in
the natural order of the keys. |
<E extends Comparable<E>> |
getSortedSet()
Create and return a new
SortedSet , which ensures that iterating the set will always return the entries in
the natural order of the items. |
<E> Collection<E> |
intersection(Collection<E> a,
Collection<E> b)
Returns a
Collection containing the intersection of the given Collection s. |
<E> boolean |
reverseModifiable(List<E> input)
Reverse the order of the elements within a list, so that the last element is moved to the beginning of the list,
the next-to-last element to the second position, and so on.
|
<E extends Comparable<E>> |
sortModifiable(List<E> input)
Sort the elements within a list according to their natural order.
|
<E> Collection<E> |
union(Collection<E> a,
Collection<E> b)
Returns a
Collection containing the union of the given Collection s. |
<E> Collection<E> |
unmodifiable(Collection<E> input)
Returns an unmodifiable view of the specified collection.
|
<E> List<E> |
unmodifiable(List<E> input)
Returns an unmodifiable view of the specified list.
|
<K,V> Map<K,V> |
unmodifiable(Map<K,V> input)
Returns an unmodifiable view of the specified map.
|
<E> Set<E> |
unmodifiable(Set<E> input)
Returns an unmodifiable view of the specified set.
|
configure, getComparable, getStringsDelimiter, getStringsTrim, internalSort, setStringsDelimiter, setStringsTrim, sort, sort, sort, sort, sort, sort, sort, sort, sort, sort, sort, sort, split
public <E> List<E> getArrayList()
ArrayList
, an unbounded list with constant access time and good performance for
most additions at the end of the list, but which performs poorly when deleting items, when inserting a new item
in the list and when appending a new item requires resizing the allocated space.E
- the type of the elements in the listArrayList
public <E> List<E> getLinkedList()
LinkedList
, optimized for insertion and deletion of items, and for sequential
iteration over the items, but not for quick access to random positions in the list.E
- the type of the elements in the listLinkedList
public <K,V> Map<K,V> getMap()
Map
, providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the map.K
- the type of keys maintained by this mapV
- the type of mapped valuesHashMap
public <K extends Comparable<K>,V> SortedMap<K,V> getSortedMap()
SortedMap
, which ensures that iterating the map will always return the entries in
the natural order of the keys.K
- the type of keys maintained by this mapV
- the type of mapped valuesTreeMap
public <K,V> Map<K,V> getOrderedMap()
Map
, which ensures that iterating the map will always return the entries in the
same order as they were added.K
- the type of keys maintained by this mapV
- the type of mapped valuesLinkedHashMap
public <E> Set<E> getSet()
Set
, providing good speed for insertion, retrieval and deletion of items, but
with no guarantees on the order of the set.E
- the type of the elements in the setHashSet
public <E extends Comparable<E>> SortedSet<E> getSortedSet()
SortedSet
, which ensures that iterating the set will always return the entries in
the natural order of the items.E
- the type of the elements in the setTreeSet
public <E> Set<E> getOrderedSet()
Set
, which ensures that iterating the set will always return the entries in the
same order as they were added.E
- the type of the elements in the setLinkedHashSet
public <E> Queue<E> getQueue()
Queue
, an unbounded list where items are ordered in a FIFO (first-in-first-out)
manner.E
- the type of the elements in the queueLinkedList
public <E> BlockingQueue<E> getBlockingQueue()
BlockingQueue
, an unbounded queue that additionally supports operations that wait
for the queue to become non-empty when retrieving an element.E
- the type of the elements in the queueBlockingQueue
public <E extends Comparable<E>> Queue<E> getPriorityQueue()
Queue
, which instead of the FIFO ordering uses the natural order of the items
added to the queue, so that the retrieved item is always the lowest one. All the items added to this queue must
be non-null and be comparable with the other items in the queue.E
- the type of the elements in the queuePriorityQueue
public <E> List<E> unmodifiable(List<E> input)
E
- the type of the elements in the listinput
- the list to wrap in an unmodifiable bridgepublic <K,V> Map<K,V> unmodifiable(Map<K,V> input)
K
- the type of keys maintained by this mapV
- the type of mapped valuesinput
- the map to wrap in an unmodifiable bridgepublic <E> Set<E> unmodifiable(Set<E> input)
E
- the type of the elements in the setinput
- the set to wrap in an unmodifiable bridgepublic <E> Collection<E> unmodifiable(Collection<E> input)
E
- the type of the elements in the collectioninput
- the collection to wrap in an unmodifiable bridgepublic <E> Collection<E> union(Collection<E> a, Collection<E> b)
Collection
containing the union of the given Collection
s.E
- the type of the elements in the collectiona
- the first collection, must be non-nullb
- the second collection, must be non-nullpublic <E> Collection<E> intersection(Collection<E> a, Collection<E> b)
Collection
containing the intersection of the given Collection
s.E
- the type of the elements in the collectiona
- the first collection, must be non-nullb
- the second collection, must be non-nullpublic <E> Collection<E> disjunction(Collection<E> a, Collection<E> b)
Collection
containing the exclusive disjunction (symmetric difference) of the given
Collection
s.E
- the type of the elements in the collectiona
- the first collection, must be non-nullb
- the second collection, must be non-nullpublic <E> boolean reverseModifiable(List<E> input)
E
- the type of the elements in the listinput
- the list to reversetrue
if the list was successfully reversed, false
otherwisepublic <E extends Comparable<E>> boolean sortModifiable(List<E> input)
E
- the type of the elements in the listinput
- the list to sorttrue
if the list was successfully sorted, false
otherwiseCopyright © 2004–2021 XWiki. All rights reserved.