S
- The tracked item. It is the key.T
- The value mapped to the tracked item.R
- The reason the tracked item is being tracked or untracked.abstract class AbstractTracked<S,T,R>
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.List<S> |
adding
List of items in the process of being added.
|
(package private) boolean |
closed
true if the tracked object is closed.
|
(package private) static boolean |
DEBUG |
private java.util.LinkedList<S> |
initial
Initial list of items for the tracker.
|
private java.util.Map<S,T> |
tracked
Map of tracked items to customized objects.
|
private int |
trackingCount
Modification count.
|
Constructor and Description |
---|
AbstractTracked()
AbstractTracked constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
close()
Called by the owning Tracker object when it is closed.
|
(package private) <M extends java.util.Map<? super S,? super T>> |
copyEntries(M map)
Copy the tracked items and associated values into the specified map.
|
(package private) S[] |
copyKeys(S[] list)
Copy the tracked items into an array.
|
(package private) abstract T |
customizerAdding(S item,
R related)
Call the specific customizer adding method.
|
(package private) abstract void |
customizerModified(S item,
R related,
T object)
Call the specific customizer modified method.
|
(package private) abstract void |
customizerRemoved(S item,
R related,
T object)
Call the specific customizer removed method.
|
(package private) T |
getCustomizedObject(S item)
Return the customized object for the specified item
|
(package private) int |
getTrackingCount()
Returns the tracking count for this
ServiceTracker object. |
(package private) boolean |
isEmpty()
Returns if the tracker is empty.
|
(package private) void |
modified()
Increment the modification count.
|
(package private) void |
setInitial(S[] list)
Set initial list of items into tracker before events begin to be
received.
|
(package private) int |
size()
Returns the number of tracked items.
|
(package private) void |
track(S item,
R related)
Begin to track an item.
|
private void |
trackAdding(S item,
R related)
Common logic to add an item to the tracker used by track and
trackInitial.
|
(package private) void |
trackInitial()
Track the initial list of items.
|
(package private) void |
untrack(S item,
R related)
Discontinue tracking the item.
|
static final boolean DEBUG
private int trackingCount
private final java.util.List<S> adding
volatile boolean closed
private final java.util.LinkedList<S> initial
void setInitial(S[] list)
list
- The initial list of items to be tracked. null
entries
in the list are ignored.void trackInitial()
void close()
void track(S item, R related)
item
- Item to be tracked.related
- Action related object.private void trackAdding(S item, R related)
item
- Item to be tracked.related
- Action related object.void untrack(S item, R related)
item
- Item to be untracked.related
- Action related object.int size()
boolean isEmpty()
T getCustomizedObject(S item)
item
- The item to lookup in the mapS[] copyKeys(S[] list)
list
- An array to contain the tracked items.void modified()
int getTrackingCount()
ServiceTracker
object.
The tracking count is initialized to 0 when this object is opened. Every
time an item is added, modified or removed from this object the tracking
count is incremented.<M extends java.util.Map<? super S,? super T>> M copyEntries(M map)
M
- Type of Map
to hold the tracked items and associated
values.map
- The map into which to copy the tracked items and associated
values. This map must not be a user provided map so that user code
is not executed while synchronized on this.abstract T customizerAdding(S item, R related)
item
- Item to be tracked.related
- Action related object.null
if the
item is not to be tracked.abstract void customizerModified(S item, R related, T object)
item
- Tracked item.related
- Action related object.object
- Customized object for the tracked item.abstract void customizerRemoved(S item, R related, T object)
item
- Tracked item.related
- Action related object.object
- Customized object for the tracked item.