Package org.mycore.frontend.basket
Class MCRBasket
java.lang.Object
org.mycore.frontend.basket.MCRBasket
- All Implemented Interfaces:
Iterable<MCRBasketEntry>
,Collection<MCRBasketEntry>
,List<MCRBasketEntry>
,Set<MCRBasketEntry>
Implements a basket of entries.
The basket has a type attribute that allows to
distinguish multiple baskets within the same session.
The basket implements the List and Set interfaces,
it behaves like an ordered Set of entries.
Entries already contained in the basket can not be
re-added, each entry can be contained only once in the basket.
- Author:
- Frank Lützenkirchen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int index, MCRBasketEntry entry) boolean
add
(MCRBasketEntry entry) boolean
addAll
(int index, Collection<? extends MCRBasketEntry> collection) boolean
addAll
(Collection<? extends MCRBasketEntry> collection) void
clear()
boolean
boolean
containsAll
(Collection<?> c) void
down
(MCRBasketEntry entry) Moves the basket entry one position down in the list of basket entries.get
(int index) Returns the basket entry with the given ID, or null.Returns the ID of the derivate that holds the persistent data of this basket, or nullgetType()
Returns the type of basket.int
boolean
isEmpty()
iterator()
int
listIterator
(int index) void
move
(MCRBasketEntry entry, int change) Moves a basket entry up or down in the list of basket entries.remove
(int index) boolean
boolean
removeAll
(Collection<?> c) boolean
removeEntry
(String id) Removes the entry with the given ID from the basket.void
For all basket entries, if their XML content is not resolved yet, resolves the XML from the given URI in the entry.boolean
retainAll
(Collection<?> c) set
(int index, MCRBasketEntry entry) void
setDerivateID
(String derivateID) Sets the ID of the derivate that holds the persistent data of this basketint
size()
subList
(int fromIndex, int toIndex) Object[]
toArray()
<T> T[]
toArray
(T[] a) void
up
(MCRBasketEntry entry) Moves the basket entry one position up in the list of basket entries.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort
-
Constructor Details
-
MCRBasket
Creates a new basket of the given type.- Parameters:
type
- the type of basket, an attribute that can be used by the application to distinguish multiple basket within the same session.
-
-
Method Details
-
getType
Returns the type of basket. -
getDerivateID
Returns the ID of the derivate that holds the persistent data of this basket, or null -
setDerivateID
Sets the ID of the derivate that holds the persistent data of this basket -
add
- Specified by:
add
in interfaceList<MCRBasketEntry>
-
add
- Specified by:
add
in interfaceCollection<MCRBasketEntry>
- Specified by:
add
in interfaceList<MCRBasketEntry>
- Specified by:
add
in interfaceSet<MCRBasketEntry>
-
addAll
- Specified by:
addAll
in interfaceCollection<MCRBasketEntry>
- Specified by:
addAll
in interfaceList<MCRBasketEntry>
- Specified by:
addAll
in interfaceSet<MCRBasketEntry>
-
addAll
- Specified by:
addAll
in interfaceList<MCRBasketEntry>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<MCRBasketEntry>
- Specified by:
clear
in interfaceList<MCRBasketEntry>
- Specified by:
clear
in interfaceSet<MCRBasketEntry>
-
contains
- Specified by:
contains
in interfaceCollection<MCRBasketEntry>
- Specified by:
contains
in interfaceList<MCRBasketEntry>
- Specified by:
contains
in interfaceSet<MCRBasketEntry>
-
containsAll
- Specified by:
containsAll
in interfaceCollection<MCRBasketEntry>
- Specified by:
containsAll
in interfaceList<MCRBasketEntry>
- Specified by:
containsAll
in interfaceSet<MCRBasketEntry>
-
get
- Specified by:
get
in interfaceList<MCRBasketEntry>
-
get
Returns the basket entry with the given ID, or null.- Parameters:
id
- the ID of the basket entry.
-
indexOf
- Specified by:
indexOf
in interfaceList<MCRBasketEntry>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<MCRBasketEntry>
- Specified by:
isEmpty
in interfaceList<MCRBasketEntry>
- Specified by:
isEmpty
in interfaceSet<MCRBasketEntry>
-
iterator
- Specified by:
iterator
in interfaceCollection<MCRBasketEntry>
- Specified by:
iterator
in interfaceIterable<MCRBasketEntry>
- Specified by:
iterator
in interfaceList<MCRBasketEntry>
- Specified by:
iterator
in interfaceSet<MCRBasketEntry>
-
lastIndexOf
- Specified by:
lastIndexOf
in interfaceList<MCRBasketEntry>
-
listIterator
- Specified by:
listIterator
in interfaceList<MCRBasketEntry>
-
listIterator
- Specified by:
listIterator
in interfaceList<MCRBasketEntry>
-
remove
- Specified by:
remove
in interfaceList<MCRBasketEntry>
-
remove
- Specified by:
remove
in interfaceCollection<MCRBasketEntry>
- Specified by:
remove
in interfaceList<MCRBasketEntry>
- Specified by:
remove
in interfaceSet<MCRBasketEntry>
-
removeEntry
Removes the entry with the given ID from the basket.- Returns:
- true, if the basket entry was removed successfully.
-
removeAll
- Specified by:
removeAll
in interfaceCollection<MCRBasketEntry>
- Specified by:
removeAll
in interfaceList<MCRBasketEntry>
- Specified by:
removeAll
in interfaceSet<MCRBasketEntry>
-
retainAll
- Specified by:
retainAll
in interfaceCollection<MCRBasketEntry>
- Specified by:
retainAll
in interfaceList<MCRBasketEntry>
- Specified by:
retainAll
in interfaceSet<MCRBasketEntry>
-
set
- Specified by:
set
in interfaceList<MCRBasketEntry>
-
size
public int size()- Specified by:
size
in interfaceCollection<MCRBasketEntry>
- Specified by:
size
in interfaceList<MCRBasketEntry>
- Specified by:
size
in interfaceSet<MCRBasketEntry>
-
subList
- Specified by:
subList
in interfaceList<MCRBasketEntry>
-
toArray
- Specified by:
toArray
in interfaceCollection<MCRBasketEntry>
- Specified by:
toArray
in interfaceList<MCRBasketEntry>
- Specified by:
toArray
in interfaceSet<MCRBasketEntry>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<MCRBasketEntry>
- Specified by:
toArray
in interfaceList<MCRBasketEntry>
- Specified by:
toArray
in interfaceSet<MCRBasketEntry>
-
up
Moves the basket entry one position up in the list of basket entries. -
down
Moves the basket entry one position down in the list of basket entries. -
move
Moves a basket entry up or down in the list of basket entries.- Parameters:
change
- the number of index positions to move the entry.
-
resolveContent
public void resolveContent()For all basket entries, if their XML content is not resolved yet, resolves the XML from the given URI in the entry. -
spliterator
- Specified by:
spliterator
in interfaceCollection<MCRBasketEntry>
- Specified by:
spliterator
in interfaceIterable<MCRBasketEntry>
- Specified by:
spliterator
in interfaceList<MCRBasketEntry>
- Specified by:
spliterator
in interfaceSet<MCRBasketEntry>
-